ecterrab

14605 Reputation

24 Badges

20 years, 98 days

MaplePrimes Activity


These are answers submitted by ecterrab

Hi

This is the same question you posted in Symmetry analysis with parameters. I am copying from there the answer to your question:


In your worksheet, you input:

parameters = A, B

parameters = A, B

(1)

What you are missing here is the order of precedence of operations. You intended one object, an equation, with left-hand side being parameters and right-hand side being A, B. But = has higher precedence than `,` so you got two objects instead of one equation,

nops([parameters = A, B])

2

(2)

Where the first and second objects are, respectively,

op(1, [parameters = A, B])

parameters = A

(3)

op(2, [parameters = A, B])

B

(4)

So how do you input what you intended? Enclosing the parameters as a set or list, for instance as follows:

parameters = {A, B}

parameters = {A, B}

(5)

nops([parameters = {A, B}])

1

(6)

op(1, [parameters = {A, B}])

parameters = {A, B}

(7)

This is explained in the help page of the commands you are using.

``

 

So, by passing the parameters as a set (enclosed within {...}) or as a list (enclosed within [...]) you can work with an unlimited number of parameters and split into cases, as shown in my first reply to Symmetry analysis with parameters, with respect to some or all of them.

 

Download parameters_as_a_set.mw

 

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft


Define the Laplace operator; use simplify/size (not mandatory, but useful in cases like this)

L := proc (F) options operator, arrow; simplify(diff(r^2*(diff(F, r)), r)+(diff(sin(theta)*(diff(F, theta)), theta))/sin(theta)+(diff(F, phi, phi))/sin(theta), size) end proc

proc (F) options operator, arrow; simplify(diff(r^2*(diff(F, r)), r)+(diff(sin(theta)*(diff(F, theta)), theta))/sin(theta)+(diff(F, phi, phi))/sin(theta), size) end proc

(1)

For readability, use compact display (derivatives are displayed indexed and the function dependency ommited - check the help page for declare)

PDEtools:-declare(F(r, theta, phi))

F(r, theta, phi)*`will now be displayed as`*F

(2)

Try first Laplace operator itself on a function of r only

L(F(r))

r*((diff(diff(F(r), r), r))*r+2*(diff(F(r), r)))

(3)

The "second power" of the operator is just the composition of the operator with itself. In Maple, the composition operator is @ (check its help page)

L__2 := `@`(L, L)

L@@2

(4)

L__2(F(r, theta, phi))

(sin(theta)^3*(diff(diff(diff(diff(F(r, theta, phi), theta), theta), theta), theta))+2*(diff(diff(diff(diff(F(r, theta, phi), phi), phi), theta), theta))*sin(theta)^2+sin(theta)*(diff(diff(diff(diff(F(r, theta, phi), phi), phi), phi), phi))+2*r^2*(diff(diff(diff(diff(F(r, theta, phi), r), r), theta), theta))*sin(theta)^3+2*sin(theta)^2*(diff(diff(diff(diff(F(r, theta, phi), phi), phi), r), r))*r^2+sin(theta)^3*(diff(diff(diff(diff(F(r, theta, phi), r), r), r), r))*r^4+2*cos(theta)*sin(theta)^2*(diff(diff(diff(F(r, theta, phi), theta), theta), theta))+4*r*(diff(diff(diff(F(r, theta, phi), r), theta), theta))*sin(theta)^3+4*sin(theta)^2*(diff(diff(diff(F(r, theta, phi), phi), phi), r))*r+2*cos(theta)*sin(theta)^2*(diff(diff(diff(F(r, theta, phi), r), r), theta))*r^2+8*sin(theta)^3*(diff(diff(diff(F(r, theta, phi), r), r), r))*r^3+(-cos(theta)^2*sin(theta)-2*sin(theta)^3)*(diff(diff(F(r, theta, phi), theta), theta))+(cos(theta)^2+sin(theta)^2)*(diff(diff(F(r, theta, phi), phi), phi))+4*cos(theta)*sin(theta)^2*(diff(diff(F(r, theta, phi), r), theta))*r+14*sin(theta)^3*(diff(diff(F(r, theta, phi), r), r))*r^2+(cos(theta)^3+cos(theta)*sin(theta)^2)*(diff(F(r, theta, phi), theta))+4*sin(theta)^3*(diff(F(r, theta, phi), r))*r)/sin(theta)^3

(5)

You can also use the repeated composition operator, for instance to compose more than twice:

L__3 := L@@3

L@@3

(6)

L__3(F(phi))

(sin(theta)^2*(diff(diff(diff(diff(diff(diff(F(phi), phi), phi), phi), phi), phi), phi))+(5*cos(theta)^2*sin(theta)+3*sin(theta)^3)*(diff(diff(diff(diff(F(phi), phi), phi), phi), phi))+(9*cos(theta)^4+12*cos(theta)^2*sin(theta)^2+3*sin(theta)^4)*(diff(diff(F(phi), phi), phi)))/sin(theta)^5

