Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@iman I shall elaborate on the simple example I gave above:

restart;
ode:=diff(y(x),x)=1/y(x);
dsolve(ode); #General solution
dsolve({ode,y(0)=0}); #Two solutions: i.e. lack of uniqueness.
## Trying numerically:
res:=dsolve({ode,y(0)=0},numeric);
plots:-odeplot(res,[x,y(x)],0..1); #NO LUCK (no surprise either)
#Now trying a midpoint method:
res2:=dsolve({ode,y(0)=0},numeric,range=0..1,method=bvp[midrich]); #NO LUCK
##Trying to find the parameter a so that the solution with y(1)=a satisfies y(0)=0:
res3:=dsolve({ode,y(1)=a},numeric,parameters=[a],output=listprocedure);
Y:=subs(res3,y(x));
res3(parameters=[sqrt(2)]); #According to results above a=sqrt(2) should work: CHEATING!
plots:-odeplot(res3,[x,y(x)],0..1); #Indeed it looks good.
##Now try to find a without cheating, i.e. without knowing an exact solution:
Q:=proc(a) res3(parameters=[a]); Y(0) end proc;
Q(1.4); #Error
Q(1.42); #OK
##We modify Q such that it returns -10 when an error in Y(0) occurs:
Q:=proc(a) res3(parameters=[a]);
  try
    Y(0)
  catch:  
    -10
  end try
end proc;
##This version of Q works with fsolve and fsolve finds the correct parameter:
fsolve(Q,[1..2]);
#############
The lesson to learn is that although a singularity is present in your ode with y(0)=0, there may still be a solution (here two), but it may require some extra work to find.


@iman Here is the code to find the denominators starting with your system of odes (called sys here).

restart;
sys:={diff(F(eta), eta, eta, eta)+E(eta)*(3*F(eta)*(diff(F(eta), eta, eta))-(diff(F(eta), eta))^2)/(.18*K(eta)^2)+(2*(diff(K(eta), eta))/K(eta)-(diff(E(eta), eta))/E(eta))*(diff(F(eta), eta, eta))+E(eta)/(0.9e-1*K(eta)^2) = 0,
diff(theta(eta), eta, eta)+15*E(eta)*(F(eta)*(diff(theta(eta), eta))-theta(eta)*(diff(F(eta), eta)))/K(eta)^2+(2*(diff(K(eta), eta))/K(eta)-(diff(E(eta), eta))/E(eta))*(diff(theta(eta), eta)) = 0,
diff(K(eta), eta, eta)+E(eta)*(1.5*F(eta)*(diff(K(eta), eta))-K(eta)*(diff(F(eta), eta)))/(0.9e-1*K(eta)^2)+(2*(diff(K(eta), eta))/K(eta)-(diff(E(eta), eta))/E(eta))*(diff(K(eta), eta))+(diff(F(eta), eta, eta))^2-E(eta)^2/(0.9e-1*K(eta)^2) = 0,
diff(E(eta), eta, eta)+7.2222*E(eta)*(3*F(eta)*(diff(E(eta), eta))-E(eta)*(diff(F(eta), eta)))/K(eta)^2+(2*(diff(K(eta), eta))/K(eta)-(diff(E(eta), eta))/E(eta))*(diff(E(eta), eta))+1.872*E(eta)*(diff(F(eta), eta, eta))^2/K(eta)-27.7333*E(eta)^3/K(eta)^3 = 0};
##Your boundary conditions:
bcs:={F(0) = 0, (D(F))(0) = 0, K(0) = 0, E(0) = 0, theta(0) = 1,((D@@2)(F))(1) = 0, K(1) = 0, E(1) = 0, theta(1) = 0};
indets(sys,specfunc(diff));
## The highest derivatives for F, E, K, and theta:
highD:={diff(F(eta),eta$3),diff(E(eta),eta,eta),diff(K(eta),eta,eta),diff(theta(eta),eta,eta)};
sysS:=solve(sys,highD); #Solving for the highest derivatives
##Finding the denominators (although they are in fact visible in sysS):
denom~(subs(sysS,highD));
##Answer:  {K(eta)^2*E(eta), K(eta)^3*E(eta)}
##These denominators are sure to give you numerical problems because of your boundary conditions for E and K.
## As I said, try a midpoint method and you find you still have a problem. So in fact the reported singularity at eta=0 and/or at eta=1 might indeed actually be a singularity.
#################
##Simple example:
restart;
ode:=diff(y(x),x,x)=1/y(x);
dsolve({ode,y(0)=0,y(1)=0},numeric,method=bvp[midrich]);




I'm not sure I get your point unless the equations were supposed to be differential equations, so that the first set would be:
Diff(x[1],t) = f[1](p[1]....p[n],x[1]...x[m])
...
etc.

