Maple 2019 Questions and Posts

These are Posts and Questions associated with the product, Maple 2019

I've recently changed to maple 2019, from the 2016 version as my license for that product had expired. 
However I find it really frustrating that often upon evaluating an expression I can't convert the units. 

For instance I had a calculation that evaluated to: 

2.114163508*10^7 [kg/s^2]
 

When I try to directly replace the units within maple to instead be [J/m^2] I recieve the following error message: 


"Error, (in  Units:-TestDimensions) 'op(3, i) does not  evaluate to module" 

There is no explanation for this error when I try to look it up. However if I once again manually write the answer: 
2.114163508*10^7 [kg/s^2] and use the replace units function. 
No problem. 
I find this quite annoying and frustrating and I hope you can help.
 

Best regards 

Anders Alexander Wagenblast 

Hello all

I am going to find the diffusion constant in the following equation :

PDE:=diff(C(x,t),t)=d*diff(C(x,t),x,x);

In a way that ,

evalf(Int(C(x,t=specific),x=0..L))/L - m_number(t=specific)=0
 

In other words, It would be an iterative procedure to guess "d" and then find the solution C (something like shooting method). The objective is to find "d" in a way that the average of C (solution of PDE) would be equal to m_number at that specific time.

Also, Since I have 5 specific time and m_number, I will have 5 different d. So, I need to use least square method or other optimization technique find one finalized d value.

I have uploaded my code.

inverse_numerical_diffusion.mw

I am not good at using Proc command and  I think the error of my code is because of that.

Would you help me to find out my problem in the code and any new idea for solviong this equaltion would be greatly appreciated.

Thank you for your kind attentions in advance

Amir

 

 

The integral of y = Dirac(phi-m), in which phi is a continuously variable quantity and m is a positive integer, from -infinity to infinity yields 1 as an answer.   The analogous integral of y2 yields no answer.  Is it possible that the latter integral has some mathematical meaning that might yield an answer?

This is may be a philosophical question. But sometimes Maple suprises me when telling it to "simplify" expression. As in this example.

expr:=1/(y^3+1)^(2/3);

1/(y^3+1)^(2/3)

int(expr,y)

y*hypergeom([1/3, 2/3], [4/3], -y^3)

simplify(%)

(2/9)*y*Pi*3^(1/2)*LegendreP(-1/3, -1/3, (-y^3+1)/(y^3+1))/((-y^3)^(1/6)*(y^3+1)^(1/3)*GAMMA(2/3))

 


For me, the original result is "simpler". (Not only smaller leaf count, but it has one special function, vs. two: Legendre and Gamma). But may be Maple considers hypergeom always more "complex" than any other?

That is why I use simplify(expr,size) because I am scared of simplify without any option, as I have little idea how it decides which is simpler.

Any thoughts from the experts on how Maple decided to simplify something when no option is used? What kinds of rules it uses to decide how to transform the expression?

Maple 2019.1

 

Download simplify.mw

In the DE solution below I cannot convert the RootOf function to radicals.
macro(solve = allvalues@solve);
_EnvExplicit := true;
de := x^4*diff(y(x), x $ 2) + omega^2*y(x) = 0;
bc := y(a) = 0, y(b) = 0, D(y)(a) = 1;
dsol := (dsolve({bc, de}, {omega, y(x)}) assuming (0 < a, a < b));
convert(dsol, radical);
{omega = RootOf(tan(_Z)*_Z*b*_C2 - sin(-2*_B5*Pi + 2*Pi*_Z10 + 2*_B5*arccos(_Z*b*_C2/a) - arccos(_Z*b*_C2/a))*a)*b, y(x) = x*(-cos(RootOf(tan(_Z)*_Z*b*_C2 - sin(-2*_B5*Pi + 2*Pi*_Z10 + 2*_B5*arccos(_Z*b*_C2/a) - arccos(_Z*b*_C2/a))*a)*b/x)*sin(-2*_B5*Pi + 2*Pi*_Z10 + 2*_B5*arccos(RootOf(tan(_Z)*_Z*b*_C2 - sin(-2*_B5*Pi + 2*Pi*_Z10 + 2*_B5*arccos(_Z*b*_C2/a) - arccos(_Z*b*_C2/a))*a)*b*_C2/a) - arccos(RootOf(tan(_Z)*_Z*b*_C2 - sin(-2*_B5*Pi + 2*Pi*_Z10 + 2*_B5*arccos(_Z*b*_C2/a) - arccos(_Z*b*_C2/a))*a)*b*_C2/a))*a/(RootOf(tan(_Z)*_Z*b*_C2 - sin(-2*_B5*Pi + 2*Pi*_Z10 + 2*_B5*arccos(_Z*b*_C2/a) - arccos(_Z*b*_C2/a))*a)*b) + sin(RootOf(tan(_Z)*_Z*b*_C2 - sin(-2*_B5*Pi + 2*Pi*_Z10 + 2*_B5*arccos(_Z*b*_C2/a) - arccos(_Z*b*_C2/a))*a)*b/x)*_C2)}

