Preben Alsholm

13471 Reputation

22 Badges

20 years, 252 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

Your huge example about radnormal (bug 3) can be reduced quite a lot in size:

Z:=-(2*(-4*q23^2*v*q12+4*q23^2*v^3*q12-8*q13^2*q12*v+8*q13^2*v^3*q12+4*q23^2*v*q12*lambda^2-4*q23^2*v^3*q12*lambda^2+8*q13^2*q12*v*lambda^2-8*q13^2*v^3*q12*lambda^2+4*sqrt(1-lambda^2)*q13*q12^2*v^2*lambda^2-2*sqrt(1-lambda^2)*q13*q12^2*v^4*lambda^2+8*q13^3*v^2*sqrt(1-lambda^2)+2*sqrt(1-lambda^2)*q13*q12^2-4*sqrt(1-lambda^2)*q13*q12^2*v^2+2*sqrt(1-lambda^2)*q13*q12^2*v^4+8*q23^2*v^2*q13*sqrt(1-lambda^2)-2*sqrt(1-lambda^2)*q13*q12^2*lambda^2))/((q12-q12*lambda^2-q12*v^2+q12*v^2*lambda^2-2*sqrt(1-lambda^2)*q13*v)*(sqrt(1-lambda^2)*q12-sqrt(1-lambda^2)*q12*v^2-2*q13*v));

radnormal(Z);
Error, (in F) invalid subscript selector

 

Added comment: I don't know what is going on, but the following (strange) workaround works on your example as well as on my short one:

radnormal(eval(Z,3=t)):
Z3:=radnormal(eval(%,t=3)):

#4 is OK too:

radnormal(eval(Z,4=t)):
Z4:=radnormal(eval(%,t=4)):
evalb(Z3=Z4);
                              true

@hirnyk There were spaces after `if` and after seq. In 2d-input they were interpreted as multiplication. In 1d-input they are ignored.

I always use worksheet interface with 1d-input, so don't have a problem. But I suppose that if you create a regular input line in document mode (e.g. by doing crtl j) and make sure you use 1d-input (crtl m) on that line then hopefully everything should be OK. 

@hirnyk There were spaces after `if` and after seq. In 2d-input they were interpreted as multiplication. In 1d-input they are ignored.

I always use worksheet interface with 1d-input, so don't have a problem. But I suppose that if you create a regular input line in document mode (e.g. by doing crtl j) and make sure you use 1d-input (crtl m) on that line then hopefully everything should be OK. 

@hirnyk Notice the * after `if` ( `if`*) and after seq (seq*).

If you just copy from Jean-Jacques' posting they ought not appear (and didn't in my case).

Ceterum censeo 2d-input esse delendam 

@hirnyk Notice the * after `if` ( `if`*) and after seq (seq*).

If you just copy from Jean-Jacques' posting they ought not appear (and didn't in my case).

Ceterum censeo 2d-input esse delendam 

Maple doesn't really get anything out of using assuming here.

restart;
solve(160/m>=5*2^m,m) assuming m::posint;
restart;
solve(160/m>=5*2^m,m);

#floor is not handled at all:

solve(floor(160/m)>=5*2^m,m);
solve(floor(x)>=4,x);

@MapleFans001 The initial values should come from the original problem, which you have not described. Is it a physics problem or what?

@MapleFans001 The initial values should come from the original problem, which you have not described. Is it a physics problem or what?

@MapleFans001 If you get the error message that there probably is a singularity, most likely that is indeed the case.

You may want to make use of the parameters option, see ?dsolve,numeric,interactive

You could assign the parameters which you don't want to change. Here I included all of them, and also introduced two new ones, the values of df1/dt(0) = f1p0 and df4/dt(0) = f4p0:

restart;
with(plots):

