Carl Love

Carl Love

28035 Reputation

25 Badges

12 years, 318 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

I don't know how to solve them all together, or if it's possible at all, but we can easily use dsolve to solve (1) & (2) to get psi__1 and psi__2 as functions of x and likewise with (3) & (4) to get functions of t. Like this:

eq1:= diff(psi__1(x), x) = -I/2/lambda*(rho*psi__1(x) + alpha*exp(I*(x+rho/2*t))*psi__2(x)):
eq2:= diff(psi__2(x), x) = -I/2/lambda*(-rho*psi__2(x) + alpha*exp(-I*(x+rho/2*t))*psi__1(x)):
Sol__x:= dsolve({eq1, eq2});

eq3:= diff(psi__1(t), t) = I*lambda/2*psi__1(t) - alpha/2*exp(I*(x+rho/2*t))*psi__2(t):
eq4:= diff(psi__2(t), t) = -I*lambda/2*psi__2(t) + alpha/2*exp(-I*(x+rho/2*t))*psi__1(t):
Sol__t:= dsolve({eq3, eq4});

 

Do

P:= sort(R, output= permutation);
L[P]; M[P];

One option is to do this:

plots:-contourplot3d(
   f(x,y), x= 0..1, y= 0..1, contours= [0.1],
   thickness= 5, color= red
);

Why do you treat u and all of its derivatives as independent variables? The only independent variables are x, y, t. You can just do this:

a:= -4*D[1,1](u) + _F1:
convert(D[1](a)(x,y,t), diff);

This produces your expected output.

 

Here are a pair of procedures for it. The procedure Sumof2Squares computes the first square (the 259 in your example) then loops with procedure FermatDescent to lower the coefficient (the 34 in your case). By using trace, we can observe the iterations.

Notice that I use mods(..., m) rather than the more-usual (... mod m). This guarantees that the residue will be between -m/2 and m/2. This is needed to guarantee that the coefficient is reduced at each iteration and thus ends at 1.
 

restart:

Sumof2Squares:= proc(p::And(prime, satisfies(p-> irem(p,4)=1)))
local x, y:= 1;
   x:= mods(Roots(x^2+y^2), p)[2,1];
   while x^2+y^2 > p do
      (x,y):= FermatDescent(x,y,p)
   end do;
   (x,y)
end proc:

FermatDescent:= proc(x::posint, y::posint, p::posint)
local
   m:= (x^2+y^2)/p,
   a:= mods(x,m),  
   b:= mods(y,m)
;
   (abs((a*x+b*y)/m), abs((a*y-b*x)/m))
end proc:
   

trace(FermatDescent):

Sumof2Squares(1973);

{--> enter FermatDescent, args = 259, 1, 1973

 

34

 

-13

 

1

 

99, 8

 

<-- exit FermatDescent (now in Sumof2Squares) = 99, 8}
{--> enter FermatDescent, args = 99, 8, 1973

 

5

 

-1

 

-2

 

23, 38

 

<-- exit FermatDescent (now in Sumof2Squares) = 23, 38}

 

23, 38

(1)

do
   p:= 4*rand()+1;
   if isprime(p) then break fi
od:

p;

426028214629

(2)

Sumof2Squares(p);

