<

Preben Alsholm

12813 Reputation

22 Badges

17 years, 310 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@tomleslie In order to be fair you must divide by 2000 000 in ans2:

ans1:=(654321.987*123456.789)/2;
ans2:=(654321987*123456789)/2000000;

@nm Normally you cannot put a number first followed by a letter; that would produre a syntax error. Example 1w would produce an error.
There are exceptions:  1d and  1e are examples.

@Jaime_mc2 This works with Digits:=50 in Maple 2021.2
 

evalf(Int(abs(u(x) - P__2), x = -1 .. 1,method= _Gquad));

The result is 0.00062767200590347019035308761635491656933673486658951.
Inspired by mmcdara I added simplify like this:
 

r := evalf(allvalues(RootOf(simplify(ChebyshevT(5, x)), x)));

and this time the result was
0.00062767200590347019035308761635491656933673486658622

not a huge difference there.

But the latter version, but not the former, worked in Maple 12 too and with that same result.

@nm Have a look at this simple example:

restart;
f:=x->a*x;
simplify(sqrt(f(a)),assume=[a<0]);
simplify(sqrt(f(a))) assuming a<0;

In the first case sqrt(f(a)) is evaluated to sqrt(a^2) before the assumption kicks in, thus the result -a.

In the second case the expression sqrt(f(a)) is not evaluated until the assumption a<0 is made. But the "version" of the 'a'  that is seen by `assuming` is therefore only the argument to f, not the 'a' appearing in the in the definition of f.
My point here has just been to say that the two versions don't work quite the same.
###
You can see it here from the printout from debug(`assuming`:
 

restart;
f:=x->a*x;
debug(`assuming`);
simplify(sqrt(f(a)),assume=[a<0]);
simplify(sqrt(f(a))) assuming a<0;

 

Obviously the syntax for Int is wrong.
Replace Int with F then both simplifications work.

@oggsait  Yes I was using the recent version of Maple.

But in Maple 18 (which you are using) I get the plot you show.

But as Carl Love points out you should use a finer grid. Besides that it helps to set gridrefine to 2 as in this code:
 

plots:-display(seq(plots:-implicitplot(eval(EQ2,params1 union {C=k/200}),u=-1..1,z=-1..1,grid=[50,50],gridrefine=2),k=-2..2));

If you look at the help for implicitplot you will find other options. Actually it looks to me that this version gives a better result than the one above:
 

plots:-display(seq(plots:-implicitplot(eval(EQ2,params1 union {C=k/200}),u=-1..1,z=-1..1,grid=[50,50],gridrefine=1,crossingrefine=2),k=-2..2));

 

@jennierubyjane Merry Christmas to you too!

@jennierubyjane You can say considerably more.
A few hints at what is going on:
Notice in my code the use of values for initmesh and maxmesh.
So from the interval, in your case 0..10, is chosen an initial mesh (default consisting of 8 points). I used 512 points.
Notice also that an approximate solution can be given as an option (I didn't use that here). If not given the procedure finds an approximate solution itself based only on the boundary conditions (!).
Here is an example of getting some information about the solving process:

restart;
#infolevel[`dsolve/numeric/BVP`]:=2:  # Also try 3 or 4:
infolevel[`numeric/bvp`]:=5: # Another possibility
ode:= diff(y(x),x,x)+sin(y(x)) +y(x) = 1;
bcs:=y(0)=1,D(y)(5)=0;
res:=dsolve({ode,bcs},numeric);
plots:-odeplot(res,[x,y(x)]);

Deliberately I used a much simpler example than yours, but the process is the same.
Notice that `dsolve/numeric/bvp` is different from `dsolve/numeric/BVP`.
The former calls the latter, i.e. `dsolve/numeric/BVP` is used by `dsolve/numeric/bvp`.
You can see that here in line 440.
showstat(`dsolve/numeric/bvp`);

@jennierubyjane When dsolve/numeric is given a boundary value problem it is using the procedure `dsolve/numeric/bvp`

For that procedure see the help page ?dsolve,numeric,bvp.

RKF45 is made for initial value problems.
If one insists on somehow making use of that method (or other intial value procedures) shooting has to be done.
That means starting at one end (e.g. eta = 0) with all the required initial values, which implies "guessing" some.

That can be done. I have no reason to believe that that is going to give a better result.
The "guessing" can be implemented by using the parameters option to dsolve where the parameters will be the unknown initial values. Then fsolve will be involved after that.

@jennierubyjane I revised the worksheet so phi and -diff(theta(eta),eta) are shown and for all values also of Nb.

Why the numbers in your table don't agree with the Maple results I cannot tell.
Are the original equations OK?
Was the right endpoint i.e. eta = 10 also used by the author of the table?
I understand that here it stands for infinity. Sometimes I have seen lower values than 10 used, e.g. 8.
The main thing, however, is that we compare with the same values of input all over.
Does the author reveal what kind of method was used to find the values?

MaplePrimes21-12-24_odebvpIII.mw

@jennierubyjane I have made several changes as you will notice.

I usually don't upload an executed version of a worksheet, and below you will see that the quality isn't nearly as good as it is on my computer.
When you click on the display/insequence version a panel on top of the screen comes up (or should come up). You can choose the speed or move one frame at a time.
I notice that the display of Vals is screwed up. Have a look at the worksheet itself.

MaplePrimes21-12-24_odebvpII_executed.mw

restart;

with(plots):

 

DE1 := diff(f(eta), eta$3)+f(eta)*(diff(f(eta), eta$2))-(diff(f(eta), eta))^2 = 0;

diff(diff(diff(f(eta), eta), eta), eta)+f(eta)*(diff(diff(f(eta), eta), eta))-(diff(f(eta), eta))^2 = 0

DE2 := diff(theta(eta), eta$2)+Pr*f(eta)*(diff(theta(eta), eta))+Pr*Nb*(diff(theta(eta), eta))*(diff(phi(eta), eta))+Pr*Nt*diff(theta(eta), eta)^2 = 0;

diff(diff(theta(eta), eta), eta)+Pr*f(eta)*(diff(theta(eta), eta))+Pr*Nb*(diff(theta(eta), eta))*(diff(phi(eta), eta))+Pr*Nt*(diff(theta(eta), eta))^2 = 0

DE3 := diff(phi(eta), eta$2)+Le*(diff(phi(eta), eta))+Nt*(diff(theta(eta), eta$2))/Nb;

diff(diff(phi(eta), eta), eta)+Le*(diff(phi(eta), eta))+Nt*(diff(diff(theta(eta), eta), eta))/Nb

BC1 := f(0) = 0, (D(f))(0) = 1, (D(f))(10) = 0;

f(0) = 0, (D(f))(0) = 1, (D(f))(10) = 0

BC2 := theta(10) = 0, (D(theta))(0) = -Bi*(1-theta(0));

theta(10) = 0, (D(theta))(0) = -Bi*(1-theta(0))

BC3 := phi(0) = 1, phi(10) = 0;

phi(0) = 1, phi(10) = 0

Digits:=15:

##

L := [0.1,0.2,0.3,0.4,0.5];
nL:=numelems(L):
for i from 1 to nL do
   for k from 1 to nL do
      res[i,k]:=dsolve(
                  eval({BC1, BC2, BC3, DE1, DE2, DE3}, [Nt = L[k], Nb=L[i], Pr=10, Le=10, Bi=0.1]),
                  numeric,output=listprocedure, abserr=1e-10,maxmesh=1024,initmesh=512
                );
      PH[i,k],mTH1[i,k] := op(subs(res[i,k], [phi(eta),-diff(theta(eta), eta)]));
   
   end do;
end do:

[.1, .2, .3, .4, .5]

M:=Matrix([seq([L[k],seq(mTH1[i,k](0),i=1..nL)],k=1..nL)]);

M := Matrix(5, 6, {(1, 1) = .1, (1, 2) = HFloat(0.09079204195997714), (1, 3) = HFloat(0.07999458907826575), (1, 4) = HFloat(0.06038735511214605), (1, 5) = HFloat(0.035939234854121746), (1, 6) = HFloat(0.017220024220039862), (2, 1) = .2, (2, 2) = HFloat(0.09048653015958226), (2, 3) = HFloat(0.07866376250695364), (2, 4) = HFloat(0.056451951494423856), (2, 5) = HFloat(0.0306001744671172), (2, 6) = HFloat(0.013603325725012235), (3, 1) = .3, (3, 2) = HFloat(0.09015411370183106), (3, 3) = HFloat(0.07711548838707), (3, 4) = HFloat(0.051978605826939764), (3, 5) = HFloat(0.02573745440282669), (3, 6) = HFloat(0.010872451216143206), (4, 1) = .4, (4, 2) = HFloat(0.08979077608034479), (4, 3) = HFloat(0.07529813593135734), (4, 4) = HFloat(0.04711421671313636), (4, 5) = HFloat(0.021624435358676336), (4, 6) = HFloat(0.00885989600363249), (5, 1) = .5, (5, 2) = HFloat(0.08939164233960008), (5, 3) = HFloat(0.07314965034262784), (5, 4) = HFloat(0.04215277835976381), (5, 5) = HFloat(0.018312484329286654), (5, 6) = HFloat(0.0073775356466370765)})

top:=Vector[row]([Nt,seq(Nb=L[i],i=1..nL)]);

top := Vector[row](6, {(1) = Nt, (2) = Nb = .1, (3) = Nb = .2, (4) = Nb = .3, (5) = Nb = .4, (6) = Nb = .5})

Vals:=<top,M>;

Vals := Matrix(6, 6, {(1, 1) = Nt, (1, 2) = Nb = .1, (1, 3) = Nb = .2, (1, 4) = Nb = .3, (1, 5) = Nb = .4, (1, 6) = Nb = .5, (2, 1) = .1, (2, 2) = HFloat(0.09079204195997714), (2, 3) = HFloat(0.07999458907826575), (2, 4) = HFloat(0.06038735511214605), (2, 5) = HFloat(0.035939234854121746), (2, 6) = HFloat(0.017220024220039862), (3, 1) = .2, (3, 2) = HFloat(0.09048653015958226), (3, 3) = HFloat(0.07866376250695364), (3, 4) = HFloat(0.056451951494423856), (3, 5) = HFloat(0.0306001744671172), (3, 6) = HFloat(0.013603325725012235), (4, 1) = .3, (4, 2) = HFloat(0.09015411370183106), (4, 3) = HFloat(0.07711548838707), (4, 4) = HFloat(0.051978605826939764), (4, 5) = HFloat(0.02573745440282669), (4, 6) = HFloat(0.010872451216143206), (5, 1) = .4, (5, 2) = HFloat(0.08979077608034479), (5, 3) = HFloat(0.07529813593135734), (5, 4) = HFloat(0.04711421671313636), (5, 5) = HFloat(0.021624435358676336), (5, 6) = HFloat(0.00885989600363249), (6, 1) = .5, (6, 2) = HFloat(0.08939164233960008), (6, 3) = HFloat(0.07314965034262784), (6, 4) = HFloat(0.04215277835976381), (6, 5) = HFloat(0.018312484329286654), (6, 6) = HFloat(0.0073775356466370765)})

colorList:=[red,blue,"Green",magenta,"DarkGreen"];

[red, blue, "Green", magenta, "DarkGreen"]

display(Array([
               display(seq(odeplot(res[1,k],[eta,phi(eta)],0..2.5,color=colorList[k]),k=1..nL)),          
               display(seq(odeplot(res[1,k],[eta,theta(eta)],0..2.5,color=colorList[k]),k=1..nL))
             ]));

 

 

 

 

 

display(Array([
               display(seq(odeplot(res[1,k],[eta,phi(eta)],0..2.5,color=colorList[k]),k=1..nL),insequence),          
               display(seq(odeplot(res[1,k],[eta,theta(eta)],0..2.5,color=colorList[k]),k=1..nL),insequence)
             ]));

 

 

 

 

 

 

 

``

Download MaplePrimes21-12-24_odebvpII_executed.mw

@jennierubyjane To get another range than the default taken from the boundary conditions, just add a range:

display(Array([
               display(seq(odeplot(res[k],[eta,phi(eta)],0..2.5),k=1..numelems(L))),          
               display(seq(odeplot(res[k],[eta,theta(eta)],0..2.5),k=1..numelems(L)))
             ]));

To get values basically you can just do as here:

res[1](0.5); # eta=0.5

If you only want phi and theta and have a particular vector of eta values in mind then do:

for k from 1 to numelems(L) do
  PH[k],TH[k]:=op(subs(res[k],[phi(eta),theta(eta)]));
end do:
interface(rtablesize=11); # So you actually see all the values (they are there anyway)
ET:=Vector([seq(0.25*i,i=0..10)]);
Matrix([ET,PH[3]~(ET),TH[3]~(ET)]); # Example: k = 3, i.e. Pr = L[3] = 5, Columns: eta,phi,theta

If you want one particular value of eta, here eta = 0.5, and phi and eta for all the values of Pr do:

## Values for all Pr and for eta = 0.5: Pr, phi, theta
Matrix([Vector(L),Vector([seq(PH[k](0.5),k=1..numelems(L))]),Vector([seq(TH[k](0.5),k=1..numelems(L))])]);

@jennierubyjane Which values do you want to print out?
You said:  " ... dont know how to print out the values tsk tsk"
What does "tsk tsk" refer to?

From your do loop in the code I see that the procedures for phi(eta) and -diff(phi(eta),eta) are saved.
Are those numerical procedures the ones you call values?

While waiting for your answer to my question I shall allow myself to continue mmcdara's worksheet
ODEprobz_mmcdara.mw here:

 

L := [0.7e-1, .2, .7, 2, 7, 20, 70];
for k from 1 to numelems(L) do
   res[k]:=dsolve(
                  eval({BC1, BC2, BC3, DE1, DE2, DE3}, [Pr = L[k], Nb=1, Nt=1, Le=1, Bi=1]), 
                  numeric,output=listprocedure
                 );
   
end do:
display(Array([
               display(seq(odeplot(res[k],[eta,phi(eta)]),k=1..numelems(L))),          
               display(seq(odeplot(res[k],[eta,-diff(phi(eta),eta)]),k=1..numelems(L)))
             ]));

I deleted your recent repost of this question. It appears that you already received an answer.
If you have further questions then continue this thread. Don't start another one.

We may use that the system has a conserved quantity.
Also it's worth noticing that the system can de solved exactly. We shall not use that solution though.

## sys is defined above in my answer.
dsolve({sys});
ode:=eval(diff(sys[1],xi),sys[2]);
EQ1:=map(int,ode*diff(u(xi),xi),xi)+(0=C);
isolate(EQ1,C);
EQ2:=subs(sys[1],u(xi)=u,z(xi)=z,%);
params1:={kao=0.1,Kga=.2,beta=1};
plots:-display(seq(plots:-implicitplot(eval(EQ2,params1 union {C=k/200}),u=-1..1,z=-1..1),k=-2..2));
params2:={kao=-0.1,Kga=-.2,beta=1};
plots:-display(seq(plots:-implicitplot(eval(EQ2,params2 union {C=k/10}),u=-1..1,z=-1..1),k=-2..2));
rhs(EQ2);
plots:-contourplot(eval(rhs(EQ2),params1),u=-1..1,z=-1..1,contours=[seq(k/10,k=-2..2)],grid=[50,50]);
plots:-contourplot(eval(rhs(EQ2),params2),u=-1..1,z=-1..1,contours=[seq(k/10,k=-2..2)],grid=[50,50]);

The plots from contourplot are not as good as the ones from implicitplot for C = 0 and (u,z) near (0,0).

MaplePrimes (right now anyway) seems to have a serious problem bringing the (first) implicitplot when I just copy and paste.
So I saved the plot as a png file:


Here is the second implicitplot:

2 3 4 5 6 7 8 Last Page 4 of 214