Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

This behavior is very old. Most likely goes back to the introduction of add and seq.

At least it exists in Maple 8 too. I remember noticing it years ago.

PS. I just cranked up an old computer with Maple V, Release 4.

The behavior is still an assignment to x[4]. The value assigned is, however, not 10 but 11.

That old computer also has Maple 6. That behaves as Maple 8, i.e. the assigned value is 10.

 

One reason might be that it has not been seen as important enough to merit attention; and I would agree.

You should provide a link to the worksheet.

I tried to copy what you posted. I had to terminate Maple with Ctrl+Delete.

@Sradharam If you insist on a symbolic solution of your ode in f alone, then you are out of luck.

If you want anything out of that equation you must use an approximate method of some kind.
The way I solved the full system with dsolve/numeric works just as well with your ode in f only.

So if you have no interest in g just use:

restart;
ode:=diff(diff(diff(f(x), x), x), x) = 1/2*(-2*diff(f(x), x)*c^2*t^2 - 6*diff(diff(f(x), x), x)*exp(c*x)*c^2*t - 6*diff(f(x), x)*f(x)*t^2 + diff(f(x), x)*t^2)/(exp(c*x)^2*c^2);
res:=dsolve({ode,f(0)=f0,D(f)(0)=f1,(D@@2)(f)(0)=f2},numeric,parameters=[c,t,f0,f1,f2],output=listprocedure);
#Setting parameters (an example):
res(parameters=[1,2,0.5,0.6,0]);

plots:-odeplot(res,[x,f(x)],-1..10);

## Here is a procedure that can be used by animate:
Q:=proc(c,t,f0,f1,f2,scene::list:=[x,f(x)],x_interval::range:=-1..10) 
   if not [c,t,f0,f1,f2]::list(realcons) then return 'procname(_passed)' end if;
   res(parameters=[c,t,f0,f1,f2]);
   plots:-odeplot(res,scene,x_interval,_rest)
end proc;

## Examples of use all with c, t, f1, f2 fixed
plots:-animate(Q,[1,2,f0,0.6,0.1,0..20],f0=-1..1,trace=24); 
plots:-animate(Q,[1,2,f0,0.6,0.1,[f(x),diff(f(x),x)],0..30],f0=-1..1);
plots:-animate(Q,[1,2,f0,0.6,0.1,[seq([x,diff(f(x),[x$k])],k=0..2)],-0.3..5],f0=0..5);

You can set c, t, f0, f1, f2 to any concrete value you like, but you won't get a formula in the usual sense for the solution.
PS. You may not be as interested in graphs or animations as I am.

If you only want numbers you can simply do this:
 

res(parameters=[1,2,0.5,0.6,0]);
F,F1,F2:=op(subs(res,[seq(diff(f(x),[x$k]),k=0..2)]));
X:=Vector([seq(i*0.5,i=-1..10)]);
# Values of f:
F~(X);
# Values of f'
F1~(X);
# Values of x, f, f', f'':
M:=<X|F~(X)|F1~(X)|F2~(X)>;
RES:=Matrix(2,1,{(1,1)=Array([x,f(x),diff(f(x),x),diff(f(x),x,x)]),(2,1)=M});
plots:-odeplot(RES); # even this you can plot with odeplot

Notice that I have changed the default output from dsolve/numeric to output=listprocedure.

@Carl Love Yes, Tom Leslie guesses right.

Since I use animations rather often I was surprised that that toolbar wasn't there when I clicked on the plot at the end.

 

P.S. On a new laptop acquired today (05/05/2021) I installed Maple 2021. No problem.

@Preben Alsholm The animation was produced in Maple 2020.

For some reason it doesn't work in Maple 2021.

I shall submit an SCR (a bug report).

PS. It works in your version Maple 17.

@acer How do you explain that f() + f() - f() + f(); returns 2*x?

@mmcdara Vectors are not accepted as input in dsolve in versions prior to Maple 18.
In versions before Maple 2018 diff wouldn't work on vectors unless you use the elementwise version diff~.

@tomleslie I use Windows 10 Home.

I didn't find any problem in my current version (beta) which is a week older than your version. I set the frame rate (FPS) at 3.

@Joe Riel

If RHERWOLF uses Maple 15 as he states and also uses Windows then he would find that
savelibname := "/home/maple/lib";
which doesn't seem to make any sense on a Windows computer.