parNames:=[r,c,G,M,theta,f1p0,f4p0]:
ex1 := {
Diff(f1(t), t$2)
+ 2*(-G*M/(r*(-r*c^2+2*G*M)))*Diff(f1(t), t)*Diff(f2(t), t) = 0,

Diff(f2(t), t$2)
+ (-(-r*c^2+2*G*M)*G*M/(r^3*c^2))*Diff(f1(t), t)^2
+ (G*M/(r*(-r*c^2+2*G*M)))*Diff(f2(t), t$2)
+ ((-r*c^2+2*G*M)/c^2)*Diff(f3(t), t$2)
+ ((-r*c^2+2*G*M)*sin(theta)^2/c^2)*Diff(f4(t), t)^2 = 0,

Diff(f3(t), t$2)
+ 2*(1/r)*Diff(f2(t), t)*Diff(f3(t), t)
+ (-sin(theta)*cos(theta))*Diff(f4(t), t)^2 = 0,

Diff(f4(t), t$2)
+ 2*(1/r)*Diff(f2(t), t)*Diff(f4(t), t)
+ 2*(cos(theta)/sin(theta))*Diff(f3(t), t)*Diff(f4(t), t) = 0

};

#Here parameters are introduced into ic:

ic := {f1(0)=0, f2(0)=0, f3(0)=0, f4(0)=0, D(f1)(0)=f1p0, D(f2)(0)=0, D(f3)(0)=0,D(f4)(0)=f4p0};

dsol := dsolve(ex1 union ic, numeric,parameters=parNames,range=0..100);
#First example:
dsol(parameters=[r=1,c=1,G=1,M=1,theta=90,f1p0=0,f4p0=1]);
dsol(80);

odeplot(dsol, [seq([t, cat(f,i)(t)],i=1..4)], 0..100,thickness=2);
odeplot(dsol, [f2(t),f4(t)], 0..100,thickness=2,refine=1);
odeplot(dsol, [f2(t),diff(f4(t),t)], 0..100,thickness=2,refine=1);
odeplot(dsol, [f2(t),f4(t),diff(f4(t),t)], 0..100,thickness=2,axes=boxed,refine=1);

#Second example

dsol(parameters=[r=1,c=1,G=1,M=1,theta=90,f1p0=.2,f4p0=1]);
dsol(80);

#Here you get the error message:

dsol(80);
Error, (in dsol) cannot evaluate the solution further right of 78.216979, probably a singularity
#And you can see why by doing:
dsol(last);

#and you can plot the graph of df1/dt:

odeplot(dsol,[t,diff(f1(t),t)],0..78.2);

@MapleFans001 If you get the error message that there probably is a singularity, most likely that is indeed the case.

You may want to make use of the parameters option, see ?dsolve,numeric,interactive

You could assign the parameters which you don't want to change. Here I included all of them, and also introduced two new ones, the values of df1/dt(0) = f1p0 and df4/dt(0) = f4p0:

restart;
with(plots):

parNames:=[r,c,G,M,theta,f1p0,f4p0]:
ex1 := {
Diff(f1(t), t$2)
+ 2*(-G*M/(r*(-r*c^2+2*G*M)))*Diff(f1(t), t)*Diff(f2(t), t) = 0,

Diff(f2(t), t$2)
+ (-(-r*c^2+2*G*M)*G*M/(r^3*c^2))*Diff(f1(t), t)^2
+ (G*M/(r*(-r*c^2+2*G*M)))*Diff(f2(t), t$2)
+ ((-r*c^2+2*G*M)/c^2)*Diff(f3(t), t$2)
+ ((-r*c^2+2*G*M)*sin(theta)^2/c^2)*Diff(f4(t), t)^2 = 0,

Diff(f3(t), t$2)
+ 2*(1/r)*Diff(f2(t), t)*Diff(f3(t), t)
+ (-sin(theta)*cos(theta))*Diff(f4(t), t)^2 = 0,

Diff(f4(t), t$2)
+ 2*(1/r)*Diff(f2(t), t)*Diff(f4(t), t)
+ 2*(cos(theta)/sin(theta))*Diff(f3(t), t)*Diff(f4(t), t) = 0

};

#Here parameters are introduced into ic:

ic := {f1(0)=0, f2(0)=0, f3(0)=0, f4(0)=0, D(f1)(0)=f1p0, D(f2)(0)=0, D(f3)(0)=0,D(f4)(0)=f4p0};