Does anyone know how to convert the above expression to radicals?
I'm grateful.
Oliveira
RootOf_to_radical.mw
 

In the DE solution below I cannot convert the RootOf function to radicals.

macro(solve = `@`(allvalues, solve))

_EnvExplicit := true

de := x^4*(diff(y(x), `$`(x, 2)))+omega^2*y(x) = 0

bc := y(a) = 0, y(b) = 0, (D(y))(a) = 1

dsol := `assuming`([dsolve({bc, de}, {omega, y(x)})], [a > 0, b > a])

convert(dsol, radical)

{omega = RootOf(tan(_Z)*_Z*b*_C2-sin(-2*_B5*Pi+2*Pi*_Z10+2*_B5*arccos(_Z*b*_C2/a)-arccos(_Z*b*_C2/a))*a)*b, y(x) = x*(-cos(RootOf(tan(_Z)*_Z*b*_C2-sin(-2*_B5*Pi+2*Pi*_Z10+2*_B5*arccos(_Z*b*_C2/a)-arccos(_Z*b*_C2/a))*a)*b/x)*sin(-2*_B5*Pi+2*Pi*_Z10+2*_B5*arccos(RootOf(tan(_Z)*_Z*b*_C2-sin(-2*_B5*Pi+2*Pi*_Z10+2*_B5*arccos(_Z*b*_C2/a)-arccos(_Z*b*_C2/a))*a)*b*_C2/a)-arccos(RootOf(tan(_Z)*_Z*b*_C2-sin(-2*_B5*Pi+2*Pi*_Z10+2*_B5*arccos(_Z*b*_C2/a)-arccos(_Z*b*_C2/a))*a)*b*_C2/a))*a/(RootOf(tan(_Z)*_Z*b*_C2-sin(-2*_B5*Pi+2*Pi*_Z10+2*_B5*arccos(_Z*b*_C2/a)-arccos(_Z*b*_C2/a))*a)*b)+sin(RootOf(tan(_Z)*_Z*b*_C2-sin(-2*_B5*Pi+2*Pi*_Z10+2*_B5*arccos(_Z*b*_C2/a)-arccos(_Z*b*_C2/a))*a)*b/x)*_C2)}

(1)

Does anyone know how to convert the above expression to radicals?
I'm grateful.

Oliveira


 

Download RootOf_to_radical.mw

 

I am playing around with certain "simple" integrals, and came across this strange behavior in Maple. Maple is able to integrate sin(x)^(1/2)*cos(x)^3, but not sin(x)^(1/3)*cos(x)^3. Any idea why?

trig_integral.mw
 

int(sin(x)^(1/2)*cos(x)^3, x)

-(2/7)*sin(x)^(7/2)+(2/3)*sin(x)^(3/2)

(1)

int(sin(x)^(1/3)*cos(x)^3, x)

int(sin(x)^(1/3)*cos(x)^3, x)

(2)

 

I am not able to understand why this ODE is quadrature. It is first order ODE of second degree. Solving for y'(x) gives two ODE's. Only one of these two ODE's is quadrature and the second is Abel.

So  why and how did odesdvisor come to conclusion that it is  quadrature? Did it pick the first ODE that comes from solving for y'(x)?

Note that from help, quadrature is ODE (for first order) is one which
the ODE is of first order and the right hand sides below depend only on x or y(x)

And the above definition only applied here for one of the 2 ODE's embeded inside this first order ODE of second degree. So I am just trying to understand the logic behind this result of odeadvisor