{--> enter FermatDescent, args = 171429182709, 1, 426028214629

 

68981263858

 

33466654993

 

1

 

83169849211, 2

 

<-- exit FermatDescent (now in Sumof2Squares) = 83169849211, 2}
{--> enter FermatDescent, args = 83169849211, 2, 426028214629

 

16236539225

 

1987153086

 

2

 

10178968574, 10

 

<-- exit FermatDescent (now in Sumof2Squares) = 10178968574, 10}
{--> enter FermatDescent, args = 10178968574, 10, 426028214629

 

243203144

 

-35563474

 

10

 

1488465479, 420

 

<-- exit FermatDescent (now in Sumof2Squares) = 1488465479, 420}
{--> enter FermatDescent, args = 1488465479, 420, 426028214629

 

5200429

 

1142785

 

420

 

327087635, 120120

 

<-- exit FermatDescent (now in Sumof2Squares) = 327087635, 120120}
{--> enter FermatDescent, args = 327087635, 120120, 426028214629

 

251125

 

122885

 

120120

 

160113859, 156396240

 

<-- exit FermatDescent (now in Sumof2Squares) = 160113859, 156396240}
{--> enter FermatDescent, args = 160113859, 156396240, 426028214629

 

117589

 

-42359

 

2870

 

53860529, 60246410

 

<-- exit FermatDescent (now in Sumof2Squares) = 53860529, 60246410}
{--> enter FermatDescent, args = 53860529, 60246410, 426028214629

 

15329

 

-5577

 

3440

 

6075577, 34005770

 

<-- exit FermatDescent (now in Sumof2Squares) = 6075577, 34005770}
{--> enter FermatDescent, args = 6075577, 34005770, 426028214629

 

2801

 

208

 

-1171

 

13765454, 5065227

 

<-- exit FermatDescent (now in Sumof2Squares) = 13765454, 5065227}
{--> enter FermatDescent, args = 13765454, 5065227, 426028214629

 

505

 

164

 

77

 

5242687, 453946

 

<-- exit FermatDescent (now in Sumof2Squares) = 5242687, 453946}
{--> enter FermatDescent, args = 5242687, 453946, 426028214629

 

65

 

-18

 

-14

 

1549594, 1003486

 

<-- exit FermatDescent (now in Sumof2Squares) = 1549594, 1003486}
{--> enter FermatDescent, args = 1549594, 1003486, 426028214629

 

8

 

2

 

-2

 

136527, 638270

 

<-- exit FermatDescent (now in Sumof2Squares) = 136527, 638270}

 

136527, 638270

(3)

%[1]^2 + %[2]^2 = p;

426028214629 = 426028214629

(4)

 


 

Download FermatDescent.mw

There are several algorithms for this sum-of-two-squares problem. Fermat Descent is not the fastest, but it's not horribly slow either.

convert(exp(x^2), compose, FormalPowerSeries, GAMMA);

The issue is operator precedence, as VV pointed out. As usual, the precedence can be overridden by using parentheses:

(3 = 0) mod 3;

When doing pure integer arithmetic, it's better to use irem rather than mod:

irem(3,3);
irem(0,3);

A simple linear transformation (x-> 2*x-1) of 0..1 makes it -1..1.

RM:= Matrix((10$2), 2*rand(0..1) - 1);

Here I've performed arithmetic directly on the procedure rand(0..1), which produces a new procedure. This is different than

RM:= Matrix((10$2), ()-> 2*rand(1) - 1);

although both produce a matrix of uniformly distributed -1s and 1s.

It's not hosted by Maplesoft, but I highly recommend the question & answer site math.stackexchange.com

Some general mathematical discussions are welcome here on MaplePrimes. If your questions haven't been answered, it's because no one knows what to say, not because we think that your questions are irrelevant to this site. So, no offense is intended by a failure to answer. If material is truly irrelevant, it gets deleted or its irrelevance is quickly commented on.

In Maple 12, you can sort numeric (i.e., decimal) values by magnitude by

sort([Y], (x,y)-> abs(x) < abs(y));

In recent versions of Maple, this can be done more efficiently by

sort([Y], key= abs);

Like this

Pts:= [[0, 438.912], [0.0295, 402.336], [0.125, 365.76], [0.2009, 341.376]]:
plot(
   [Pts$2], style= [point, line], symbol= diamond, symbolsize= 12, 
   color= blue, gridlines, view= [0..0.25, 0..500]
);

 

Using printlevel is a crude tool for debugging only. It's impossible to get it to display only the information that you want. Thus it is never intended for the display the output of a finished procedure.

If you have a procedure that generates plots which are not the official return value of the procedure, but you want to see them anyway, the use print in the procedure, as in

print(plots[display]( ...your exact same display command here...));

The point-data matrices can be extracted from a plot like this:

P:= implicitplot(...your exact same command...);
(M1,M2):= map2(op, -1, [plottools:-getdata(P)])[];

Now M1 and M2 will both be two-column matrices, the first for disf and the second for dispbeamf.

How about

convert(simplify(eval(diff(f(x),x)*cos(f(x)), x= RootOf(f(x),x))), D);

 

Use eliminate instead of solve. The second set returned is the conditions (which must be understood to be equated to 0).

First 181 182 183 184 185 186 187 Last Page 183 of 395