dharr

Dr. David Harrington

8270 Reputation

22 Badges

20 years, 355 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are answers submitted by dharr

restart

with(VectorCalculus)

with(DETools)

with(DynamicSystems)

_local(I)

I

Warning, The imaginary unit, I, has been renamed _I

dS := -P*S*alpha-S*mu+Lambda; dE := alpha*S*P-(-T*eta+1)*beta*E-theta*E-mu*E; dI := (-T*eta+1)*beta*E-delta*I-gamma*I-mu*I; dR := E*theta+I*gamma-R*mu; dP := -P*T*sigma+I*xi-P*tau; dT := r*T*(1-T/K)-phi*T

-P*S*alpha-S*mu+Lambda

alpha*S*P-(-T*eta+1)*beta*E-theta*E-mu*E

(-T*eta+1)*beta*E-delta*I-gamma*I-mu*I

E*theta+I*gamma-R*mu

-P*T*sigma+I*xi-P*tau

r*T*(1-T/K)-phi*T

SEkuil := solve({dE, dI, dP, dR, dS, dT}, {E, I, P, R, S, T})

SEkuil_End := SEkuil[4]

E1 := eval(E, SEkuil_End)

(K^2*beta*delta*eta*mu*phi^2*sigma-2*K^2*beta*delta*eta*mu*phi*r*sigma+K^2*beta*delta*eta*mu*r^2*sigma+K^2*beta*eta*gamma*mu*phi^2*sigma-2*K^2*beta*eta*gamma*mu*phi*r*sigma+K^2*beta*eta*gamma*mu*r^2*sigma+K^2*beta*eta*mu^2*phi^2*sigma-2*K^2*beta*eta*mu^2*phi*r*sigma+K^2*beta*eta*mu^2*r^2*sigma+K*Lambda*alpha*beta*eta*phi*r*xi-K*Lambda*alpha*beta*eta*r^2*xi-K*beta*delta*eta*mu*phi*r*tau+K*beta*delta*eta*mu*r^2*tau-K*beta*eta*gamma*mu*phi*r*tau+K*beta*eta*gamma*mu*r^2*tau-K*beta*eta*mu^2*phi*r*tau+K*beta*eta*mu^2*r^2*tau+K*beta*delta*mu*phi*r*sigma-K*beta*delta*mu*r^2*sigma+K*beta*gamma*mu*phi*r*sigma-K*beta*gamma*mu*r^2*sigma+K*beta*mu^2*phi*r*sigma-K*beta*mu^2*r^2*sigma+K*delta*mu^2*phi*r*sigma-K*delta*mu^2*r^2*sigma+K*delta*mu*phi*r*sigma*theta-K*delta*mu*r^2*sigma*theta+K*gamma*mu^2*phi*r*sigma-K*gamma*mu^2*r^2*sigma+K*gamma*mu*phi*r*sigma*theta-K*gamma*mu*r^2*sigma*theta+K*mu^3*phi*r*sigma-K*mu^3*r^2*sigma+K*mu^2*phi*r*sigma*theta-K*mu^2*r^2*sigma*theta+Lambda*alpha*beta*r^2*xi-beta*delta*mu*r^2*tau-beta*gamma*mu*r^2*tau-beta*mu^2*r^2*tau-delta*mu^2*r^2*tau-delta*mu*r^2*tau*theta-gamma*mu^2*r^2*tau-gamma*mu*r^2*tau*theta-mu^3*r^2*tau-mu^2*r^2*tau*theta)/((K*eta*phi-K*eta*r+r)*xi*beta*(K*beta*eta*phi-K*beta*eta*r+beta*r+mu*r+r*theta)*alpha)

We want the above solution in terms of the following expression.

R0 := Lambda*alpha*beta*r*xi*(-K*eta*phi+K*eta*r-r)/(mu*(K*phi*sigma-K*r*sigma-r*tau)*(K*beta*eta*phi-K*beta*eta*r+beta*r+mu*r+r*theta)*(delta+gamma+mu))

Lambda*alpha*beta*r*xi*(-K*eta*phi+K*eta*r-r)/(mu*(K*phi*sigma-K*r*sigma-r*tau)*(K*beta*eta*phi-K*beta*eta*r+beta*r+mu*r+r*theta)*(delta+gamma+mu))

We can use simplify with side relations but we want the above relationship in polynomial form. This can be achieved by multiplying each side by the denominator, which amounts to requiring the following to be zero

siderel := numer(normal(R__0-R0))

