Preben Alsholm

13663 Reputation

22 Badges

19 years, 350 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

In your 2D-math you have a space between assume and (a>0 ). In 2D-math input that space is interpreted as multiplication.
So remove the space.
Furthermore, you are making assumptions on a twice. They need to be in the same call to assume:
assume(a>0,a<1);
See ?assume, where it says:
"When the assume function is used to make an assumption about an expression x, all previous assumptions on x are removed."

There are more syntactical problems, e.g. that a loop cannot run unless the upper limit (here N) is concrete.

@Kitonum plot uses numerical integration thus never sees the symbolict result.

Compare to:
 

G:=int(eval(sqrt(1+((k*Pi)/l*cos((Pi*x)/l))^2),{k=2,l=2}), x);
plot(G, x=0..6,discont=true);

From G you can construct a differentiable (thus continuous) F using piecewise:
 

L:=limit(G,x=2,left);
R:=limit(G,x=2,right);
F:=piecewise(x<2,G,x=2,L,x<4,G+L-R,x=4,2*L-R,x<6,G+2*(L-R),x=6,2*(L-R)+L);
plot(F, x=0..6);

 

Then check:

diff(F,x) assuming x<6;
simplify(%-eval(sqrt(1+((k*Pi)/l*cos((Pi*x)/l))^2),{k=2,l=2}));  # 0

@amirhadiz Using dsolve/numeric with the parameters option is better than using your current approach.
Here is what you can do:
 

restart;
ode12:=
   {-0.1*a*diff(u(z),z,z) + 
     (z-2*diff(v(z)^(-1/2),z))*diff(u(z),z)+(3-2*b*diff(v(z)^(-1/2),z,z))*u(z)= 0, 0.1*diff(v(z),z,z)+0.01*z*a*diff(v(z),z)+0.02*v(z)-u(z)*b*v(z)^(1/2)=0,u(0)=c0, v(0)=0.1, D(u)(0)=c1, D(v)(0)=0};
sol:=dsolve(ode12, numeric,parameters=[a,b,c0,c1]);
sol(parameters=[1,1,0,1]); # Setting parameters
sol(1);
lastexception;
lastexception[-1];
plots:-odeplot(sol,[z,u(z)],0..0.25);
FindSingularity:= proc(params::list(realcons), max::realcons)
     sol(parameters=params);
     try sol(max)
     catch "cannot evaluate the solution further": 
          return lastexception[-1]
     end try;
     FAIL
end proc:

FindSingularity([1,1,0,1], 4);
FindSingularity([3,2,0,-1], 4);
## I would prefer not to assign to a and b. They are names appearing in dsolve.
## Thus I use aa and bb below:
for aa from 0.1 by 0.1 to 1 do
  for bb from -1 by 0.1 to 1 do 
    print(a=aa, b=bb, `singularity at` = FindSingularity([aa,bb,0,1],5))
  end do
end do;

In the loops above c0 = 0, c1 = 1 as you see.

Since I cannot reproduce the behavior you describe in any version of Maple that I have checked, I think you should tell us which version (release) you are using.

@vv  I tried doing rsolve({req, x(1)=1}, x, makeproc);   in the first worksheet by acer.

But I hadn't noticed that you used a different name (req) than his (eqa) for the recurrence relation.

What I got surprised me:  {req = 0, x(1) = 1}, x, makeproc

I was expecting either an error or a return unevaluated.
The call is sent to `rsolve/makeproc`, which returns unevaluated, but then rsolve itself strips rsolve from the result (called solution):
return op(solution)

 

@Jan Jensen I should point out the worst problem with the exact solution: It doesn't satisfy the initial condition given x(0) = 0, and yet odetest claims that it does:
 

sol3:=dsolve({eval(ode,{k=1,a=1,b=3}),x(0)=0});
eval(sol3,{t=0,x(t)=0});
evalf(%); # 0. = 2.664536887
odetest(sol3,[eval(ode,{k=1,a=1,b=3}),x(0)=0]); # [0,0]

The [0,0] from odetest means that (1) the ode is satisfies and (2) the initial condition is.

The blame is probably to be put on solve (not really dsolve).

@Jan Jensen To get the same use the option implicit in dsolve:
 

restart;
ode := diff(x(t), t) = k*(a - x(t))*(b - 2*x(t))^2;
sol:=dsolve(ode,implicit);
eval(sol,{t=0,x(t)=0});
solve(%,{_C1});
sol1:=eval(sol,%);
sol2:=op(solve(sol1,{x(t)}));

There are problems with this approach in this case as you will find out (or have already).

