Preben Alsholm

MaplePrimes Activity


These are answers submitted by Preben Alsholm

For the 2 matrices (or more) you can just use <... , ... > in this way:
 

A:=LinearAlgebra:-RandomMatrix(3,2);
B:=LinearAlgebra:-RandomMatrix(4,2);
C:=LinearAlgebra:-RandomMatrix(2,2);
M:=<A,B>;
M1:=<A,B,C>;
M2:=<M,C>;
M1-M2;

 

This works:
 

restart;

expr:=x*A[2]+A[1];
select(type,expr,identical(x) &* anything);
select(type,expr,identical(x^2) &* anything);

See ? type, structured

Using simple shooting shows that there can be several solutions.

I take here the example where k = 1.5, alpha = 2, and infinity = 10.
In this case we find 3 solutions, 2 of which may be considered unphysical or maybe rather not corresponding properly to an acceptance of infinity = 10.

restart;
odeSys := f(xi)+3*diff(g(xi), xi)-xi*diff(f(xi),xi)=0,
            f(xi)^2+3*g(xi)*diff(f(xi),xi)-xi*f(xi)*diff(f(xi),xi)=3*diff(f(xi),xi,xi)+18*k*diff(f(xi),xi)^2*diff(f(xi),xi,xi);
  bcs := f(0)=alpha, f(infinity)=0, g(0)=0;
inf:=10;
respar:=dsolve(eval({odeSys,f(0)=alpha,g(0)=0,D(f)(0)=f1},{alpha=2,k=1.5}),numeric,parameters=[f1],output=listprocedure);
F:=subs(respar,f(xi));
Q:=proc(f1) if not f1::realcons then return 'procname(_passed)' end if;
   respar(parameters=[f1]);
   F(inf)
end proc;
plot(Q(f1),f1=-2..0);
f1val1:=fsolve(Q,-1.8..-1.6);
f1val2:=fsolve(Q,-1..-0.98);
f1val3:=fsolve(Q,-0.95..-0.9);
f1vals:=[f1val1,f1val2,f1val3];
for i from 1 to numelems(f1vals) do
  Q(f1vals[i]);
  p[i]:=plots:-odeplot(respar,[xi,f(xi)],0..inf,caption=typeset(D(f)(0)=f1vals[i]))
end do:
plots:-display(seq(p[i],i=1..numelems(f1vals)),insequence);
plots:-display(seq(p[i],i=1..numelems(f1vals)),caption=typeset(D(f)(0)=f1vals));

Notice that Q sets the parameter f1 each time it is called.
The the 3 solutions in an animation:

 

Comment.
Making the procedure Q have 2 arguments, f1 and inf (now unassigned, was 10) and trying much higher values of inf (e.g. 100) shows that 3 solutions of Q = 0 remain. They are all negative. Also it appears that the smallest in absolute value is roughly the same for all values of inf. The middle one moves ever closer to the first while the absolute value of the third root becomes rather large.
Values for inf=100:  -363.8130077, -0.9332179835, -0.9272464476.

My guess is that as inf -> infinity the 3rd root tends to -infinity and the first and second root becomes a double root. Thus we are left with one root.

I tried your worksheet in Maple 18, Maple 2020.2, and in Maple 2021.1.

The double loop over i and j got stuck in Maple 2020.2, but not in the other two.

Already the computation of evalf(int(r*h0[i]*g[j], r = 0 .. 1)) gets stuck for i = j = 1.
Try this version instead:
 

for i to n do
    for j to n do h[j][i] := int(r*h0[i]*g[j], r = 0 .. 1,numeric,method=_d01ajc)/int(r*(-r^2 + 1)*g[j]^2, r = 0 .. 1,numeric,method=_d01ajc); end do;
end do;

The use of method=_d01ajc makes the computation real fast.

Try this:
 

expr:=piecewise(x(t)<0, -1, x(t)<1, 0, 1) + f(t) + piecewise(t<0, 0, t<1, 1, 0) + x(t)*piecewise(t<0, 1, t<1, 0, 1) + a*piecewise(t<0, 3, t<1, -1, 2);
####
select(hastype,expr,specfunc(piecewise));
select(hastype,%,And(relation,satisfies(r->lhs(r)=t)));

 

Trying this:

plot(w->int(eval(A1+A2,omega=w),theta=0..2*Pi,numeric,digits=5),0..50);

I got

You won't be able to find a symbolic solution. You must solve numerically.

Thus you must give values to the parameters c and t.
You must also give boundary or intial values.

I'm assuming that by e^() you mean the exponential function, which in Maple is exp. So I have made that replacement.
Here is an example of solving the initial value problem.

