nm

12108 Reputation

20 Badges

13 years, 222 days

MaplePrimes Activity


These are answers submitted by nm

 

sys_ode := diff(F0(zeta), zeta, zeta)-b^2*F0(zeta)+G0(zeta)^2 = 0, diff(G0(zeta), zeta, zeta)-b^2*G0(zeta) = 0, 2*F0(zeta)+diff(H0(zeta), zeta) = 0;

ics := F0(0) = 0, G0(0) = 1, H0(0) = 0, F0(infinity) = 0, G0(infinity) = 0;

sol:= dsolve([sys_ode,ics])

 

simplify(sol) assuming positive

you can eliminate  the remove has calls by doing

map(x->ListTools:-SearchAll(x,L1),L2)

do not know if this will speed it up much or not.

Another apprach to the fine answers given already is to use: (can't write Latex in the form, so I put screen shot)

Using Maple

g:=x->cos(x);
limit(1/abs(g(x)),x=0)+limit(1/abs(g(x)),x=-Pi)+limit(1/abs(g(x)),x=Pi)

    3

 

 But the lecturer's solution was non-imaginary.

 

restart;
ode := x^2*diff(z(x), x, x) + (1 + gamma + beta)*x*diff(z(x), x) + gamma*beta*z(x) - cos(ln(x)):
sol:=(dsolve({ode, z(1) = 1, D(z)(1) = -1}) assuming (gamma <> beta));

simplify(evalc(sol)) assuming x>0

You get same out using

remove(`=`,op~(0,indets(x)),symbol)

{f, g, h}

It works since op(0,f(x))  gives f  while op(0,f) gives symbol

there might be a better way to do ofcourse, but this is how I see it so far. But there should be a more robust way to do this using type(....,'function')

May be something like

restart;
x := -h(U) + f( f( g( f(U+W*X)*V) + g( f(W)*g(V) ) ) ):
foo:=x-> if type(x,'function') then return(op(0,x)) fi;
convert(foo~(convert(indets(x),list)),set)

{f, g, h}

 

In Section 14.5 - External Calling ..., page 489

 

I do not use Maple on Linux. But you have one ". You need two of these, one of each side. 

Here is the example from book. Try and see if this fixes it.

 

 

 


expr:=latex('int(1/(x^2+2),x=2..3)')
\int_{2}^{3}\! \left( {x}^{2}+2 \right) ^{-1}\,{\rm d}x

compiles to

 

And you can do things like this


expr:="int(1/(x^2+2),x=2..3)";
result:=cat(latex(parse(expr),output=string)," = ",latex(eval(parse(expr)),output=string));

Which gives latex which compiles to

 

It is not a bug, Isn't this known and due to when evalation and binding names to value happen? When you type f:=(x,y)->eq2 notice that Maple did not replace eq2 with its value y = 10 - 5*x at the time the function is defined.

When you called the function next, maple did not replace the x,y since eq2 was still name. Next, it evaluates eq2 and returns it value which is y = 10 - 5*x but by then it is too late. 

I think this is why unapply was invented.

but to do what you want, you could always write

          f:=(x0,y0)->eval(eq2,[x=x0,y=y0])

And now f(3,1) returns 1 = -5

 

ofcourse Maple can open a CDF file. Any software can open a CDF file, after all, it is just plain text file and not a binary file. Same for Mathematica notebooks. They are all plain text files.

Here is start of one such CDF file

 

(* Content-type: application/vnd.wolfram.cdf.text *)

(*** Wolfram CDF File ***)
(* http://www.wolfram.com/cdf *)

(* CreatedBy='Mathematica 12.1' *)

Now, the question is what you meant to ask is, can Maple run a CDF?  The answer is No. Only WRI software can run CDF files. You need either Mathematica itself or the Wolfram player installed to run a CDF file.

This is becuase it needs the Wolfram kernel software to run it. Just like one needs Maple kernel to Maple worksheet. No difference.

 

I am going to assume you meant fixed length string and u(0,t)=0=u(0,1) is a typo and you meant  u(0,t)=0=u(1,t)

restart;
pde := diff(u(x,t),t$2)=c^2*diff(u(x,t),x$2);
bc  := u(0,t)=0,u(L,t)=0;
ic  := u(x,0)=f(x),D[2](u)(x,0)=g(x);
sol:=pdsolve([pde, ic, bc],u(x,t)) assuming L>0;

To do animation, we need to put specific values. For example

L:=1;
c:=2;
g:=0;
f:=(8*x*(L-x)^2)/L^3;
pde := diff(u(x,t),t$2)=c^2*diff(u(x,t),x$2);
bc  := u(0,t)=0,u(L,t)=0;
ic  := u(x,0)=f,D[2](u)(x,0)=g;
sol:=pdsolve([pde, ic, bc],u(x,t));
sol:=subs(infinity=15,sol); #should be good enough

 

Another example

 

restart;
c:=2;
pde := diff(u(x,t),t$2)=c^2*diff(u(x,t),x$2);
bc  := u(-Pi,t)=0,u(Pi,t)=0;
ic  := u(x,0)=0,D[2](u)(x,0)=sin(x)^2;
sol:=pdsolve([pde, ic, bc],u(x,t));
sol:=subs(infinity=20,sol);

If you search the internet, there are hundreds of such examples out there. 

 

restart;
pde  := diff(u(x,t),t$2)= diff(u(x,t),x$2);
f    := x->piecewise(-1/2<x and x<1/2,5*cos(Pi*x),true,0);
ic   := u(x,0)=x, D[2](u)(x,0)=f(x);
sol  := pdsolve([pde,ic],u(x,t));
plots:-animate(plot, [rhs(sol),x=-6..6],t=0..10);

 

update

Thanks to the hint by Carl below, I can now save animation to gif file. Made a new one by making small change to the initial conditions given above just to make the wave motion a little bit more interesting looking. I am surprised how fast Maple saved the animation gif file to disk. This is good.

restart;
pde :=  diff(u(x,t),t$2)= diff(u(x,t),x$2);
f   :=  x->piecewise(-1/2<x and x<1/2,10*cos(Pi*x),true,0);
ic  :=  u(x,0)=f(x), D[2](u)(x,0)=0;
sol := pdsolve([pde,ic],u(x,t));

plots:-animate(plot, [rhs(sol),x=-10..10],t=0..10,frames=100);

restart;
PDE := diff(u(x, t), t) - VectorCalculus:-Laplacian(u(x, t), [x]) - u(x, t) + x - 2*sin(2*x)*cos(x) = 0;
IBC := D[1](u)(Pi/2, t) = 1, u(0, t) = 0, u(x, 0) = x;
pdsolve(eval(PDE), {IBC}, type = numeric);

 

Works OK on Maple 2020. 

 

Or you can try analytical solution

restart;
PDE := diff(u(x, t), t) - VectorCalculus:-Laplacian(u(x, t), [x]) - u(x, t) + x - 2*sin(2*x)*cos(x) = 0;
IBC := D[1](u)(Pi/2, t) = 1, u(0, t) = 0, u(x, 0) = x;
pdsolve([PDE,IBC]);

 

Both work. No error. Attached worksheet.


 

 

restart;
PDE := diff(u(x, t), t) - VectorCalculus:-Laplacian(u(x, t), [x]) - u(x, t) + x - 2*sin(2*x)*cos(x) = 0;
IBC := D[1](u)(Pi/2, t) = 1, u(0, t) = 0, u(x, 0) = x;
pdsolve([PDE,IBC]);

diff(u(x, t), t)-(diff(diff(u(x, t), x), x))-u(x, t)+x-2*sin(2*x)*cos(x) = 0

(D[1](u))((1/2)*Pi, t) = 1, u(0, t) = 0, u(x, 0) = x

u(x, t) = (1/8)*(-exp(-8*t)+1)*sin(3*x)+sin(x)*t+x

restart;
PDE := diff(u(x, t), t) - VectorCalculus:-Laplacian(u(x, t), [x]) - u(x, t) + x - 2*sin(2*x)*cos(x) = 0;
IBC := D[1](u)(Pi/2, t) = 1, u(0, t) = 0, u(x, 0) = x;
sol:=pdsolve(eval(PDE), {IBC}, type = numeric);

diff(u(x, t), t)-(diff(diff(u(x, t), x), x))-u(x, t)+x-2*sin(2*x)*cos(x) = 0

(D[1](u))((1/2)*Pi, t) = 1, u(0, t) = 0, u(x, 0) = x

_m3030174367552

sol:-plot(t=0,numpoints=50)

sol:-plot3d(t=0..1,x=0..5)

 


 

Download maple_sheet.mw

Removed as not needed.

L1:=[1,2,5,6,9];
andmap( x->x>0, L1 );

         true

L2:=[0,-2,5,6,9]:
andmap( x->x>0, L2 );

       false

You can't really expect to translate such code to Maple. Using MmaTranslator or any other tool.

MmaTranslator is meant to translate mathematics from Mathematica syntax to Maple syntax. It also  supports few core Mathematica commands such as Table, If, Do, etc...

So only common mathematical functions and basic constructs that have Maple equivalent can be translated. 

But Manipulate can't be translated to Maple. What do expect Maple to translate Manipulate to?  

Let try it. Here is a full Manipulate program

with(MmaTranslator)
FromMma(`Manipulate[Plot[Sin[c x],{x,-1,1}], {{c,1,"c"},0,2,.1}]`)

Maple returns

Manipulate(plot(sin(c*x), x = -1 .. 1), [[c, 1, "c"], 0, 2, 0.1])

Good luck running the above in Maple.

There are thousands of Mathematica commands that can't be expected to be translated. For example

FromMma(`Graphics3D[Sphere[{0, 0, 0}]]`)

Will just give

Graphics3D(Sphere([0, 0, 0]))

You can't run the above in Maple.

You could translated a Table command for example

FromMma(`Table[i,{10}]`)

Which gives

[seq(i, i = 1 .. 10)]

To translate all of Mathematica commands and functions to Maple means that Maple will have to reimplement all of Mathematica functions inside it (those that have no direct corresponding in Maple ). May be this will take 20 millions or so lines of code to do. Which is not realistic.

 

 

First 13 14 15 16 17 18 19 Page 15 of 20