ode:= (x^2-a*y(x))*diff(y(x),x)^2-2*x*y(x)*diff(y(x),x) = 0;

(x^2-a*y(x))*(diff(y(x), x))^2-2*x*y(x)*(diff(y(x), x)) = 0

DEtools:-odeadvisor(ode);

[_quadrature]

odes:=[solve(ode,diff(y(x),x))]; #solve for y' we get 2 first order ODE's

[0, -2*x*y(x)/(a*y(x)-x^2)]

DEtools:-odeadvisor(diff(y(x),x)=odes[1]); #find type of first one

[_quadrature]

DEtools:-odeadvisor(diff(y(x),x)=odes[2]); #find type of second one

[[_homogeneous, `class G`], _rational, [_Abel, `2nd type`, `class A`]]


Download why_only_quadrature.mw

btw, the above is just one example. I have many more. below show one more such example

#example 2

ode:=diff(y(x),x)^3-(2*x+y(x)^2)*diff(y(x),x)^2+(x^2-y(x)^2+2*x*y(x)^2)*diff(y(x),x)-(x^2-y(x)^2)*y(x)^2 = 0;

(diff(y(x), x))^3-(2*x+y(x)^2)*(diff(y(x), x))^2+(x^2-y(x)^2+2*x*y(x)^2)*(diff(y(x), x))-(x^2-y(x)^2)*y(x)^2 = 0

DEtools:-odeadvisor(ode);

[_quadrature]

odes:=[solve(ode,diff(y(x),x))]; #solve for y' we get 3 first order ODE's

[y(x)^2, x+y(x), x-y(x)]

DEtools:-odeadvisor(diff(y(x),x)=odes[1]); #find type of first one

[_quadrature]

DEtools:-odeadvisor(diff(y(x),x)=odes[2]); #find type of second one

[[_linear, `class A`]]

DEtools:-odeadvisor(diff(y(x),x)=odes[3]); #find type of third one

[[_linear, `class A`]]

 

 

Download why_only_quadrature_2.mw

Maple 2019.1

 

I gave up. Spend 40 minutes trying everything and can't figure the right syntax. 

I need to use indets to obtain all occurrences of specific function in expression. Such as sin() or cos() or ln(), etc...

The indets commands has the form indets(expression, type).

But what is the type of ln ? It is of function type. But this picks up all other functions in the expression. I tried specfun and could not make it work. For example

expr:=x+sin(x)+ln(y)+10+ln(x+y)^2;

I want  to obtain  {ln(y),ln(x+y)^2}

I tried

indets(expr,function); 
indets(expr,specfun(ln));

and many more. Since indets needs a name of a type in the second argument, then what is the type name for ln or sin or cos, etc... I can't use indential, it did not work, since it is not a symbol I am looking for. I could use patmatch, but I am trying to learn indets for all these things.

Do I need to use subsindets for this? I still do not know how to use subsindets.

Maple 2019.1

hi i did this in maple and i get an error when i try to solve the system of equation  :

restart;
with(Student[VectorCalculus]);
with(PDEtools);with(plots);

h_f := 300;
h_a := 1000;
T_f := 1500 + 273;
T_a := 30 + 273;
k_r := 15;
k_s := 70;
Ra := 5;
Rf := 6.05;
Rc := 6;

Lap1 := Laplacian(T_r(r, theta), polar[r, theta]);
Lap2 := Laplacian(T_s(r, theta), polar[r, theta]);
Bc_r := k_r*eval(Gradient(T_r(r, theta), polar[r, theta])[1], r = 5) = h_a*(T_r(5, theta) - T_a);
Bc_s := k_s*eval(Gradient(T_s(r, theta), polar[r, theta])[1], r = 6.05) = h_f*(T_s(6.05, theta) - T_f);
systemThermal_r := Lap1 = 0;
systemThermal_s := Lap2 = 0;
Bc1_rs := eval(T_r(r, theta), r = 6) = eval(T_s(r, theta), r = 6);
Bc2_rs := k_r*eval(Gradient(T_r(r, theta), polar[r, theta])[1], r = 6) = -k_s*eval(Gradient(T_s(r, theta), polar[r, theta])[1], r = 6);
pdsolve([systemThermal_r, systemThermal_s, Bc_r, Bc_s, Bc1_rs, Bc2_rs]);
 
 
 