So I suggest solving numerically:
 

res:=dsolve({ode,x(0)=c},numeric,parameters=[a,b,c,k]);
res(parameters=[1,3,0,1]);
plots:-odeplot(res,[t,x(t)],0..10);
res(parameters=[a=1,k=1,b=3,c=1.1]); # In this form the order is irrelevant
plots:-odeplot(res,[[t,x(t)],[t,1]],0..10,view=0..1.5,color=["Green",blue]);
Q:=proc(a,b,c,k,R::range(realcons):=0..10) if not [a,b,c,k]::list(realcons) then return 'procname(_passed)' end if;
   res('parameters'=[a,b,c,k]);
   plots:-odeplot(res,[[t,x(t)],[t,a],[t,b/2]],R,_rest)
end proc;
plots:-animate(c->Q(1,3,c,1),[c],c=0..3);
plots:-animate(c->Q(1,3,c,1),[c],c=0..3,trace=24);

@vv Thank you, this is very interesting. I shall keep looking into this.

@Carl Love Your statement, " Operations between exact rationals get done first. " confuses me.

Consider the results of the following sums.
 

restart;
Digits:=10:
(10^12+1e-12)-10^12; # 0.
10^12+(1e-12-10^12); # 0.
10^12+1e-12-10^12;   # 0.
10^12-10^12+1e-12;   # 1e-12
'10^12-10^12+1e-12'; # 1e-12
'10^12+1e-12-10^12'; # 0.
restart;
Digits:=10:
a:=10^12:
f:=1e-12:
(a+f)-a; # 0.
a+(f-a); # 0.
a+f-a;   # 0.
a-a+f;   # 1e-12
'a-a+f'; # f
'a+f-a'; # f
%;       # 1e-12

If operations between exact rationals were done first then we should be getting 1e-12 (or f) in all the cases or what?

I must be misunderstanding you.

@Axel Vogt You wrote:
NB: For me the following is a bug:

evalf[2](1014 - 1007);

                                 7.

But automatic simplification kicks in before evalf can do anything.
 

'1014 - 1007';
                               7

evalf[2]('1014 - 1007');
                               7.

Thus this is not a bug. (The same with floats instead).

With m=1 adding the general dsolve option event_doublecross=1e-8 (or whatever) appears to help.

See ?dsolve, events under Event triggering (details).

In the proces of downloading your file Maple 2019.2.1 came up with a window with the title:
"Recover Corrupt File and Save As".

It suggested a name having the number 1 attached to your file's name.

That froze Maple. I had to use Ctrl+Alt+Del to shut down Maple.

I did this once again and the same thing happened.

Trying to load the "recovered" file had the same effect.

PS. It is safe to open your original file as well as the "recovered" file in a text editor like NotePad.

Your file takes up 13023 KB; the "recovered" takes up 5574 KB.

It would be an oddity if two keyword arguments both had effect as is implied in your display example.

In the help page "Argument Processing" under "Keyword Matching" we find the statement:

"Whenever a matching keyword parameter is encountered, the right-hand side of the equation becomes the value for that parameter, and the equation is removed from further consideration as an argument. If more than one keyword argument matches a keyword parameter, only the last one takes effect."

This is taken from Maple 2019.

I tried the following 3 different display versions:
 

with(plots):
setoptions3d(style=patchnogrid,projection=.9):
a:=plot3d(-x^2-y^2-x*y,x=-1..1,y=-1..1,color=[.5,.9,.9],grid=[15,15]):
b:=n->display(a,orientation=[n,60]):
####
display([seq(b(10*n),n=0..35)],light=[90,-80,1,.2,.1],light=[90,40,1,.5,.8],insequence=true);
display([seq(b(10*n),n=0..35)],light=[90,40,1,.5,.8],insequence=true);
display([seq(b(10*n),n=0..35)],light=[90,-80,1,.2,.1],insequence=true);

In Maple 2019 the first two outputs were identical so follows the rule as explained in the passage I quoted above.

In Maple 8, however, all three outputs were clearly different.

@ecterrab I observed the following behavior when trying to install Physics Updates 426 and  428 from the cloud.

Downloading finished, but installing didn't seem to ever finish. In both cases I ended up closing Maple.

After opening again it appeared in both cases that the update was installed.
It would be more comforting if the window would report "Finished" or equivalent.

@dharr In Maple 12 I tried your code. The only problem came from writedata since cat(currentdir(),"/testfile.txt" )

came up with "C:\Program Files\Maple 12/testfile.txt".

First 31 32 33 34 35 36 37 Last Page 33 of 229