K^2*R__0*beta*delta*eta*mu*phi^2*sigma-2*K^2*R__0*beta*delta*eta*mu*phi*r*sigma+K^2*R__0*beta*delta*eta*mu*r^2*sigma+K^2*R__0*beta*eta*gamma*mu*phi^2*sigma-2*K^2*R__0*beta*eta*gamma*mu*phi*r*sigma+K^2*R__0*beta*eta*gamma*mu*r^2*sigma+K^2*R__0*beta*eta*mu^2*phi^2*sigma-2*K^2*R__0*beta*eta*mu^2*phi*r*sigma+K^2*R__0*beta*eta*mu^2*r^2*sigma-K*R__0*beta*delta*eta*mu*phi*r*tau+K*R__0*beta*delta*eta*mu*r^2*tau-K*R__0*beta*eta*gamma*mu*phi*r*tau+K*R__0*beta*eta*gamma*mu*r^2*tau-K*R__0*beta*eta*mu^2*phi*r*tau+K*R__0*beta*eta*mu^2*r^2*tau+K*Lambda*alpha*beta*eta*phi*r*xi-K*Lambda*alpha*beta*eta*r^2*xi+K*R__0*beta*delta*mu*phi*r*sigma-K*R__0*beta*delta*mu*r^2*sigma+K*R__0*beta*gamma*mu*phi*r*sigma-K*R__0*beta*gamma*mu*r^2*sigma+K*R__0*beta*mu^2*phi*r*sigma-K*R__0*beta*mu^2*r^2*sigma+K*R__0*delta*mu^2*phi*r*sigma-K*R__0*delta*mu^2*r^2*sigma+K*R__0*delta*mu*phi*r*sigma*theta-K*R__0*delta*mu*r^2*sigma*theta+K*R__0*gamma*mu^2*phi*r*sigma-K*R__0*gamma*mu^2*r^2*sigma+K*R__0*gamma*mu*phi*r*sigma*theta-K*R__0*gamma*mu*r^2*sigma*theta+K*R__0*mu^3*phi*r*sigma-K*R__0*mu^3*r^2*sigma+K*R__0*mu^2*phi*r*sigma*theta-K*R__0*mu^2*r^2*sigma*theta-R__0*beta*delta*mu*r^2*tau-R__0*beta*gamma*mu*r^2*tau-R__0*beta*mu^2*r^2*tau-R__0*delta*mu^2*r^2*tau-R__0*delta*mu*r^2*tau*theta-R__0*gamma*mu^2*r^2*tau-R__0*gamma*mu*r^2*tau*theta-R__0*mu^3*r^2*tau-R__0*mu^2*r^2*tau*theta+Lambda*alpha*beta*r^2*xi

simplify(E1, {siderel})

-(sigma*(r-phi)*K+r*tau)*(delta+gamma+mu)*(R__0-1)*mu/(xi*alpha*beta*(eta*(r-phi)*K-r))

NULL

Download end.mw

I don't think there is a simple way to do this, but here is one way to make it convincing. Verifying the actual and your proposed formulas solve the equation is easier and could be a first step.

restart

eqn1 := sin(x) = 1/2

sin(x) = 1/2

Solve and then replace the variable starting with _Z by k.

ans1, ans2 := solve(eqn1, allsolutions); ans1 := eval(ans1, indets(ans1, suffixed(_Z))[] = k); ans2 := eval(ans2, indets(ans2, suffixed(_Z))[] = k)

(1/6)*Pi+2*Pi*_Z1, (5/6)*Pi+2*Pi*_Z1

(1/6)*Pi+2*Pi*k

(5/6)*Pi+2*Pi*k

ans3 := k*Pi+(1/6)*(-1)^k*Pi

Pi*k+(1/6)*(-1)^k*Pi

Check each of them individually satisfies the equation (could also apply evalb or is to get true).

`assuming`([simplify(eval(eqn1, x = ans1))], [k::integer]); `assuming`([simplify(eval(eqn1, x = ans2))], [k::integer]); `assuming`([simplify(eval(eqn1, x = ans3))], [k::integer])

1/2 = 1/2

1/2 = 1/2

1/2 = 1/2

Of course this doesn't show ans1 and ans2 cover the same values as ans3. We can generate some possibilities to see if this is true, but you have to try different ranges of k to see that they match

seq(ans3, k = -5 .. 5); seq(ans1, k = -2 .. 2); seq(ans2, k = -3 .. 2)

-(31/6)*Pi, -(23/6)*Pi, -(19/6)*Pi, -(11/6)*Pi, -(7/6)*Pi, (1/6)*Pi, (5/6)*Pi, (13/6)*Pi, (17/6)*Pi, (25/6)*Pi, (29/6)*Pi

-(23/6)*Pi, -(11/6)*Pi, (1/6)*Pi, (13/6)*Pi, (25/6)*Pi

-(31/6)*Pi, -(19/6)*Pi, -(7/6)*Pi, (5/6)*Pi, (17/6)*Pi, (29/6)*Pi

So this works

{seq(ans1, k = -2 .. 2), seq(ans2, k = -3 .. 2)} = {seq(ans3, k = -5 .. 5)}; evalb(%)

{-(31/6)*Pi, -(23/6)*Pi, -(19/6)*Pi, -(11/6)*Pi, -(7/6)*Pi, (1/6)*Pi, (5/6)*Pi, (13/6)*Pi, (17/6)*Pi, (25/6)*Pi, (29/6)*Pi} = {-(31/6)*Pi, -(23/6)*Pi, -(19/6)*Pi, -(11/6)*Pi, -(7/6)*Pi, (1/6)*Pi, (5/6)*Pi, (13/6)*Pi, (17/6)*Pi, (25/6)*Pi, (29/6)*Pi}

true

NULL

Download sets.mw

The answer to your second question is convert(Bans, trigh). But this can leave complex expressions as arguments, so you might want to also try convert(..., trig).

I more-or-less did it by hand here; I'm sure it could be streamlined.

restart;

s1 := arctan(2/n^2);
s2 := expand(convert(s1, ln));

arctan(2/n^2)

((1/2)*I)*ln(1-(2*I)/n^2)-((1/2)*I)*ln(1+(2*I)/n^2)

Take exp so we can do products instead of sums; find the pieces

p:=simplify(exp(s2),exp);
p1,e1:=op(op(1,p));
p2,e2:=op(op(2,p));

(1-(2*I)/n^2)^((1/2)*I)*(1+(2*I)/n^2)^(-(1/2)*I)

1-(2*I)/n^2, (1/2)*I