Error, (in PDEtools:-Library:-NormalizeBoundaryConditions) unable to isolate the functions {T_r(5, theta), T_r(6, theta), T_s(6, theta), T_s(6.05, theta), (D[1](T_r))(5, theta), (D[1](T_r))(6, theta), (D[1](T_s))(6, theta), (D[1](T_s))(6.05, theta)} in the given boundary conditions {15*(D[1](T_r))(5, theta) = 1000*T_r(5, theta)-303000, 15*(D[1](T_r))(6, theta) = -70*(D[1](T_s))(6, theta), 70*(D[1](T_s))(6.05, theta) = 300*T_s(6.05, theta)-531900, T_r(6, theta) = T_s(6, theta)}
 
 

I like using Record in Maple. It allows me to collect related variables to pass around inside one object. (Like with Pascal or Ada records or C struct).

But I find myself copying the record definition over and over everywhere I want to use the same specific record layout.

Is there a way to define specific record layout somewhere, may be as a type and give it a name, and then in each proc I want to make a variable of this record type, just tell Maple that this variable is a record of that type so I do not have to explicity define the record there each time? 

Here is a simple example to make it more clear

foo:=proc() #some proc that uses same Record layout
   local S;
   S:=Record('name','age');   
   S:-name:="joe doe 1";
   S:-age:=99;
   return S;
end proc:

boo:=proc() #another proc that wants to use same Record layout
   local S;
   S:=Record('name','age');   
   S:-name:="joe doe 2";
   S:-age:=80;
   return S;
end proc:

S1:=foo();
S2:=boo();

These proc's can be anywhere, such as inside package or module, either local or exported.

I just want to avoid having to type   S:=Record('name','age');   Each time. I want to tell Maple that a local variable is of this specific Record layout, without having to type the layout explicitly.

This way, when I add new field to this Record,  I just have to do it in one place and not in 10 places in the code. 

I think I need to add a new type? But do not know how to do this.  I hope the question is clear. If not, will add more information.

 

Hello everyone

I have the solution of diffusion equation from Help of maple website. I put the code here

*****************************

restart: with(plots):
 

unprotect(D);
 

alias(c[0]=c0, c[1]=c1, c[2]=c2);
PDE:=diff(C(x,t),t)=D*diff(C(x,t),x,x);
IBC:={C(x,0)=cx0, C(0,t)=ct0, D[1](C)(10,t)=0};
ct0:=1;
cx0:=0;
D:=1;
pds:=pdsolve(PDE,IBC,numeric);
L1:=[0.01, 0.1, 1, 5, 10];
L2:=[red, green, yellow, blue, magenta, black];
for i from 1 to 5 do
 pn[i] := pds:-plot(t=L1[i], color=L2[i]):
end do:
display({seq(pn[i], i=1..5)}, title=`Numerical solution at t=0.01, 0.1, 1, 5, 10`);

****************************

 

the code is working perfectly. But, My question is how can I found the diffusion constant (D) if I have the solution ( C(x,t) ).  Probably it should be an algorithm which use least square method to find (D) based on the data C(x,t).

I am looking for a fast and efficient algorithm if there is any.

thank you so much for your kind attentions in advance

Sincerely yours,

Amir

This ODE turns out to be a simple separable ODE. With one solution, if the ODE is rewritten.

But in its original form, Maple dsolve gives 6 complicated looking solutions with complex numbers in some of them. Even though all 6 solutions are valid.

Any one knows why Maple did that and not give the one simple solution instead? 

I used isolate to solve for y' from the original ODE. Verfiied that only one solution exist.  The ODE then became y'(x)= 3*y(x)/(2*x). Which by uniqueness theorem, should have one unique solution in some region in the RHS or in some region in the LHS that does not inculde x=0 ?

Just wondering what is going on, and why Maple did not give same simpler solution, so I can learn something new. That is all.

restart;

Typesetting:-Settings(typesetprime=true):

ode:= 1/2*(2*x^(5/2)-3*y(x)^(5/3))/x^(5/2)/y(x)^(2/3)+1/3*(-2*x^(5/2)+3*y(x)^(5/3))*diff(y(x),x)/x^(3/2)/y(x)^(5/3) = 0;