And the second set
Diff(y[1],s) = f[1](q[1]....q[p],y[1]...y[m])
...

etc.
where also t is changed to s.
?

@vv Indeed!
The help page for sum says:

To add a finite sequence of values, rather than compute a formula, use the add command.  For example, add(k, k=0..9) returns 45.  Although the sum command can often be used to compute explicit sums, it is strongly recommended that the add command be used in programs if an explicit sum is needed, in particular, when summing over all elements of a list, Array, Matrix, or similar data structure.
(emphasis added)

@H-R Maple simplies u/sqrt(u) to u^(1/2), because it is always correct:

Proof:  Write u = r*exp(I*t), where r > 0 and  -Pi < t <= Pi.
Then  u^(1/2) = r^(1/2) * exp( I*t/2), since -Pi < -Pi/2 < t/2 <= Pi/2 <= Pi, so that t/2 is the principal argument of u^(1/2).
Thus by using the properties of the exponential function we get:

u/sqrt(u) = (r/r^(1/2))*exp(I*t -I*t/2) = r^(1/2)*exp(I*t/2) = u^(1/2).

rsolve doesn't use f(0)=1:
restart;
eq:=f(n)=f(n-1)/2+f(n+1)/2;
pb:={eq, f(0)=1, f(6)=0};
res:=rsolve(pb, {f(n)});
eval(%,n=0); #Using that f(0)=1 we get:
res2:=eval(res,f(5)=1/6);


It is not explicitly stated in the help page for rsolve, but seems to be assumed that boundary conditions are given sequentially with none missing between lowest and highest n. Since only two conditions can be given here, f(0) and f(1) could be given, or f(5) and f(6) for instance.

Example:
pb2:={eq, f(5)=1/6, f(6)=0};
rsolve(pb2,f(n));


@vv Actually, the result is not wrong, but isn't satisfactory since f(0) = 1 is not used:

eq:=f(n)=f(n-1)/2+f(n+1)/2;
pb:={eq, f(0)=1, f(6)=0};
res:=rsolve(pb, {f(n)});
eval(%,n=0); #So using that f(0)=1 we get:
res2:=eval(res,f(5)=1/6);


@vv and Markiyan: Thanks for the references.

Thank you Carl (and acer) for sharing with us this insight.

Off topic, but inspired by the fact that the false eigenvalues RPf (as remarked by Carl) seems to lie on a circle, I recalled my observation a few years ago that a randomly chosen polynomial of high degree has roots which tend to cluster around a circle of radius 1.
I wondered why, and still do.

restart;
p:=RandomTools:-Generate(polynom(integer(range=-99..99),z,degree=100));
r:=fsolve(p=0,z,complex):
plots:-complexplot([r],style=point,symbol=circle,scaling=constrained);

To get all 50 roots:

degree(g,x); #50
fsolve(g=0,x,complex); #Include the imaginary ones
nops([%]); #50

@canoiras Although it is certainly not clear to me precisely what you want to do, I should point out that in the example, which I gave in my answer below, I used boolean variables essentially to switch from one form of the system to another. These boolean variables are changed by the events specified.
Maybe you could give the Maple code, you already have, for us to work on.

@Bendesarts You cannot have equations in plot. Use a parametric plot:

plot([seq([Pz[i],t,t=-0.1..0.1],i=1..nops(Pz))],colour=yellow,linestyle=3, thickness=2,view=[0..2,default]);

Adjust [Pz[i],t,t=-0.1..0.1] to taste.

@Bendesarts If you do this:

restart;
for i to 4 do
  u[i]:=unapply(L/2*cos(w*t+phi[i]),t);
  Equ[i]:=evaln(u[i](t))=u[i](t)
end do;
## then you have
Equ[1];
              (1/2)*L*cos(t*w+phi[1]) = (1/2)*L*cos(t*w+phi[1])

Certainly true, but not exciting!

So if you just want to define the u[i]'s as functions, then you shouldn't define equations, you should just assign to u[i] as in e.g:
restart;
for i to 4 do u[i]:=unapply(L/2*cos(w*t+phi[i]),t) end do;
#Test:
u[1](s);




@Thomas Richard This way it exhibits well as it is run, but try afterwards:
Eq[1];

This is just stating that a=a, so to speak.

I tried from within Maple using "Check for Updates". It took forever (50 minutes at least), and stalled when 8 seconds were left, or so it claimed. Then at some point it "decided" to try again and announced a long download time (about 50 minutes again). I went shopping for beer. When I came back my computer had fallen asleep, but when I woke it up the downloading was not finished, but later it stalled at 5 seconds left. Then apparently it gave up. 

I then tried the Maplesoft website. The update downloaded very rapidly and installed without problem.

First 92 93 94 95 96 97 98 Last Page 94 of 231