@Johan159 When you use plot or plot3d on a function f your range(s) must be given as just ranges, not equations.
If your first argument is f(x,y) then you must use equations.
See the help for plot and plot3d.
 

f:= (x,y)-> 2*x^2 + 5*y^3 + 5;
plot3d(f,0..10,0..5);
plot3d(f(x,y),x=0..10,y=0..5);


Another thing to keep in mind: A function (like your f) evaluates just to a name.
If you write f; and press enter, you just get f (literally).
If you want to see its definition as a procedure do eval(f); (enter).

@Kitonum The numbers 5 and 6 should be either 5 and 5 or 6 and 6.
Take the general case:
 

convert(series(f(x),x=0, 6), polynom)+(D@@6)(f)(xi)*x^6/6!;

 

@tomleslie What you are comparing is not only a potential cputime/realtime/memory difference due to the different output types of dsolve, but you are comparing the effect of using plot and odeplot:
These tests show not much of a difference:
 

restart;
sys:= { diff(x(t),t,t) = -2*lambda(t)*x(t),
         diff(y(t),t,t) = -2*lambda(t)*y(t)-Pi^2,
         x(t)^2+y(t)^2 = 1,
         x(0)=0, D(x)(0)=1/10, y(0)=-1, D(y)(0)=0
       }:
dsol1 := dsolve(sys, numeric):

CodeTools:-Usage(plots:-odeplot(dsol1, [[t, x(t)],[t, y(t)],[t, lambda(t)]], t=0..10)):

# memory used=1.20MiB, alloc change=0 bytes, cpu time=31.00ms, real time=33.00ms, gc time=0ns
#######################################################
restart;
sys:= { diff(x(t),t,t) = -2*lambda(t)*x(t),
         diff(y(t),t,t) = -2*lambda(t)*y(t)-Pi^2,
         x(t)^2+y(t)^2 = 1,
         x(0)=0, D(x)(0)=1/10, y(0)=-1, D(y)(0)=0
       }:


dsol2 := dsolve(sys, numeric, output=listprocedure):
xf:=eval(x(t), dsol2):
yf:=eval(y(t), dsol2):
lf:=eval(lambda(t), dsol2 ):

CodeTools:-Usage( plots:-odeplot(dsol2, [[t, x(t)],[t, y(t)],[t, lambda(t)]], t=0..10)):
# memory used=1.20MiB, alloc change=0 bytes, cpu time=32.00ms, real time=40.00ms, gc time=0ns

The following test shows a substantial difference:
 

restart;
sys:= { diff(x(t),t,t) = -2*lambda(t)*x(t),
         diff(y(t),t,t) = -2*lambda(t)*y(t)-Pi^2,
         x(t)^2+y(t)^2 = 1,
         x(0)=0, D(x)(0)=1/10, y(0)=-1, D(y)(0)=0
       }:
dsol1 := dsolve(sys, numeric):

CodeTools:-Usage([for i from 1 to 10^5 do dsol1(10^(-4)*i) end do]):
# memory used=0.77GiB, alloc change=288.01MiB, cpu time=8.75s, real time=7.32s, gc time=3.17s
#######################################################
restart;
sys:= { diff(x(t),t,t) = -2*lambda(t)*x(t),
         diff(y(t),t,t) = -2*lambda(t)*y(t)-Pi^2,
         x(t)^2+y(t)^2 = 1,
         x(0)=0, D(x)(0)=1/10, y(0)=-1, D(y)(0)=0
       }:


dsol2 := dsolve(sys, numeric, output=listprocedure):
xf:=eval(x(t), dsol2):
yf:=eval(y(t), dsol2):
lf:=eval(lambda(t), dsol2 ):

CodeTools:-Usage([for i from 1 to 10^5 do dsol2(10^(-4)*i) end do]):
# memory used=4.22GiB, alloc change=0.68GiB, cpu time=44.09s, real time=37.64s, gc time=11.70s

 

@Kitonum What you get with your code is not always positive:
 

T1 := remove(t -> is(op(1, t) = -1), [T]);
eval(T1,{R=1/6,ZETA=1});
evalf(%);

An illustration:
 

plots:-animate(plots:-complexplot,[T1,R=0..1,thickness=3,color=[red,blue],style=point,symbolsize=20],ZETA=-1..1);

First 6 7 8 9 10 11 12 Last Page 8 of 215