## 13613 Reputation

19 years, 236 days

## Agree...

@nm You are right!

## Boundary condition?...

@Sradharam Do you mean to say that the boundary conditions for theta are theta(0)=1 and theta(infinity)=0 instead of what you actually wrote?

If your answer is YES then in my code just make the following changes:
1. In the procedure Q change TH(inf) -1 to TH(inf).
2. Use this th1 interval th1=-0.1325..-0.1275 in the animation and the same interval in the 3 solving methods.

Make no other changes.
You get:

params := {f1 = -0.9272464891, th1 = -0.1295294672}

and the graphs:

## Some attempts at an explanation...

@Sradharam I admit that the code is in need of some explanation.
Here I will just point to a few essential features.

1. Using the parameters option in dsolve ( here parameters=[f1,th1] ) sets up the result (here named respar) as a complete recipe for computation before any values are actually given to those parameters. This avoids having to call dsolve for every new pair of actual values for the parameters. To insert values for the parameters you just do
respar( parameters = [xx, yy]) or more explicitly respar( parameters = [f1=xx, th1=yy]), where xx and yy are actual numbers.

2. Using output = listprocedure instead of the default output = procedurelist makes it easy to extract the procedures you will actually use. In our case they are called F and TH. They compute values for f(xi) and theta(xi), respectively, when given a concrete value for xi. We need F(inf) = 0 and TH(inf) -1 = 0, where inf is here taken to be 10 later.

3. The procedure Q produces a list of the values F(inf) and TH(inf) -1 on input of concrete values for f1 and th1.
To make it possible to solve for f1 and th1 using either of the 3 methods I used I have made the procedures q1 and q2 return the single values F(inf) and TH(inf) -1, respectively. The option remember in Q implies that a call to q1 will make it very cheap to answer the call to q2. Both will be taken from the same call to Q.

4. Since respar( parameters = [xx, yy]) sets the parameters to the values xx and yy the parameters are reset many times when either of the 3 solution methods are used. Since we don't necessarily know what values are set last, the cautious user will set the parameters returned by either of the 3 methods if respar (or F or TH) is going to be used with those parameters. I used respar subsequently to plot using odeplot. I set respar at the result from fsolve.

5. I'm using the default rkf45 dsolve method as mentioned. This is a variable step method. It adjusts the step taken in order to make sure that the absolute and relative error bounds are satisfied. The classical RK4 method is a fixed step method, i.e. you choose the stepsize in advance. There is no error control.
Another drawback for RK4 is that the parameters option is not available for that method.

@Sradharam As Tom Leslie points out, you need to give us the value of Pr.

I have taken it to be 0.01, and I use alpha=2, k=1.5.
I'm using the same shooting method I used above, but it is now extended to two variables.
The numerical method used by dsolve is the default rkf45 (rkf=Runge-Kutta-Fehlberg).

```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;
ode3 := theta(xi)*f(xi) + g(xi)*diff(theta(xi), xi) - 1/3*xi*f(xi)*diff(theta(xi), xi) = diff(theta(xi), xi, xi)/Pr;
bcs_theta:=theta(0) = 1, theta(infinity) = 1;
####
respar:=dsolve(eval({odeSys,ode3,f(0)=alpha,g(0)=0,D(f)(0)=f1,theta(0)=1,D(theta)(0)=th1},{alpha=2,k=1.5,Pr=.01}),numeric,
parameters=[f1,th1],output=listprocedure,abserr=1e-12,relerr=1e-10);
F,TH:=op(subs(respar,[f,theta](xi)));
Q:=proc(f1,th1,inf) option remember;
#if not [f1,th1,inf]::list(realcons) then return 'procname(_passed)' end if;
respar(parameters=[f1,th1]);
[F(inf),TH(inf)-1]
end proc;
q1:=proc(f1,th1,inf) if not [f1,th1,inf]::list(realcons) then return 'procname(_passed)' end if;
Q(_passed)[1]
end proc;
q2:=proc(f1,th1,inf) if not [f1,th1,inf]::list(realcons) then return 'procname(_passed)' end if;
Q(_passed)[2]
end proc;
###
### Some exploratory plotting:
plot([q1(f1,-0.025,10),q2(f1,-0.025,10)],f1=-2..0);
plots:-animate(plot,[[q1(f1,th1,10),q2(f1,th1,10)],f1=-1..-0.9,-0.3..0.3],th1=-0.03..0);
### From the animation we see that the values for theta must lie in the range:
th1=-0.025..-0.02375; # sol1
### in order to find the relevant solution (there are 3 as before).
### I find the values for f1 and th1 in 3 ways although one is enough.
### Skip the first if you don't have DirectSearch yet.
with(DirectSearch);
SolveEquations([q1(f1,th1,10),q2(f1,th1,10)],{f1=-0.95..-0.92,th1=-0.025..-0.02375});
Optimization:-LSSolve([q1(f1,th1,10),q2(f1,th1,10)],f1=-0.95..-0.92,th1=-.025..-0.02375);
params:=fsolve([q1(f1,th1,10),q2(f1,th1,10)],{f1=-0.95..-0.92,th1=-.025..-0.02375});
respar(parameters=convert(params,list)); # Making sure parameters are set at params.
plots:-odeplot(respar,[[xi,f(xi)],[xi,g(xi)],[xi,theta(xi)]],0..10,thickness=3,legend=[f,g,theta]);
plots:-odeplot(respar,[xi,theta(xi)],0..10);
```

