Preben Alsholm

13728 Reputation

22 Badges

20 years, 247 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

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

If I count correctly then there are 6*nn + (nk+1)*Q variables and the same number of equations.

In order to use GenerateMatrix you need nn, nk, and Q to be positive integers, and you should replace Sum by sum (using value e.g.) or replace Sum by add.

If I count correctly then there are 6*nn + (nk+1)*Q variables and the same number of equations.

In order to use GenerateMatrix you need nn, nk, and Q to be positive integers, and you should replace Sum by sum (using value e.g.) or replace Sum by add.

But the problem was the type check. So if that is added then you still need '',

x := (i::integer) -> i^2:
sum(x(m), m=1..3);
sum('x(m)', m=1..3);

But the problem was the type check. So if that is added then you still need '',

x := (i::integer) -> i^2:
sum(x(m), m=1..3);
sum('x(m)', m=1..3);

First 211 212 213 214 215 216 217 Last Page 213 of 230