(7)

``


Download powers_of_operators.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

Hi

The PDEtools:-dcoeffs command is probably what you are looking for. 

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

Hi zia,

Your question "Plot Heun in Maple" from October 24 is the same as this one now on "How to plot HeunTprime in Maple": you are entering your expressions using the (default) 2D input mode, which in my opinion works well for most things and is nicer than 1D, but for this "Smart Operators" (default is "checked") which keeps putting invisible multiplication operators between ][ and )( and that ends corrupting your input without you perceiving. So it is not you but this Smart Operators default. You can change that in "Maple -> Preferences -> Interface -> Smart operators", just uncheck it then click "Apply Global", and you will never have this problem again; i.e in your example in this post your [7.6613, 8.0102, 8.1790][1] will become 7.6613 instead of the nonsensical [7.6613, 8.0102, 8.1790]*[1].

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

Hi

Unfortunately, you use the MTM package and it redefines the 'dsolve' command in a way that it stops working properly. You do that after equation (2) of your worksheet.

So first you need to undo that redefinition (or otherwise do not load MTM). You can undo this wrong redefinition as shown in the reviewed worksheet (linked at the end) entering uprotect(dsolve): dsolve := eval(:-dsolve); protect(dsolve);

After doing that there is still another source of error interruption in your formulation: some letters x1... x10 depend on t, as in x10(t), others do not, as x8, and some appear both with and without dependency at the same time, in the system sys1, that you want to solve - that is not correct syntax. So second you need to revise who depends on t and who doesn't. In the reviewed worksheet linked at the end of this answer I made x9 and x10 depend on t always (as oppposed to some times yes and some other times no), but left x8 untouched for instance. In this way you can run dsolve without error interruptions. But then the output is "NULL" meaning the algorithms installed cannot solve this problem.

In summary: the question you mentioned in this post (what is the source of the error interruption) is resolved (the MTM issue) but you need to revise your formulation anyway in order to tell whether the system is or not solvable by Maple's dsolve.

M_(reviewed).mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

Hi

I enhanced one bit the design of the types in Physics so that from now on there are no more error interruptions in type commutative, anticommutative or noncommutative. So, the error interruptiion you noticed doesn't happen anymore. In order to install the new version you need to update your Physics.mla library with the one distributed on the Maplesoft R&D Physics webpage.

Independent of that, there is an issue with the generation of Matlab code: after equation (26), within the double loop seen in your worksheet, the code interrupts as shown below, but this has not to do with Physics and only with the way you are formulating your problem, I think. Note as well that in the worksheet you posted, from Physics, you only use diff and `.`, so you could as well, instead of "with(Physics)", use "with(Physics, diff, `.`)".

transverse_linearization_(reviewed).mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

The idea of providing these updates literally around the clock is relatively new. So there are updates only for Maple 17 and ahead till the current Maple 2015. By the way the update covers not only Physics, but also the Differential Equations and Mathematical Functions libraries.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft


Just saw your post today. A symbolic matrix is just an object for which the product is not commutative. Therefore you can use any noncommutative objects to produce the result you want. The Physics package is the tool for computing with noncommutative objects, including differentiation among other things.

For example:

with(Physics):

Set three operators (there is a one to one correspondence between a operator and a matrix; you can, if you want, but you do not need to indicate the dimension of the matrices)

Physics:-Setup(operator = {A, B, C})

`* Partial match of  'operator' against keyword 'quantumoperators'`

 

[quantumoperators = {A, B, C}]

(1)

Define now your matricial equation (use exponentiation with the product operator as exponent to represent the Dagger, which in the case of real matrices is the transpose)

C(t) = Typesetting:-delayDotProduct(Physics:-Dagger(A(t)), B(t))

C(t) = Physics:-`*`(Physics:-Dagger(A(t)), B(t))

(2)

Differentiate:

diff(C(t) = Physics:-`*`(Physics:-Dagger(A(t)), B(t)), t)

diff(C(t), t) = Physics:-`*`(diff(Physics:-Dagger(A(t)), t), B(t))+Physics:-`*`(Physics:-Dagger(A(t)), diff(B(t), t))

(3)

And that is essentially the result you wanted, all symbolic, it is 100% doable in Maple.

Another way of doing the same: set a noncommutative prefix:

Physics:-Setup(noncommutativeprefix = Z)

[noncommutativeprefix = {Z}]

(4)

Z__1(t) = Typesetting:-delayDotProduct(Physics:-Dagger(Z__2(t)), Z__3(t))

Z__1(t) = Physics:-`*`(Physics:-Dagger(Z__2(t)), Z__3(t))

(5)

diff(Z__1(t) = Physics:-`*`(Physics:-Dagger(Z__2(t)), Z__3(t)), t)

diff(Z__1(t), t) = Physics:-`*`(diff(Physics:-Dagger(Z__2(t)), t), Z__3(t))+Physics:-`*`(Physics:-Dagger(Z__2(t)), diff(Z__3(t), t))

(6)

Or you can also set many prefixes and use each one to represent one of the matrices of your problem:

Physics:-Setup(noncommutativeprefix = {R, S, T})

[noncommutativeprefix = {R, S, T}]

(7)

R(t) = Typesetting:-delayDotProduct(Physics:-Dagger(S(t)), T(t))

R(t) = Physics:-`*`(Physics:-Dagger(S(t)), T(t))

(8)

diff(R(t) = Physics:-`*`(Physics:-Dagger(S(t)), T(t)), t)

diff(R(t), t) = Physics:-`*`(diff(Physics:-Dagger(S(t)), t), T(t))+Physics:-`*`(Physics:-Dagger(S(t)), diff(T(t), t))

(9)

``


Download DifferentiatingSymbolicMatrices.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

 

with(PDEtools):

declare(u(x))

u(x)*`will now be displayed as`*u

(1)

PDE := diff(u(x), x, x)+A*u(x)^2

diff(diff(u(x), x), x)+A*u(x)^2

(2)

The call you are doing to DeterminingPDE automatically enforces integrability conditions assuming the parameters - in this case A -  are arbitrary, and you get as you show:

DetSys := DeterminingPDE([PDE])

{diff(diff(_xi[x](x, u), x), x) = 0, diff(_xi[x](x, u), u) = 0, _eta[u](x, u) = -2*(diff(_xi[x](x, u), x))*u}

(3)

Leading to the infinitesimals

pdsolve(DetSys)

{_eta[u](x, u) = -2*_C1*u, _xi[x](x, u) = _C1*x+_C2}

(4)

Library:-Specialize_Cn({_eta[u](x, u) = -2*_C1*u, _xi[x](x, u) = _C1*x+_C2})

{_eta[u](x, u) = -2*u, _xi[x](x, u) = x}, {_eta[u](x, u) = 0, _xi[x](x, u) = 1}

(5)

And that is the same you obtain in one go if you directly call Infinitesimals

Infinitesimals(PDE)

[_xi[x](x, u) = 1, _eta[u](x, u) = 0], [_xi[x](x, u) = x, _eta[u](x, u) = -2*u]

(6)

If you want to split into cases according to the values of the parameters involved, call DeterminingPDE with the option to not aplpy integrability conditions so that the system you obtain is not simplified and in this example includes A

DetSys := DeterminingPDE([PDE], integrability = false)

`* Partial match of  'integrability' against keyword 'integrabilityconditions'`

 

{diff(diff(_eta[u](x, u), u), u)-2*(diff(diff(_xi[x](x, u), u), x)), 3*(diff(_xi[x](x, u), u))*A*u^2+2*(diff(diff(_eta[u](x, u), u), x))-(diff(diff(_xi[x](x, u), x), x)), -(diff(_eta[u](x, u), u))*A*u^2+2*(diff(_xi[x](x, u), x))*A*u^2+diff(diff(_eta[u](x, u), x), x)+2*_eta[u](x, u)*A*u, diff(diff(_xi[x](x, u), u), u)}

(7)

Now split this system into cases taking A as a parameter

PDEtools:-casesplit({diff(diff(_eta[u](x, u), u), u)-2*(diff(diff(_xi[x](x, u), u), x)), 3*(diff(_xi[x](x, u), u))*A*u^2+2*(diff(diff(_eta[u](x, u), u), x))-(diff(diff(_xi[x](x, u), x), x)), -(diff(_eta[u](x, u), u))*A*u^2+2*(diff(_xi[x](x, u), x))*A*u^2+diff(diff(_eta[u](x, u), x), x)+2*_eta[u](x, u)*A*u, diff(diff(_xi[x](x, u), u), u)}, parameters = A)

`casesplit/ans`([diff(_eta[u](x, u), x) = 0, diff(_eta[u](x, u), u) = _eta[u](x, u)/u, diff(_xi[x](x, u), x) = -(1/2)*_eta[u](x, u)/u, diff(_xi[x](x, u), u) = 0], []), `casesplit/ans`([diff(diff(diff(_eta[u](x, u), u), u), x) = 0, diff(diff(diff(_eta[u](x, u), u), u), u) = 0, diff(diff(_eta[u](x, u), x), x) = 0, diff(diff(_xi[x](x, u), x), x) = 2*(diff(diff(_eta[u](x, u), u), x)), diff(diff(_eta[u](x, u), u), u) = 2*(diff(diff(_xi[x](x, u), u), x)), diff(diff(_xi[x](x, u), u), u) = 0, A = 0], [])

(8)

Leading to the following infinitesimals

map(pdsolve, [%], parameters = A)

Warning, the names [A] indicated as parameters were not found in the system.

 

[{_eta[u](x, u) = _C1*u, _xi[x](x, u) = -(1/2)*_C1*x+_C2}, {A = 0, _eta[u](x, u) = _C1*u*x+_C2*x+(1/2)*_C3*u^2+_C4*u+_C5, _xi[x](x, u) = _C1*x^2+(1/2)*(_C3*u+2*_C7)*x+_C6*u+_C8}]

(9)

map(Library:-Specialize_Cn, [{_eta[u](x, u) = _C1*u, _xi[x](x, u) = -(1/2)*_C1*x+_C2}, {A = 0, _eta[u](x, u) = _C1*u*x+_C2*x+(1/2)*_C3*u^2+_C4*u+_C5, _xi[x](x, u) = _C1*x^2+(1/2)*(_C3*u+2*_C7)*x+_C6*u+_C8}])

[{_eta[u](x, u) = u, _xi[x](x, u) = -(1/2)*x}, {_eta[u](x, u) = 0, _xi[x](x, u) = 1}, {A = 0, _eta[u](x, u) = u*x, _xi[x](x, u) = x^2}, {A = 0, _eta[u](x, u) = x, _xi[x](x, u) = 0}, {A = 0, _eta[u](x, u) = (1/2)*u^2, _xi[x](x, u) = (1/2)*u*x}, {A = 0, _eta[u](x, u) = u, _xi[x](x, u) = 0}, {A = 0, _eta[u](x, u) = 1, _xi[x](x, u) = 0}, {A = 0, _eta[u](x, u) = 0, _xi[x](x, u) = u}, {A = 0, _eta[u](x, u) = 0, _xi[x](x, u) = x}, {A = 0, _eta[u](x, u) = 0, _xi[x](x, u) = 1}]

(10)

NULL

 

 

Download PDETools_(reviewed).mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft


To have this working the way you want either use p_ . p_, as you said, or in addition to Vectors also load Physics:-`^` and Physics:-`*`, as shown below, and note please that this only works this way in Maple 2015 after updating the Physics library with the one available in the Maplesoft R&D Physics webpage.

restart;with(Physics,`^`,`*`):with(Physics[Vectors]);
Setup(mathematicalnotation=true);
Setup(geometricdifferentiation=true);

[`&x`, `+`, `.`, ChangeBasis, ChangeCoordinates, Component, Curl, DirectionalDiff, Divergence, Gradient, Identify, Laplacian, Nabla, Norm, Setup, diff]

 

[mathematicalnotation = true]

 

[geometricdifferentiation = true]

(1)

(* Derivation of the standard Hamiltonian from moderately-first principles.
 *)
Physics:-Version();

"/Users/ecterrab/Maple/lib/Physics2015.mla", `2015, November 8, 4:36 hours`

(2)

# We start with the relativistic Hamiltonian H=T+V = E:

H := sqrt(p_^2*c^2+m^2*c^4);

(Physics:-`^`(p_, 2)*c^2+m^2*c^4)^(1/2)

(3)

Note first that the expansion of a power of a vector is implemented, returning the square of the norm:

expand(H)

(Physics:-Vectors:-Norm(p_)^2*c^2+m^2*c^4)^(1/2)

(4)

Introduce now the components as you did

p_ := p1*_i+p2*_j+p3*_k;

_i*p1+_j*p2+_k*p3

(5)

So now H, or its expanded form, are given by

H;

(Physics:-`^`(_i*p1+_j*p2+_k*p3, 2)*c^2+m^2*c^4)^(1/2)

(6)

expand(H)

(c^4*m^2+c^2*p1^2+c^2*p2^2+c^2*p3^2)^(1/2)

(7)

You can differentiate directly, without having to indicate that c is real:

dH := diff(H, p1)

p1*c^2/(Physics:-`^`(_i*p1+_j*p2+_k*p3, 2)*c^2+m^2*c^4)^(1/2)

(8)

``


Download Derivation_of_H_(reviewed).mw


Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft


with(Physics:-Vectors);

[`&x`, `+`, `.`, ChangeBasis, ChangeCoordinates, Component, Curl, DirectionalDiff, Divergence, Gradient, Identify, Laplacian, Nabla, Norm, Setup, diff]

(1)

If all what you want is to use _x, _y and _z with the following meaning:

_x = _i, _y = _j, _z = _k;

_x = _i, _y = _j, _z = _k

(2)

Then you can use macro (check its help page), as in

macro(_x = _i, _y = _j, _z = _k):

So that now you can use _x, _y, _z meaning

_x, _y, _z

_i, _j, _k

(3)

If, however, what you want is for _i, _j, and _k to be displayed as _x, _y and _z, then you can use alias (again give a look at its help page please), as in

alias(_x = _i, _y = _j, _z = _k):

_x, _z, _z

_x, _z, _z

(4)

``


Download UnitVectors.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft


with(Physics):

This is a vector (postfix is an underscore - see the ?Physics,Vectors page)

f_(x, y, z)

f_(x, y, z)

(1)

Physics:-Vectors:-`+`(Physics:-Vectors:-Gradient(Physics:-Vectors:-Divergence(f_(x, y, z))), Physics:-`*`(K, Physics:-Vectors:-Laplacian(f_(x, y, z))))

Physics:-diff(Physics:-Vectors:-Divergence(f_(x, y, z)), x)*_i+Physics:-diff(Physics:-Vectors:-Divergence(f_(x, y, z)), y)*_j+Physics:-diff(Physics:-Vectors:-Divergence(f_(x, y, z)), z)*_k+K*(diff(diff(f_(x, y, z), y), y))+K*(diff(diff(f_(x, y, z), z), z))+K*(diff(diff(f_(x, y, z), x), x))

(2)

eval(Physics:-diff(Physics:-Vectors:-Divergence(f_(x, y, z)), x)*_i+Physics:-diff(Physics:-Vectors:-Divergence(f_(x, y, z)), y)*_j+Physics:-diff(Physics:-Vectors:-Divergence(f_(x, y, z)), z)*_k+K*(diff(diff(f_(x, y, z), y), y))+K*(diff(diff(f_(x, y, z), z), z))+K*(diff(diff(f_(x, y, z), x), x)), f_(x, y, z) = Physics:-Vectors:-`+`(Physics:-Vectors:-`+`(Physics:-`*`(f[1](x, y, z), _i), Physics:-`*`(f[2](x, y, z), _j)), Physics:-`*`(f[3](x, y, z), _k)));

(diff(diff(f[1](x, y, z), x), x)+diff(diff(f[2](x, y, z), x), y)+diff(diff(f[3](x, y, z), x), z))*_i+(diff(diff(f[1](x, y, z), x), y)+diff(diff(f[2](x, y, z), y), y)+diff(diff(f[3](x, y, z), y), z))*_j+(diff(diff(f[1](x, y, z), x), z)+diff(diff(f[2](x, y, z), y), z)+diff(diff(f[3](x, y, z), z), z))*_k+K*((diff(diff(f[1](x, y, z), y), y))*_i+(diff(diff(f[2](x, y, z), y), y))*_j+(diff(diff(f[3](x, y, z), y), y))*_k)+K*((diff(diff(f[1](x, y, z), z), z))*_i+(diff(diff(f[2](x, y, z), z), z))*_j+(diff(diff(f[3](x, y, z), z), z))*_k)+K*((diff(diff(f[1](x, y, z), x), x))*_i+(diff(diff(f[2](x, y, z), x), x))*_j+(diff(diff(f[3](x, y, z), x), x))*_k)

(3)

convert((diff(diff(f[1](x, y, z), x), x)+diff(diff(f[2](x, y, z), x), y)+diff(diff(f[3](x, y, z), x), z))*_i+(diff(diff(f[1](x, y, z), x), y)+diff(diff(f[2](x, y, z), y), y)+diff(diff(f[3](x, y, z), y), z))*_j+(diff(diff(f[1](x, y, z), x), z)+diff(diff(f[2](x, y, z), y), z)+diff(diff(f[3](x, y, z), z), z))*_k+K*((diff(diff(f[1](x, y, z), y), y))*_i+(diff(diff(f[2](x, y, z), y), y))*_j+(diff(diff(f[3](x, y, z), y), y))*_k)+K*((diff(diff(f[1](x, y, z), z), z))*_i+(diff(diff(f[2](x, y, z), z), z))*_j+(diff(diff(f[3](x, y, z), z), z))*_k)+K*((diff(diff(f[1](x, y, z), x), x))*_i+(diff(diff(f[2](x, y, z), x), x))*_j+(diff(diff(f[3](x, y, z), x), x))*_k), setofequations)

{diff(diff(f[1](x, y, z), x), x)+diff(diff(f[2](x, y, z), x), y)+diff(diff(f[3](x, y, z), x), z)+K*(diff(diff(f[1](x, y, z), y), y))+K*(diff(diff(f[1](x, y, z), z), z))+K*(diff(diff(f[1](x, y, z), x), x)) = 0, diff(diff(f[1](x, y, z), x), y)+diff(diff(f[2](x, y, z), y), y)+diff(diff(f[3](x, y, z), y), z)+K*(diff(diff(f[2](x, y, z), y), y))+K*(diff(diff(f[2](x, y, z), z), z))+K*(diff(diff(f[2](x, y, z), x), x)) = 0, diff(diff(f[1](x, y, z), x), z)+diff(diff(f[2](x, y, z), y), z)+diff(diff(f[3](x, y, z), z), z)+K*(diff(diff(f[3](x, y, z), y), y))+K*(diff(diff(f[3](x, y, z), z), z))+K*(diff(diff(f[3](x, y, z), x), x)) = 0}

(4)

 

Alternatively, you can also enter (1) directly specifying the function components and using compact display, as in

PDEtools:-declare(f(x, y, z))

f(x, y, z)*`will now be displayed as`*f

(5)

f_(x, y, z) := Physics:-Vectors:-`+`(Physics:-Vectors:-`+`(Physics:-`*`(f[1](x, y, z), _i), Physics:-`*`(f[2](x, y, z), _j)), Physics:-`*`(f[3](x, y, z), _k))

f[1](x, y, z)*_i+f[2](x, y, z)*_j+f[3](x, y, z)*_k

(6)

Physics:-Vectors:-`+`(Physics:-Vectors:-Gradient(Physics:-Vectors:-Divergence(f_(x, y, z))), Physics:-`*`(K, Physics:-Vectors:-Laplacian(f_(x, y, z))))

_i*(diff(diff(f[1](x, y, z), x), x)+diff(diff(f[2](x, y, z), x), y)+diff(diff(f[3](x, y, z), x), z)+K*(diff(diff(f[1](x, y, z), y), y))+K*(diff(diff(f[1](x, y, z), z), z))+K*(diff(diff(f[1](x, y, z), x), x)))+_j*(diff(diff(f[1](x, y, z), x), y)+diff(diff(f[2](x, y, z), y), y)+diff(diff(f[3](x, y, z), y), z)+K*(diff(diff(f[2](x, y, z), y), y))+K*(diff(diff(f[2](x, y, z), z), z))+K*(diff(diff(f[2](x, y, z), x), x)))+_k*(diff(diff(f[1](x, y, z), x), z)+diff(diff(f[2](x, y, z), y), z)+diff(diff(f[3](x, y, z), z), z)+K*(diff(diff(f[3](x, y, z), y), y))+K*(diff(diff(f[3](x, y, z), z), z))+K*(diff(diff(f[3](x, y, z), x), x)))

(7)

convert(_i*(diff(diff(f[1](x, y, z), x), x)+diff(diff(f[2](x, y, z), x), y)+diff(diff(f[3](x, y, z), x), z)+K*(diff(diff(f[1](x, y, z), y), y))+K*(diff(diff(f[1](x, y, z), z), z))+K*(diff(diff(f[1](x, y, z), x), x)))+_j*(diff(diff(f[1](x, y, z), x), y)+diff(diff(f[2](x, y, z), y), y)+diff(diff(f[3](x, y, z), y), z)+K*(diff(diff(f[2](x, y, z), y), y))+K*(diff(diff(f[2](x, y, z), z), z))+K*(diff(diff(f[2](x, y, z), x), x)))+_k*(diff(diff(f[1](x, y, z), x), z)+diff(diff(f[2](x, y, z), y), z)+diff(diff(f[3](x, y, z), z), z)+K*(diff(diff(f[3](x, y, z), y), y))+K*(diff(diff(f[3](x, y, z), z), z))+K*(diff(diff(f[3](x, y, z), x), x))), setofequations)

{diff(diff(f[1](x, y, z), x), x)+diff(diff(f[2](x, y, z), x), y)+diff(diff(f[3](x, y, z), x), z)+K*(diff(diff(f[1](x, y, z), y), y))+K*(diff(diff(f[1](x, y, z), z), z))+K*(diff(diff(f[1](x, y, z), x), x)) = 0, diff(diff(f[1](x, y, z), x), y)+diff(diff(f[2](x, y, z), y), y)+diff(diff(f[3](x, y, z), y), z)+K*(diff(diff(f[2](x, y, z), y), y))+K*(diff(diff(f[2](x, y, z), z), z))+K*(diff(diff(f[2](x, y, z), x), x)) = 0, diff(diff(f[1](x, y, z), x), z)+diff(diff(f[2](x, y, z), y), z)+diff(diff(f[3](x, y, z), z), z)+K*(diff(diff(f[3](x, y, z), y), y))+K*(diff(diff(f[3](x, y, z), z), z))+K*(diff(diff(f[3](x, y, z), x), x)) = 0}

(8)

``


Download VectorialEquation.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

 

This is your input:

plot3d([r, theta, -3.3203*HeunT(.4995036958*3^(2/3)/([1.1233, 6.8291, 12.2089, 17.4216, 32.9018, 53.2699, 64.3282]*[1])^(4/3), 0, (.3138423830*[1.1233, 6.8291, 12.2089, 17.4216, 32.9018, 53.2699, 64.3282])*[1]*3^(1/3), -.3258398511*3^(2/3)*r)*exp(0.5743565187e-1*r*(2.710463448*r^2+3))+4.9407*exp(-(.1148713037*(1.355231724*r^2+3/2))*r)*HeunT(.4277706929*3^(2/3), 0, .3525391488*3^(1/3), .3258398511*3^(2/3)*r)], r = 0 .. 1, theta = 0 .. 2*Pi, coords = cylindrical)

And as you noticed, it produces nothing.  This is the problem:

([1.1233, 6.8291, 12.2089, 17.4216, 32.9018, 53.2699, 64.3282]*[1])^(4/3)

([1.1233, 6.8291, 12.2089, 17.4216, 32.9018, 53.2699, 64.3282]*[1])^(4/3)

(1)

lprint(%)

([1.1233, 6.8291, 12.2089, 17.4216, 32.9018, 53.2699, 64.3282]*[1])^(4/3)

 

The `*` is incorrect of course, not your fault but an issue with 2D, that you can avoid by going to Preferences -> Interface -> Smart Operators: uncheck it so that an invisible multiplication is not inserted automatically between ][ or )(

 

To make the problem evident, when you find something strange using 2D input, the first thing to do is to place the same input in a 1D input line: just open a prompt below and press F5 to go from 2D to 1D input mode, now paste:

plot3d([r, theta, -3.3203*HeunT(.4995036958*3^(2/3)/([1.1233, 6.8291, 12.2089, 17.4216, 32.9018, 53.2699, 64.3282]*[1])^(4/3), 0, (.3138423830*[1.1233, 6.8291, 12.2089, 17.4216, 32.9018, 53.2699, 64.3282])*[1]*3^(1/3), -.3258398511*3^(2/3)*r)*exp(0.5743565187e-1*r*(2.710463448*r^2+3))+4.9407*exp(-(.1148713037*(1.355231724*r^2+3/2))*r)*HeunT(.4277706929*3^(2/3), 0, .3525391488*3^(1/3), .3258398511*3^(2/3)*r)], r = 0 .. 1, theta = 0 .. 2*Pi, coords = cylindrical);

 

Then look closer and you see the problem aforementioned. OK. Fix it now to obtain correct input, and hence the plot

plot3d([r, theta, -3.3203*HeunT(.4995036958*3^(2/3)/([1.1233, 6.8291, 12.2089, 17.4216, 32.9018, 53.2699, 64.3282][1])^(4/3), 0, (.3138423830*[1.1233, 6.8291, 12.2089, 17.4216, 32.9018, 53.2699, 64.3282])[1]*3^(1/3), -.3258398511*3^(2/3)*r)*exp(0.5743565187e-1*r*(2.710463448*r^2+3))+4.9407*exp(-(.1148713037*(1.355231724*r^2+3/2))*r)*HeunT(.4277706929*3^(2/3), 0, .3525391488*3^(1/3), .3258398511*3^(2/3)*r)], r = 0 .. 1, theta = 0 .. 2*Pi, coords = cylindrical)

 

Finally, answering the question you actually posted: by all means Heun functions can be plotted.

 

Download Heun_(reviewed).mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft


Hi vv,

Your system

sys := [diff(y(t), t) = y(t)^2-y(t)^3, y(0) = 1/10]

[diff(y(t), t) = y(t)^2-y(t)^3, y(0) = 1/10]

(1)

sol := dsolve(sys)

y(t) = RootOf(ln(_Z-1)*_Z-ln(_Z)*_Z-ln(9/10)*_Z-I*Pi*_Z-ln(10)*_Z+_Z*t-10*_Z+1)

(2)

As mentioned by Preben, this RootOf comes from solve. The expression sent to solve is, mainly,

sol__2 := DEtools[remove_RootOf](y(t) = RootOf(ln(_Z-1)*_Z-ln(_Z)*_Z-ln(9/10)*_Z-I*Pi*_Z-ln(10)*_Z+_Z*t-10*_Z+1))

ln(y(t)-1)*y(t)-ln(y(t))*y(t)-ln(9/10)*y(t)-I*Pi*y(t)-ln(10)*y(t)+y(t)*t-10*y(t)+1 = 0

(3)

This expression satisfies the initial conditions, also mentioned by Preben

eval(sol__2, [t = 0, y(t) = 1/10])

0 = 0

(4)

Now, your argument to say that dsolve's solution is wrong is that

eval(sol, [t = 0])

y(0) = RootOf(-ln(_Z-1)*_Z+ln(_Z)*_Z+ln(9/10)*_Z+I*Pi*_Z+ln(10)*_Z-1+10*_Z)

(5)

evalf(y(0) = RootOf(-ln(_Z-1)*_Z+ln(_Z)*_Z+ln(9/10)*_Z+I*Pi*_Z+ln(10)*_Z-1+10*_Z))

y(0) = 0.7601399434e-1-0.4409375242e-1*I

(6)

and in the above, you argue, if the solution were correct, the right-hand side should be equal to 1/10. It sounds reasonable.

 

My point here, however, is that I do not trust the numerical evaluation of any RootOf unless its argument is polynomial in _Z. Otherwise (as it happens in your example), there may be branch cuts in the expression entering as argument to RootOf, or multiple roots for which we have no closed formulas, and so the numerical algorithm that evaluates RootOf can end up computing "over the branch cut" and choosing one of the two values without you being aware of this arbitrariness of the numerical result, or even worse: start computing a root through one path, to suddenly jump to a different path sufficiently close but belonging to another root, leading to unexpected results without you noticing (typically resuting in a jig-saw plot for instance). In part for these reasons is that dsolve has the option 'implicit' also for ODE-IVP problems, which is rather unusual in computer algebra systems.

So le's take your example, and consider the expression (3) sent to solve (for which solve returned a RootOf) and evaluat it at t = 0, but without telling the value of y(0)

eval(sol__2, [t = 0])

ln(y(0)-1)*y(0)-ln(y(0))*y(0)-ln(9/10)*y(0)-I*Pi*y(0)-ln(10)*y(0)+1-10*y(0) = 0

(7)

Evaluate this numerically, then solve for y(0) .. requesting*all*solutions

evalf(ln(y(0)-1)*y(0)-ln(y(0))*y(0)-ln(9/10)*y(0)-I*Pi*y(0)-ln(10)*y(0)+1-10*y(0) = 0)

ln(y(0)-1.)*y(0)-1.*ln(y(0))*y(0)-12.19722458*y(0)-(3.141592654*I)*y(0)+1. = 0.

(8)

solve(ln(y(0)-1.)*y(0)-1.*ln(y(0))*y(0)-12.19722458*y(0)-(3.141592654*I)*y(0)+1. = 0., y(0), allsolutions)

0.7601399433e-1-0.4409375241e-1*I, 0.9999999998e-1-0.3691860874e-11*I

(9)

And there you are, with two solutions, not just one. The first solution is, actually, your argument to say that dsolve's output is wrong. The second solution, however is, actually, "y(0)=1/10,"which, for the same reason one could take as an indication that dsolve's output is correct. Putting all together, the only thing you can say is that, symbolically (ie exact solutions) , the expression (5) involving a RootOf is correct, in that, as shown above, if you remove the RootOf you see that the solution (3) verifies OK, exactly, as shown in (4), and for these problems you cannot verify correctness by numerically evaluating a RootOf whose argument is not polynomial in _Z.

To see that there are branch cuts in this expression you only need to check whether there is more than one value of y(t) for a given t (ie the function is multivalued). By eye, (3) is linear in t so in this case it is easy:

isolate(subs(y(t) = y, ln(y(t)-1)*y(t)-ln(y(t))*y(t)-ln(9/10)*y(t)-I*Pi*y(t)-ln(10)*y(t)+y(t)*t-10*y(t)+1 = 0), t)

t = (-ln(y-1)*y+ln(y)*y+ln(9/10)*y+I*Pi*y+ln(10)*y+10*y-1)/y

(10)

Compute now the branch cuts (if any) of the right-hand side

FunctionAdvisor(branch_cuts, rhs(t = (-ln(y-1)*y+ln(y)*y+ln(9/10)*y+I*Pi*y+ln(10)*y+10*y-1)/y))

[(-ln(y-1)*y+ln(y)*y+ln(9/10)*y+I*Pi*y+ln(10)*y+10*y-1)/y, And(0 <= y, y < 1)]

(11)

Ie there is a branch cut for "0<=y<1, "so the function is multivalued, you cannot rely on the numerical evaluation of RootOf. In these cases the only verification that I think is meaningful is the exact symbolic one, shown above, based on removing the RootOf from the solution.

ADDED AFTER POSTING THIS ANSWER: You can get the solution with LambertW using the appropriate optional argument, not obvious at all but anyway: skipimplicit

dsolve(sys, skipimplicit)

y(t) = 1/(LambertW(9*exp(9)*exp(1)*exp(-t-1))+1)

(12)

odetest(y(t) = 1/(LambertW(9*exp(9)*exp(1)*exp(-t-1))+1), sys)

[0, 0]

(13)


Download dsolve_not_a_bug.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

Hi
Instead of simplify(eq2), try simplify(convert(eq2, exp)) and you receive 0. So, no, pdetest is not returning a wrong result.

Have in mind, in general, that pdetest, as well as odetest, have all sorts of simplification manipulations, some of them very sophisticated, towards zero recognition, that go far beyond a simple call to a simplification command, and that are not easy to imagine immediately. These manipulations were collected analyzing different situations reported by users along the (19) years since pdetest entered the Maple library.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

First 39 40 41 42 43 44 45 Last Page 41 of 60