dsol := dsolve(ex1 union ic, numeric,parameters=parNames,range=0..100);
#First example:
dsol(parameters=[r=1,c=1,G=1,M=1,theta=90,f1p0=0,f4p0=1]);
dsol(80);

odeplot(dsol, [seq([t, cat(f,i)(t)],i=1..4)], 0..100,thickness=2);
odeplot(dsol, [f2(t),f4(t)], 0..100,thickness=2,refine=1);
odeplot(dsol, [f2(t),diff(f4(t),t)], 0..100,thickness=2,refine=1);
odeplot(dsol, [f2(t),f4(t),diff(f4(t),t)], 0..100,thickness=2,axes=boxed,refine=1);

#Second example

dsol(parameters=[r=1,c=1,G=1,M=1,theta=90,f1p0=.2,f4p0=1]);
dsol(80);

#Here you get the error message:

dsol(80);
Error, (in dsol) cannot evaluate the solution further right of 78.216979, probably a singularity
#And you can see why by doing:
dsol(last);

#and you can plot the graph of df1/dt:

odeplot(dsol,[t,diff(f1(t),t)],0..78.2);

It is the latter result which is compact, not the former :-)

@MapleFans001 

After replacing the last equation's Diff(f3(t),t,t) by Diff(f4(t),t,t) and changing the initial conditions so that you don't get the trivial zero solution, e.g. to

ic := {f1(0)=0, f2(0)=0, f3(0)=0, f4(0)=0, D(f1)(0)=0, D(f2)(0)=0, D(f3)(0)=0,D(f4)(0)=1};

you can do:

dsol := dsolve(ex1 union ic, numeric);
dsol(3);
with(plots):
#Graphs of all 4:
odeplot(dsol, [seq([t, cat(f,i)(t)],i=1..4)], 0..100,thickness=2);

#f4 versus f2:
odeplot(dsol, [f2(t),f4(t)], 0..100,thickness=2);

#diff(f4(t),t) versus f2:

odeplot(dsol, [f2(t),diff(f4(t),t)], 0..100,thickness=2);
# 3-dim:

odeplot(dsol, [f2(t),f4(t),diff(f4(t),t)], 0..100,thickness=2,axes=boxed);

You don't need to use phaseportrait, and notice that the help page for phaseportrait (and DEplot) says that it requires "a list or set of first order ordinary differential equations, or a single differential equation of any order".

@MapleFans001 

After replacing the last equation's Diff(f3(t),t,t) by Diff(f4(t),t,t) and changing the initial conditions so that you don't get the trivial zero solution, e.g. to

ic := {f1(0)=0, f2(0)=0, f3(0)=0, f4(0)=0, D(f1)(0)=0, D(f2)(0)=0, D(f3)(0)=0,D(f4)(0)=1};

you can do:

dsol := dsolve(ex1 union ic, numeric);
dsol(3);
with(plots):
#Graphs of all 4:
odeplot(dsol, [seq([t, cat(f,i)(t)],i=1..4)], 0..100,thickness=2);

#f4 versus f2:
odeplot(dsol, [f2(t),f4(t)], 0..100,thickness=2);

#diff(f4(t),t) versus f2:

odeplot(dsol, [f2(t),diff(f4(t),t)], 0..100,thickness=2);
# 3-dim:

odeplot(dsol, [f2(t),f4(t),diff(f4(t),t)], 0..100,thickness=2,axes=boxed);

You don't need to use phaseportrait, and notice that the help page for phaseportrait (and DEplot) says that it requires "a list or set of first order ordinary differential equations, or a single differential equation of any order".

In the first equation there is a variable t1 which should be t and an f that perhaps should be f1?

Diff(f1(t), t$2)
+ 2*(-G*M/(r*(-r*c^2+2*G*M)))*Diff(f(t), t1)*Diff(f2(t), t) = 0

Besides that, are your equations correct? Should the last equation have Diff(f4(t),t,t) instead of Diff(f3(t),t,t)?

(Did you mean Pi/2 instead of 90 for theta?)

If you provide us with the function in question then you are more likely to get useful answers.

First 205 206 207 208 209 210 211 Last Page 207 of 225