1+(2*I)/n^2, -(1/2)*I

We can do the products

P1:=product(p1, n=1.. infinity);
P2:=product(p2, n=1.. infinity);

(-1/2+(1/2)*I)*sin((2+I)*Pi)/Pi

(-1/2-(1/2)*I)*sin((2-I)*Pi)/Pi

Take the ln to reverse the expNULL

S:=simplify(e1*ln(P1)+e2*ln(P2));

(3/4)*Pi

 

Download sum.mw

Here's how I would do it, keeping close to how you did it. When using solve, if you get a warning about assumptions not used, add the useassumptions option.

restart

Levine - Ch. 2.4 - Particle in a Rectangular Well

 

In this problem, E < V__0 and m > 0.

assume(E < V__0, m > 0, `&hbar;` > 0)

NULL

Define

s__1 := sqrt(2*m*(V__0-E))/`&hbar;` = 2^(1/2)*(m*(V__0-E))^(1/2)/`&hbar;`NULL

s__2 := -s__1 = -2^(1/2)*(m*(V__0-E))^(1/2)/`&hbar;`NULL

s := sqrt(2*m*E)/`&hbar;`

2^(1/2)*(m*E)^(1/2)/`&hbar;`

`&psi;__1`, `&psi;__2` and `&psi;__3` are wavefunctions.

`&psi;__1` := proc (x) options operator, arrow; C*exp('s__1'*x) end proc = proc (x) options operator, arrow; C*exp('s__1'*x) end procNULL

`&psi;__2` := proc (x) options operator, arrow; A*cos('s'*x)+B*sin('s'*x) end proc = proc (x) options operator, arrow; A*cos('s'*x)+B*sin('s'*x) end procNULL

`&psi;__3` := proc (x) options operator, arrow; G*exp('s__2'*x) end proc = proc (x) options operator, arrow; G*exp('s__2'*x) end procNULL

``

As can be seen above, there are four unknown constants, "A,B,C,"and G.

 

We can obtain values for these unknowns by imposing boundary conditions.

 

Some of the boundary conditions involve the first derivatives of the wavefunctions.

`&psi;__1,d` := D(`&psi;__1`) = proc (z) options operator, arrow; C*s__1*exp(s__1*z) end procNULL

`&psi;__2,d` := D(`&psi;__2`) = proc (z) options operator, arrow; -A*s*sin(s*z)+B*s*cos(s*z) end procNULL

`&psi;__3,d` := D(`&psi;__3`) = proc (z) options operator, arrow; G*s__2*exp(s__2*z) end procNULL

NULL

The boundary conditions are

NULL

`&psi;__1`(0) = `&psi;__2`(0)*`&psi;__2`(l) and `&psi;__2`(0)*`&psi;__2`(l) = `&psi;__3`(l)*(D(`&psi;__1`))(0) and `&psi;__3`(l)*(D(`&psi;__1`))(0) = (D(`&psi;__2`))(0)*(D(`&psi;__2`))(l) and (D(`&psi;__2`))(0)*(D(`&psi;__2`))(l) = (D(`&psi;__3`))(l)

NULL

My question is how to find the constants in Maple.

NULL``

Solving the first boundary condition is easy.

expr1 := solve(`&psi;__1`(0) = `&psi;__2`(0), {C}, useassumptions) = {C = A}NULL

NULL

Next, I solve the third boundary condition and sub in the result from solving the first boundary condition. We get B in terms of A.

expr3 := simplify(eval(solve(`&psi;__1,d`(0) = `&psi;__2,d`(0), {B}), expr1)) = {B = A*(V__0-E)^(1/2)/E^(1/2)}NULL

``

Already here it is not clear to me why Maple does not cancel the m's - use simplify.

 

Next, consider the second boundary condition

expr2 := solve(`&psi;__2`(l) = `&psi;__3`(l), {G}, useassumptions) = {G = (A*cos(s*l)+B*sin(s*l))/exp(s__2*l)}NULL

 

We can obtain G in terms of just A by subbing in previously found relationships, as follows

expr2 := simplify(subs(expr3, expr2))

{G = exp(2^(1/2)*m^(1/2)*(V__0-E)^(1/2)*l/`&hbar;`)*A*(cos(2^(1/2)*m^(1/2)*E^(1/2)*l/`&hbar;`)*E^(1/2)+(V__0-E)^(1/2)*sin(2^(1/2)*m^(1/2)*E^(1/2)*l/`&hbar;`))/E^(1/2)}

NULL

Finally, consider the fourth boundary condition.

solve(`&psi;__2,d`(l) = `&psi;__3,d`(l), {G}, useassumptions)

{G = (m*E)^(1/2)*(A*sin(2^(1/2)*(m*E)^(1/2)*l/`&hbar;`)-B*cos(2^(1/2)*(m*E)^(1/2)*l/`&hbar;`))/((m*(V__0-E))^(1/2)*exp(-2^(1/2)*(m*(V__0-E))^(1/2)*l/`&hbar;`))}

expr4 := simplify(subs(expr3, solve(`&psi;__2,d`(l) = `&psi;__3,d`(l), {G}, useassumptions)))

{G = (-(V__0-E)^(1/2)*cos(2^(1/2)*m^(1/2)*E^(1/2)*l/`&hbar;`)+sin(2^(1/2)*m^(1/2)*E^(1/2)*l/`&hbar;`)*E^(1/2))*A*exp(2^(1/2)*m^(1/2)*(V__0-E)^(1/2)*l/`&hbar;`)/(V__0-E)^(1/2)}