restart;
sys := -diff(g(x), x)*exp(c*x)*c/(3*t) + f(x) = 0, t*(c*exp(2*c*x)*diff(g(x), x) + t*exp(c*x)*(2*c^2 + 3*f(x) - 1))*diff(f(x), x) + 6*c^2*(diff(f(x), x, x)*t*exp(2*c*x) + diff(f(x), x, x, x)*exp(3*c*x)/3) = 0;
sol:=dsolve({sys}); # essentially unsolved, but work has been done
dsolve(sol[1]); # returns NULL i.e. nothing
#Solving the original system numerically:
res:=dsolve({sys,f(0)=f0,D(f)(0)=f1,(D@@2)(f)(0)=f2,g(0)=g0},numeric,parameters=[c,t,f0,f1,f2,g0]);
#Setting parameters (an example):
res(parameters=[1,2,0.5,0.6,0,0]);
plots:-odeplot(res,[[x,f(x)],[x,g(x)]],-1..10);
## Here is a procedure that can be used by animate:
Q:=proc(c,t,f0,f1,f2,g0,scene::list:=[[x,f(x)],[x,g(x)]],x_interval::range:=-1..10) 
   if not [c,t,f0,f1,f2,g0]::list(realcons) then return 'procname(_passed)' end if;
   res(parameters=[c,t,f0,f1,f2,g0]);
   plots:-odeplot(res,scene,x_interval,_rest)
end proc;
## Examples of use all with c, t, f1, f2, g0 fixed
plots:-animate(Q,[1,2,f0,0.6,0.1,-.3,0..20],f0=-1..1,trace=24); 
plots:-animate(Q,[1,2,f0,0.6,0.1,-0.3,[f(x),diff(f(x),x)],0..30],f0=-1..1);
plots:-animate(Q,[1,2,f0,0.6,0.1,-0.3,[seq([x,diff(f(x),[x$k])],k=0..2)],-0.3..5],f0=0..5);

In the worksheet attached I end up displaying all the separatrices in sequence producing the animation below.
MaplePrimes21-05-05_separatrices.mw

Since the problem is formulated in vector form the Maple solution should be given as such, I think.
Even Maple 2021 doesn't quite do that.
Here is the closest I got:
 

restart;
X:=<x1(t),x2(t)>;
Sys:=diff(X,t)=<-4,-2;6,3>.X+<2/(exp(t)+1),-3/(exp(t)+1)>; 
ics:=eval(X,t=0) = <0,ln(2)>;
 
sol1:= dsolve([ Sys, ics]); # Not on vector form
sol:=X=eval(X,sol1); # Now on vector form

The solution looks like this:

You have a classical Volterra-Lotka system.
All solutions are periodic. The orbits in phase space are closed.
Use odeplot with a numerical solution as done here.
 

restart;
sys := diff(x1(t), t) = 3*x1(t) - 2/1000*x1(t)*x2(t), diff(x2(t), t) = 6/10000*x1(t)*x2(t) - 1/2*x2(t);
ics := x1(0) = 1000, x2(0) = 500;
res:=dsolve({sys,ics},numeric);
plots:-odeplot(res,[[t,x1(t)],[t,x2(t)]],0..15,legend=[x1,x2],size=[1000,500]);
plots:-odeplot(res,[x1(t),x2(t)],0..7,frames=100);

The last is an animation of the orbit in phse space and is seen below.

I don't have Maple 13, but I have Maple 12. It gives the same error.
The error is NOT related to the way you produce the subscript, which is seen by this code:
 

restart;
H1:=v*P[r]-((1-P[r]^2*r/(P[r]^2*r-1))/r)^(1/2);
simplify(H1); ## Error in Maple 12
normal(H1);   ## OK
radnormal(H1);         ## Same error
simplify(H1,symbolic); ## Same error

The error is also present in Maple 15, 16, 17, 18, and 2015, but not in Maple 2016.

@nm For one session you can can keep the order once determined by giving LinearAlgebra:-Eigenvectors option remember or maybe option remember,system:
 

LA_EV:=subsop(3=(remember,system),eval(LinearAlgebra:-Eigenvectors)):

So you could compare the outputs of LA_EV and LinearAlgebraEigenvectors like this:
 

restart;
Sy:=1/sqrt(2)*Matrix([[0,-I,0],[I,0,-I],[0,I,0]]);
LA_EV:=subsop(3=(remember,system),eval(LinearAlgebra:-Eigenvectors)):
to 5 do LA_EV(Sy) end do;
to 5 do LinearAlgebra:-Eigenvectors(Sy) end do;

This only assures that if you happen to execute another time the previous result will be returned.
Between sessions this is no solution. You must sort.
 

Replace expand by solve or fsolve.
Here I use fsolve. Notice that all 3 roots are real (as it happens):
 

restart;
A1 := x^3 + n - 81*x - 6 = 0;
for n to 11 do
    fsolve(A1)
end do;

 

Since Z is taking values in the complex plane and E is therefore also, you would need a 4D coordinate system to illustrate E's dendence on Z. Maple uses color as the fourth dimension in complexplot3d. Take a look at the help page.

rho := 1/4; mu := 1/4; E := add(Z^k/GAMMA(k*rho+mu), k = 0 .. 5);
plots:-complexplot3d(E,Z=-5-5*I..5+5*I);

You simply need to give epsilon a numeric value. Then your code runs.
epsilon is present in exz, which is going to be printed.

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