Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@Wang Gaoteng I think Robert means 4*arctan(x) - 4*x/(1+x^2) (the original expression), when he talks of the numerical difficulties.

To find the order of the zero at x = 0 you can use taylor:

taylor(4*arctan(x) - 4*x/(1+x^2),x=0);

which results in (8/3)*x^3-(16/5)*x^5+O(x^6).

NextZero has problems in this case, fsolve does not.

That x = 0 is the only zero follows from the result of an integration by parts using that arctan(x) = Int(1/(1+t^2),t=0..x):

IntegrationTools:-Parts(Int(1/(1+t^2),t=0..x),1/(1+t^2)):  
map(simplify,%);

with result x/(1+x^2)+2*(Int(t^2/(1+t^2)^2, t = 0 .. x))

The last term is positive for x > 0. Thus u(x) = 4*arctan(x) - 4*x/(1+x^2) > 0 for x > 0.

Since u is odd, we get u(x) < 0 for x <0.

@Wang Gaoteng I think Robert means 4*arctan(x) - 4*x/(1+x^2) (the original expression), when he talks of the numerical difficulties.

To find the order of the zero at x = 0 you can use taylor:

taylor(4*arctan(x) - 4*x/(1+x^2),x=0);

which results in (8/3)*x^3-(16/5)*x^5+O(x^6).

NextZero has problems in this case, fsolve does not.

That x = 0 is the only zero follows from the result of an integration by parts using that arctan(x) = Int(1/(1+t^2),t=0..x):

IntegrationTools:-Parts(Int(1/(1+t^2),t=0..x),1/(1+t^2)):  
map(simplify,%);

with result x/(1+x^2)+2*(Int(t^2/(1+t^2)^2, t = 0 .. x))

The last term is positive for x > 0. Thus u(x) = 4*arctan(x) - 4*x/(1+x^2) > 0 for x > 0.

Since u is odd, we get u(x) < 0 for x <0.

Thank you Robert, for catching my mistake of equating points computed with points plotted in DEplot.

Thank you Robert, for catching my mistake of equating points computed with points plotted in DEplot.

As always it is best to present the actual problem concretely. If necessary (because of size) by uploading a worksheet.

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);

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