Here are the graphs:

## Got an error...

Error, (in plottools:-rotate) invalid plot structure: wheel

What is p1 in the code for wheel in the line

`p[i++] := translate(p1, 0,0,-h):`

?

Added: It appears that d1 should be %.

Also in the code for spokes wheel should be wheel().

## KummerM and method=_d01ajc...

@Carl Love In Maple 2021.1 numerical integration of KummerM doesn't work with method=_d01ajc. Thus h[1] [1] doesn't get evaluated.in the double loop. I have submitted an SCR.

```restart;
K:=KummerM(-0.0847656450, 5., 10.33906258*r^2);
int(K,r=0..1,numeric, method = _d01ajc);
```

## 'satisfies'...

@mmcdara To your first question: That is what I thought of first. You are right, your shorter version works too.

The type And(relation,satisfies(r->lhs(r)=t)) is satisfied by expressions that are both of type relation and also of the special type 'satisfies'. The argument to 'satisfies' is a procedure that returns true (in this example) if the relation (here t < something, or x(t)<something) has left hand side equal to t.
See type/satisfies.

## Maybe so...

@itsme You may be right. The acceptance of vector input is fairly new.

By the way there is another inconsistency: dsolve with method=laplace or type=series will not work without the variable(s) as a second argument. That I have been told is due to different people writing those parts.

```restart;

sys:=Vector([diff(x(t),t),diff(y(t),t)]) = Matrix([[1,2],[0,3]]).Vector([x(t),y(t)]);
init:=<x(0),y(0)> = <x0,y0>; # vector equation
### I think the form of the following outputs are quite fine:
dsolve(sys);         # output set of eqs
dsolve({sys,init}); # output set of eqs
## Giving the second argument as a vector forces vector output:
dsolve({sys,init},<x(t),y(t)>); # output vector equation
dsolve(sys,<x(t),y(t)>);         # output vector equation

### The next outputs are also fine.
### The second argument, however, MUST be present when using method = laplace or (type=)series

dsolve(sys,[x(t),y(t)],method=laplace);   # output set of eqs
dsolve(sys,[x(t),y(t)],series);                   # output set of eqs
dsolve(sys,<x(t),y(t)>,method=laplace); # output vector equation
dsolve(sys,<x(t),y(t)>,series);                 # output vector equation
```

## Difference in two loops...

@Carl Love In the help page for seq the following two illustrations are given. Here adapted to the present discussion.

```restart;
S:=NULL;
old:=x[4];
for x[4] from 1 to 10 do S:=S,u(x[4]) end do;
x[4]:=old;
S;
restart;
S:=NULL;
old:=x[4];
for x[4] in [1,2,3,4,5,6,7,8,9,10] do S:=S,u(x[4]) end do;
x[4]:=old;
S;
```

Here we get the assignment 11 to x[4] in the first and 10 to x[4] in the second.

## Old fact...

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.

## A reason...

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.

## No way to get a symbolic solution...

@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.

## Disappearance of toolbar...

@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.

## Problem in Maple2021...

@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.

 First 19 20 21 22 23 24 25 Last Page 21 of 229
﻿