result := simplify(subs(expr2, expr4))

{exp(2^(1/2)*m^(1/2)*(V__0-E)^(1/2)*l/`&hbar;`)*A*(cos(2^(1/2)*m^(1/2)*E^(1/2)*l/`&hbar;`)*E^(1/2)+(V__0-E)^(1/2)*sin(2^(1/2)*m^(1/2)*E^(1/2)*l/`&hbar;`))/E^(1/2) = (-(V__0-E)^(1/2)*cos(2^(1/2)*m^(1/2)*E^(1/2)*l/`&hbar;`)+sin(2^(1/2)*m^(1/2)*E^(1/2)*l/`&hbar;`)*E^(1/2))*A*exp(2^(1/2)*m^(1/2)*(V__0-E)^(1/2)*l/`&hbar;`)/(V__0-E)^(1/2)}

Subtract rhs-lhs, and divide through or multiply by the factors to cancel

result2 := simplify((rhs-lhs)(result[])*sqrt(V__0-E)*sqrt(E)/(exp(sqrt(2)*sqrt(m)*sqrt(V__0-E)*l/`&hbar;`)*A))

(2*E-V__0)*sin(2^(1/2)*m^(1/2)*E^(1/2)*l/`&hbar;`)-2*cos(2^(1/2)*m^(1/2)*E^(1/2)*l/`&hbar;`)*E^(1/2)*(V__0-E)^(1/2)

NULL

For example, I would like to replace sqrt(2*mE)/`&hbar;` with s. But s already has a value, so you need to use a different symbol or unassign it

s := 's'

s

Since this is essentially replacing all the ms

s = sqrt(2*m*E)/`&hbar;`; isolate(%, m); simplify(eval(result2, %))

(2*E-V__0)*sin((s^2/E)^(1/2)*E^(1/2)*l)-2*cos((s^2/E)^(1/2)*E^(1/2)*l)*E^(1/2)*(V__0-E)^(1/2)

 

This is a first task (that I have asked about in a separate question).

 

Then, I would want Maple to do the cancellations for me, but I have already used "simplify".

 

Finally, I think I would like to collect terms involving cos and sin.

 

Here is what happens when I try to get Maple to solve the equations for me in one go

 

solve({`&psi;__1`(0) = `&psi;__2`(0), `&psi;__1,d`(0) = `&psi;__2,d`(0), `&psi;__2`(l) = `&psi;__3`(l), `&psi;__2,d`(l) = `&psi;__3,d`(l)}, {A, B, C, G}, useassumptions)

{A = 0, B = 0, C = 0, G = 0}

NULL

 

NULL

Download solve_constants.mw