(1/2)*(2*x^(5/2)-3*y(x)^(5/3))/(x^(5/2)*y(x)^(2/3))+(1/3)*(-2*x^(5/2)+3*y(x)^(5/3))*(diff(y(x), x))/(x^(3/2)*y(x)^(5/3)) = 0

DEtools:-odeadvisor(ode);

[[_1st_order, _with_linear_symmetries], _exact, _rational]

maple_sol:=dsolve(ode);

y(x) = (1/3)*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*(-(1/4)*5^(1/2)-1/4-((1/4)*I)*2^(1/2)*(5-5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*(-(1/4)*5^(1/2)-1/4+((1/4)*I)*2^(1/2)*(5-5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*((1/4)*5^(1/2)-1/4-((1/4)*I)*2^(1/2)*(5+5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*((1/4)*5^(1/2)-1/4+((1/4)*I)*2^(1/2)*(5+5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), x/y(x)^(2/3)+y(x)/x^(3/2)+_C1 = 0

map(x->odetest(x,ode),[maple_sol])

[0, 0, 0, 0, 0, 0]

solve(ode,diff(y(x),x),AllSolutions)

(3/2)*y(x)/x

ode2:=isolate(ode,diff(y(x),x)); #solve for y' first

diff(y(x), x) = -(3/2)*(2*x^(5/2)-3*y(x)^(5/3))*y(x)/(x*(-2*x^(5/2)+3*y(x)^(5/3)))

ode2:=simplify(ode2)

diff(y(x), x) = (3/2)*y(x)/x

DEtools:-odeadvisor(ode2);

[_separable]

sol:=dsolve(ode2)

y(x) = _C1*x^(3/2)

odetest(sol,ode2)

0

 

Download strange_ode_answer.mw

Maple 2019.1

Physics 395

Hi, I am trying to plot the phase potrait for this as follow:

s0 := 3*10^5;
d := 10^(-3);
delta := 10^4;
b := 5*10^6;
lamda := 4.16;

DEplot([diff(I(t), t) = s0 + I(t)*(-d - delta*Q(t)/(b + Q(t))), diff(Q(t), t) = -lamda*Q(t)], [I(t), Q(t)], t = 0 .. 10, I = 0 .. 100, 0, Q = 0 .. 100, 0, dirfield = 400, arrows = smalltwo, number = 2, [[0, 4, 0.1], [0, 0.2, 4.1], [0, 7, 0.2], [0, 0.2, 7]], color = red, linecolor = blue, numsteps = 100)

 

But, there is an error saying "Error, (in DEtools/DEplot) vars must be declared as a list, e.g. [x(t),y(t),...]". However, I did the same for other problem and worked well tho. I have no idea what the problem is for above.

When I apply the uses function with the Physics package in a procedure, the commands in this package are not restricted to the inside of the procedure, but are applied globally. See the example below:

gds := proc(LL, qi, t)

 local ta,i;  

uses Physics;

ta := sec(diff(diff(LL, diff(qi[i](t), t)), t), i = 1 .. nops(qi));

RETURN(ta) end:

sxy := diff(x(t), t)^2 + diff(y(t), t)^2:

gds(sxy, [x, y], t);

Error, (in Physics:-diff) name expected for external function
 

On the other hand, when I apply the uses function with the LinearAlgebra package in a procedure, the commands in this package are restricted to the inside of the procedure only.
dst:=proc(MM) 

local DA; 

uses LinearAlgebra;

DA:=Determinant(MM); 

RETURN(DA) end:

dst(<<1 | 2>, <3 | 4>>);

                  -2

Determinant(<<1 | 2>, <3 | 4>>);

                         Determinant(Matrix(2, 2, [[1, 2], [3, 4]]))

This could be a bug in Maple 2019?

The following differential equation:

sy := (dsolve({T*diff(y(x), x, x) + rho*omega^2*y(x) = 0, y(0) = 0, y(L) = 0}, y(x)) assuming (0 < T, 0 < omega, 0 < rho))

                                                                 sy:=y(x)=0

Maple only returns the trivial solution. Should return other expressions:
Thank you

First 8 9 10 11 12 13 14 Last Page 10 of 18