You did not change u(x,y,t) to u(x,y,z,t) in the code that extracts the linear part. After fixing that, there is no solution.
(The answer to the question about removing LambertW is that you can't).

remove2.mw

Basically, using indets gives you the (more complicated) subexpressions that you can directly substitute. I did it twice so there are no exps or square roots left, but you can go further if you wish.

restart

with(LinearAlgebra)

 

Additional conditions:

c1 := `&omega;__1`+`&omega;__2` = 1; c2 := f__p+f__d1+f__d2 = 1

f__p+f__d1+f__d2 = 1

All non-negative values (but f__p and T must be positive for the denominators to make sense).NULL

NULL

F := Matrix([[-(f__d1/f__p+1)*`&lambda;__1`, -`&omega;__1`*f__d2*`&lambda;__2`/f__p, `&omega;__1`, 0], [-(`&omega;__2`*f__d1/(`&omega;__1`*f__p)-1)*`&lambda;__1`, -(`&omega;__2`*f__d2/f__p+1)*`&lambda;__2`, `&omega;__2`, 0], [0, 0, 0, 1/T], [0, 0, 0, 0]])

Matrix(%id = 36893490587109511524)

 

 

 

Make the following substitutions right away, to reduce the number of variables by 2

NULLc3 := {isolate(c1, `&omega;__1`), isolate(c2, f__d1)}

{f__d1 = 1-f__p-f__d2, omega__1 = 1-omega__2}

F2 := simplify(eval(F, c3))

Matrix(%id = 36893490587109494780)

expFT := MatrixExponential(F2, T)NULL

NULL

inds := indets(expFT)

{T, f__d2, f__p, lambda__1, lambda__2, omega__2, 1/((-1+f__d2)^2*lambda__1^2-2*(f__d2^2*omega__2+(f__p-omega__2)*f__d2+f__p)*lambda__2*lambda__1+lambda__2^2*(f__d2*omega__2+f__p)^2)^(1/2), ((-1+f__d2)^2*lambda__1^2-2*(f__d2^2*omega__2+(f__p-omega__2)*f__d2+f__p)*lambda__2*lambda__1+lambda__2^2*(f__d2*omega__2+f__p)^2)^(1/2), exp((1/2)*(-f__d2*lambda__2*omega__2+f__d2*lambda__1-f__p*lambda__2-lambda__1+((-1+f__d2)^2*lambda__1^2-2*(f__d2^2*omega__2+(f__p-omega__2)*f__d2+f__p)*lambda__2*lambda__1+lambda__2^2*(f__d2*omega__2+f__p)^2)^(1/2))*T/f__p), exp(-(1/2)*(f__d2*lambda__2*omega__2-f__d2*lambda__1+f__p*lambda__2+((-1+f__d2)^2*lambda__1^2-2*(f__d2^2*omega__2+(f__p-omega__2)*f__d2+f__p)*lambda__2*lambda__1+lambda__2^2*(f__d2*omega__2+f__p)^2)^(1/2)+lambda__1)*T/f__p)}

musubs := `~`[`=`](select(has, inds, exp), {mu[1], mu[2]})

{exp((1/2)*(-f__d2*lambda__2*omega__2+f__d2*lambda__1-f__p*lambda__2-lambda__1+((-1+f__d2)^2*lambda__1^2-2*(f__d2^2*omega__2+(f__p-omega__2)*f__d2+f__p)*lambda__2*lambda__1+lambda__2^2*(f__d2*omega__2+f__p)^2)^(1/2))*T/f__p) = mu[1], exp(-(1/2)*(f__d2*lambda__2*omega__2-f__d2*lambda__1+f__p*lambda__2+((-1+f__d2)^2*lambda__1^2-2*(f__d2^2*omega__2+(f__p-omega__2)*f__d2+f__p)*lambda__2*lambda__1+lambda__2^2*(f__d2*omega__2+f__p)^2)^(1/2)+lambda__1)*T/f__p) = mu[2]}

expFTmu := subs(musubs, expFT); inds2 := indets(expFTmu)

{T, f__d2, f__p, lambda__1, lambda__2, omega__2, mu[1], mu[2], 1/((-1+f__d2)^2*lambda__1^2-2*(f__d2^2*omega__2+(f__p-omega__2)*f__d2+f__p)*lambda__2*lambda__1+lambda__2^2*(f__d2*omega__2+f__p)^2)^(1/2), ((-1+f__d2)^2*lambda__1^2-2*(f__d2^2*omega__2+(f__p-omega__2)*f__d2+f__p)*lambda__2*lambda__1+lambda__2^2*(f__d2*omega__2+f__p)^2)^(1/2)}

``

Check last two are reciprocals; since they are, convert them to 1/P and P

simplify(inds2[-2]-1/inds2[-1]); expFTmuP := simplify(subs(inds2[-1] = P, inds2[-2] = 1/P, expFTmu))

Matrix(%id = 36893490587266132316)

``

NULL

Download expFT_compact.mw

P.S. If the matrix were diagonalizable, I could probably do something more intelligent via the eigenvectors. Is the last row really intended to be zero?

The normal way to deal with a RootOf if you want an explicit solution would be to convert it to radical form. In your case, it is the root(s) of a quadratic, so you can use convert(E[u], radical) to get an explicit solution in terms of the quadratic formula. If you want both roots, you can use allvalues(E[u]). Or better yet, you probably got that result from solve, so you could add the option explicit to the solve command and not generate the RootOf in the first place. (remove_RootOf is just giving you an equivalent equation to solve, so you are not getting ahead by that method).

In future please upload your worksheet using the green up-arrow in the Mapleprimes editor, select your file, click upload, and then insert link or insert contents.

Here the derivation for the one lump case (sections in green). The two-lump case can be done similarly, I assume.

restart

with(PDEtools)

undeclare(prime, quiet); declare(u(x, y, t), quiet); declare(f(x, y, t), quiet)

pde := diff(u(x, y, t), t)-(diff(diff(u(x, y, t), `$`(x, 4))+5*u(x, y, t)*(diff(u(x, y, t), `$`(x, 2)))+(5/3)*u(x, y, t)^3+5*(diff(u(x, y, t), x, y)), x))-5*u(x, y, t)*(diff(u(x, y, t), y))+5*(int(diff(u(x, y, t), `$`(y, 2)), x))-5*(diff(u(x, y, t), x))*(int(diff(u(x, y, t), y), x))

diff(u(x, y, t), t)-(diff(diff(diff(diff(diff(u(x, y, t), x), x), x), x), x))-5*(diff(u(x, y, t), x))*(diff(diff(u(x, y, t), x), x))-5*u(x, y, t)*(diff(diff(diff(u(x, y, t), x), x), x))-5*u(x, y, t)^2*(diff(u(x, y, t), x))-5*(diff(diff(diff(u(x, y, t), x), x), y))-5*u(x, y, t)*(diff(u(x, y, t), y))+5*(int(diff(diff(u(x, y, t), y), y), x))-5*(diff(u(x, y, t), x))*(int(diff(u(x, y, t), y), x))

pde_linear, pde_nonlinear := selectremove(proc (term) options operator, arrow; not has((eval(term, u(x, y, t) = a*u(x, y, t)))/a, a) end proc, expand(pde))

diff(u(x, y, t), t)-(diff(diff(diff(diff(diff(u(x, y, t), x), x), x), x), x))-5*(diff(diff(diff(u(x, y, t), x), x), y))+5*(int(diff(diff(u(x, y, t), y), y), x)), -5*(diff(u(x, y, t), x))*(diff(diff(u(x, y, t), x), x))-5*u(x, y, t)*(diff(diff(diff(u(x, y, t), x), x), x))-5*u(x, y, t)^2*(diff(u(x, y, t), x))-5*u(x, y, t)*(diff(u(x, y, t), y))-5*(diff(u(x, y, t), x))*(int(diff(u(x, y, t), y), x))

thetai := t*w[i]+y*p[i]+x

t*w[i]+y*p[i]+x

eqw := w[i] = -5*p[i]^2

w[i] = -5*p[i]^2

Bij := proc (i, j) options operator, arrow; (-6*p[i]-6*p[j])/(p[i]-p[j])^2 end proc

proc (i, j) options operator, arrow; (-6*p[i]-6*p[j])/(p[i]-p[j])^2 end proc

NULL

theta1 := normal(eval(eval(thetai, eqw), i = 1)); theta2 := normal(eval(eval(thetai, eqw), i = 2))

-5*t*p[1]^2+y*p[1]+x

-5*t*p[2]^2+y*p[2]+x

eqf := f(x, y, t) = theta1*theta2+Bij(1, 2)

f(x, y, t) = (-5*t*p[1]^2+y*p[1]+x)*(-5*t*p[2]^2+y*p[2]+x)+(-6*p[1]-6*p[2])/(p[1]-p[2])^2

eqfcomplex := collect(evalc(eval(eval(eqf, p[2] = conjugate(p[1])), p[1] = a+I*b)), t)

f(x, y, t) = ((-5*a^2+5*b^2)^2+100*a^2*b^2)*t^2+(2*(a*y+x)*(-5*a^2+5*b^2)-20*y*b^2*a)*t+(a*y+x)^2+y^2*b^2+3*a/b^2

Eqs 16,17

eqp := {x = xp-(5*(a^2+b^2))*t, y = 10*a*t+yp}; eqfc2 := f(x, y, t) = simplify(eval(rhs(eqfcomplex), eqp))

f(x, y, t) = (b^4*yp^2+(a*yp+xp)^2*b^2+3*a)/b^2

eq17 := u(x, y, t) = 6*(diff(diff(f(x, y, t), x), x))/f(x, y, t)-6*(diff(f(x, y, t), x))^2/f(x, y, t)^2

u(x, y, t) = 6*(diff(diff(f(x, y, t), x), x))/f(x, y, t)-6*(diff(f(x, y, t), x))^2/f(x, y, t)^2

Eq 18

eqt := u(x, y, t) = simplify(eval(rhs(eval(eq17, eqfcomplex)), eqp))

u(x, y, t) = -12*(-b^4*yp^2+(a*yp+xp)^2*b^2-3*a)*b^2/(b^4*yp^2+(a*yp+xp)^2*b^2+3*a)^2

Alternatively,

eqfp := dchange(eqp, eqfcomplex, [xp, yp], params = [a, b], simplify); eq17p := dchange(eqp, eq17, [xp, yp], params = [a, b], simplify); eqt := simplify(eval(eq17p, eqfp))

f(xp, yp, t) = (b^4*yp^2+(a*yp+xp)^2*b^2+3*a)/b^2

u(xp, yp, t) = (6*(diff(diff(f(xp, yp, t), xp), xp))*f(xp, yp, t)-6*(diff(f(xp, yp, t), xp))^2)/f(xp, yp, t)^2

u(xp, yp, t) = -12*(-b^4*yp^2+(a*yp+xp)^2*b^2-3*a)*b^2/(b^4*yp^2+(a*yp+xp)^2*b^2+3*a)^2

Eq 17 is the parametric equation for a line.
velocities are derivatives wrt t. (after eq 19)

Intercept is at the origin (x=0,y=0 at t=0), and slope is dy/dx (Eq 19).

vx, vy := diff(eval(x, eqp), t), diff(eval(y, eqp), t); dydx := simplify(vy/vx)

-5*a^2-5*b^2, 10*a

-2*a/(a^2+b^2)

``

NULL

Download Y-pde-line.mw

restart

i1 := int(sin(t^2), t = x .. x+1)

-(1/2)*FresnelS(x*2^(1/2)/Pi^(1/2))*2^(1/2)*Pi^(1/2)+(1/2)*FresnelS((x+1)*2^(1/2)/Pi^(1/2))*2^(1/2)*Pi^(1/2)

plot(i1, x = -5 .. 50)

q := x^(1-epsilon)*i1; plot3d(q, x = 0 .. 50, epsilon = 0 .. 10)

x^(1-epsilon)*(-(1/2)*FresnelS(x*2^(1/2)/Pi^(1/2))*2^(1/2)*Pi^(1/2)+(1/2)*FresnelS((x+1)*2^(1/2)/Pi^(1/2))*2^(1/2)*Pi^(1/2))

`assuming`([limit(q, x = infinity)], [epsilon > 0])

0

NULL

Download limit.mw

Here is an answer to a followup question, now deleted, in which the evalc and pdetest were much slower because of a more complicated function f. I'm guessing the integrals in the original pde are problematic, so suggest working with the pde in f. For the evalc, if you do it on the simpler f and not u it is also manageable.

Question file: stop-working_question.mw

restart

with(PDEtools)

undeclare(prime, quiet); declare(u(x, y, t), quiet); declare(f(x, y, t), quiet)

pde := diff(u(x, y, t), t)-(diff(diff(u(x, y, t), `$`(x, 4))+5*u(x, y, t)*(diff(u(x, y, t), `$`(x, 2)))+(5/3)*u(x, y, t)^3+5*(diff(u(x, y, t), x, y)), x))-5*u(x, y, t)*(diff(u(x, y, t), y))+5*(int(diff(u(x, y, t), `$`(y, 2)), x))-5*(diff(u(x, y, t), x))*(int(diff(u(x, y, t), y), x))

eq17 := u(x, y, t) = 6*(diff(diff(f(x, y, t), x), x))/f(x, y, t)-6*(diff(f(x, y, t), x))^2/f(x, y, t)^2

The integrals in pde are problematic for fast evaluation, so work in the pde for f

pdef := numer(normal(eval(pde, eq17)))

30*f(x, y, t)^2*(diff(diff(diff(f(x, y, t), x), y), y))-30*f(x, y, t)^2*(diff(diff(diff(diff(diff(f(x, y, t), x), x), x), x), y))+6*f(x, y, t)^2*(diff(diff(diff(f(x, y, t), t), x), x))-6*f(x, y, t)^2*(diff(diff(diff(diff(diff(diff(diff(f(x, y, t), x), x), x), x), x), x), x))-60*f(x, y, t)*(diff(f(x, y, t), y))*(diff(diff(f(x, y, t), x), y))+30*f(x, y, t)*(diff(f(x, y, t), y))*(diff(diff(diff(diff(f(x, y, t), x), x), x), x))-6*f(x, y, t)*(diff(diff(f(x, y, t), x), x))*(diff(f(x, y, t), t))-54*f(x, y, t)*(diff(diff(f(x, y, t), x), x))*(diff(diff(diff(diff(diff(f(x, y, t), x), x), x), x), x))-30*f(x, y, t)*(diff(diff(f(x, y, t), y), y))*(diff(f(x, y, t), x))-60*f(x, y, t)*(diff(diff(f(x, y, t), x), y))*(diff(diff(diff(f(x, y, t), x), x), x))+120*f(x, y, t)*(diff(f(x, y, t), x))*(diff(diff(diff(diff(f(x, y, t), x), x), x), y))-12*f(x, y, t)*(diff(f(x, y, t), x))*(diff(diff(f(x, y, t), t), x))+42*f(x, y, t)*(diff(f(x, y, t), x))*(diff(diff(diff(diff(diff(diff(f(x, y, t), x), x), x), x), x), x))+30*f(x, y, t)*(diff(diff(diff(f(x, y, t), x), x), x))*(diff(diff(diff(diff(f(x, y, t), x), x), x), x))-180*(diff(diff(diff(f(x, y, t), x), x), y))*(diff(f(x, y, t), x))^2+60*(diff(f(x, y, t), x))*(diff(f(x, y, t), y))^2-60*(diff(diff(diff(f(x, y, t), x), x), x))*(diff(f(x, y, t), x))*(diff(f(x, y, t), y))+180*(diff(diff(f(x, y, t), x), x))*(diff(f(x, y, t), x))*(diff(diff(f(x, y, t), x), y))+180*(diff(diff(diff(diff(f(x, y, t), x), x), x), x))*(diff(f(x, y, t), x))*(diff(diff(f(x, y, t), x), x))+12*(diff(f(x, y, t), x))^2*(diff(f(x, y, t), t))-72*(diff(diff(diff(diff(diff(f(x, y, t), x), x), x), x), x))*(diff(f(x, y, t), x))^2-120*(diff(diff(diff(f(x, y, t), x), x), x))^2*(diff(f(x, y, t), x))

thetai := t*w[i]+y*p[i]+x

eqw := w[i] = -5*p[i]^2

Bij := proc (i, j) options operator, arrow; (-6*p[i]-6*p[j])/(p[i]-p[j])^2 end proc

eqf2 := f(x, y, t) = (-5*t*p[1]^2+y*p[1]+x)*(-5*t*p[2]^2+y*p[2]+x)*(-5*t*p[3]^2+y*p[3]+x)*(-5*t*p[4]^2+y*p[4]+x)-(6*(p[1]+p[2]))*(-5*t*p[3]^2+y*p[3]+x)*(-5*t*p[4]^2+y*p[4]+x)/(p[1]-p[2])^2-(6*(p[1]+p[3]))*(-5*t*p[2]^2+y*p[2]+x)*(-5*t*p[4]^2+y*p[4]+x)/(p[1]-p[3])^2-(6*(p[1]+p[4]))*(-5*t*p[2]^2+y*p[2]+x)*(-5*t*p[3]^2+y*p[3]+x)/(p[1]-p[4])^2-(6*(p[2]+p[3]))*(-5*t*p[1]^2+y*p[1]+x)*(-5*t*p[4]^2+y*p[4]+x)/(p[2]-p[3])^2-(6*(p[2]+p[4]))*(-5*t*p[1]^2+y*p[1]+x)*(-5*t*p[3]^2+y*p[3]+x)/(p[2]-p[4])^2-(6*(p[3]+p[4]))*(-5*t*p[1]^2+y*p[1]+x)*(-5*t*p[2]^2+y*p[2]+x)/(p[3]-p[4])^2+(36*(p[1]+p[2]))*(p[3]+p[4])/((p[1]-p[2])^2*(p[3]-p[4])^2)+(36*(p[1]+p[3]))*(p[2]+p[4])/((p[1]-p[3])^2*(p[2]-p[4])^2)+(36*(p[1]+p[4]))*(p[2]+p[3])/((p[1]-p[4])^2*(p[2]-p[3])^2)

CodeTools:-Usage(simplify(eval(pdef, eqf2)))

memory used=0.63GiB, alloc change=483.86MiB, cpu time=98.80s, real time=18.07s, gc time=296.88ms

0

evalc is slow on the complicated expression, so do it on the expression for f first

eqf2complex := evalc(eval(eval(eqf2, {p[3] = conjugate(p[1]), p[4] = conjugate(p[2])}), {p[1] = pR+I*pI, p[2] = hR+I*hI}))

And now substitute to get the expression for u

equ2 := eval(eq17, eqf2complex)

indets(rhs(equ2))

{hI, hR, pI, pR, t, x, y}

NULL

Download stop-working.mw

 

restart;

change:=proc(a::integer, b::{identical(10),identical(20),identical(30)})
  a*b;
end proc:

change(3,11);

Error, invalid input: change expects its 2nd argument, b, to be of type {identical(10), identical(20), identical(30)}, but received 11

change(3,10);

30

NULL

Download identical.mw

Maple has the _options mechanism for this purpose, see the help page. Passing _options to your embedded procedure passes all the keyword arguments. If you just want to pass some of them, such as color, then use the syntax _options['color'].

If you don't need to override the default values used by plot, then the simplest is to use _rest. In this case, use

ecdf := proc(S) ... end proc;

and pass _rest to the plot routines; the rest of the arguments (aside from S) that were passed are passed on to the plot routines. This of course doesn't do any argument checking, so has some downsides. Or you can use some combined strategy.

restart

ecdf := proc(S, {color::string:="blue", thickness::posint:=1})
  local N   := numelems(S):
  local M   := sort(S):
  local i;
  plots:-display(
    plot([ seq(op([[M[i], (i-1)/N], [M[i], i/N], [M[i+1], i/N]]), i=1..N-1) ], _options)
    , plot([ [M[N], (N-1)/N], [M[N], 1] ], _options)
    , plot([ [M[N], 1], [(max+(max-min)*0.2)(S), 1] ], _options, 'linestyle'=3)
    , plot([ [M[1], 0], [(min-(max-min)*0.2)(S), 0] ], _options, 'linestyle'=3)
  )
end proc:

S := Statistics:-Sample(Uniform(0, 1), 10):
ecdf(S)

ecdf(S, color="red", thickness=3)

 

Download ecdf.mw

If I understand correctly, you want 99.9999999 to return 1, not 2. Then ilog10 will work.

In general, if there is a symbolic solution, it is preferred, since the sorts of numerical issues you get here don't occur. Here my workarounds, and comments in italics.

Note that ConditionNumber(Snum) returns a very high value, which is probably why LinearSolve (and fsolve) have difficulty finding both solutions; this will generally be the case when you are solving (A-lambda*I)x =0, (where lambda is an eigenvalue).

restart

with(LinearAlgebra)

A := `<,>`(`<|>`(-2*`&omega;__0`^2, `&omega;__0`^2), `<|>`(`&omega;__0`^2, -`&omega;__0`^2))

Matrix(%id = 36893490302213400324)

AA := subs(`&omega;__0` = 3, A)

Matrix(%id = 36893490302213398268)

evs, evecs := Eigenvectors(AA); evsnum, evecsnum := evalf(%)

Vector[column](%id = 36893490302213376228), Matrix(%id = 36893490302213376348)

NULL

Below is an eigenvector equation for AA for the eigenvalue -3.4376...

 

S := AA-evs[1]*IdentityMatrix(2); Rank(S); Snum := AA-evsnum[1]*IdentityMatrix(2); Rank(Snum)

1

When I solve the system below, I expect to get the vector `<,>`(.6180, 1)

Vector[column](%id = 36893490302356068700)

, just like the result of the Eigenvectors command used above.

 

LinearSolve(Snum, `<,>`(0, 0)); NullSpace(Snum)

{Vector[column](%id = 36893490302356058708)}

Instead I get the zero vector. You can use NullSpace to get around this.

If you do it symbolically, you find there is a degree of freedom with LinearSolve. Different values of the variable starting with an underline can give both the zero vector, and a multiple of the eigenvector (whose length is arbitrary). Since the zero vector is not in the nullspace, you only get the eigenvector with NullSpace.

 

LinearSolve(S, `<,>`(0, 0)); NullSpace(S)

{Vector[column](%id = 36893490302356047140)}

In addition, when I compute the reduced row echelon form, I expect to have one of the rows be zero since matrix S has rank 1.

 

Rank(Snum)

1

ReducedRowEchelonForm(Snum)

Matrix(%id = 36893490302356043164)

We get the expected results with a symbolic solution

NULLRank(S)

1

ReducedRowEchelonForm(S)

Matrix(%id = 36893490302356041228)

Therefore, I guess my question is maybe about calculations and not about Maple. That being said, I did the calculations manually, then I asked chatgpt, which agreed with me.

 

Why are the calculations not coinciding with Maple?

 

I can do the calculations "manually" with Maple, For numeric calculations use fsolve

 

fsolve(-14.5623059000000*x+9*y = 0)

{x = .6180339887*y, y = y}

fsolve(9*x-5.56230590000000*y = 0)

{x = .6180339888*y, y = y}

 

Now, if I try to solve them simultaneously, it seems I have the same issue as with LinearSolve. fsolve gives one real solution

NULL

fsolve({9*x-5.56230590000000*y = 0, -14.5623059000000*x+9*y = 0}, {x, y})

{x = -0., y = -0.}

For the other one, give it a range excluding zero. Fails here so numerical reasons that aren't exactly clear to me.

fsolve({9*x-5.5623059*y = 0, -14.5623059*x+9*y = 0}, {x = .1 .. 100, y = .1 .. 100})

fsolve({9*x-5.5623059*y = 0, -14.5623059*x+9*y = 0}, {x, y}, {x = .1 .. 100, y = .1 .. 100})

But we can do it symbolically - as with LinearSolve we can get both the zero vector and the eigenvector with different choices of x.

eqns := GenerateEquations(S, [x, y])

[-(9/2)*x-(9/2)*x*5^(1/2)+9*y = 0, 9*x+(9/2)*y-(9/2)*y*5^(1/2) = 0]

ans := solve(eqns, {x, y})

{x = x, y = (1/2)*x*5^(1/2)+(1/2)*x}

NULL

Download evcalc.mw

5 6 7 8 9 10 11 Last Page 7 of 82