Preben Alsholm

13703 Reputation

22 Badges

20 years, 141 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

Actually no assumptions are needed:
 

#But this is a solution
SOL:=y(x)=2*arctan(1+x)+Pi/2;
odetest(SOL,[ode,ic]) ;

 

@Mathrookie94 I played a little with it. Notice that the exponential terms in sol like exp(17/2500 - 17/2500*x)
can be split since exp(x+y)=exp(x)*exp(y):
Thus we can do:

expand(sol);
evalf(%);

You will see that the constant part exp(17/2500) becomes just a float.
You get
f(x) = 426.8577244 + 300.733958*exp(-0.006800000000*x) - 48.5791876*exp(-0.01020000000*x) - 620.5737973*exp(-0.003400000000*x)

Please upload a worksheet instead of or in addition to a screenshot.

Go to the fat green uparrow in the editor you use to post questions, answers, or replies.

I have seen other cases where it pays to consider a more general version.
Anyway, here are two animations in b. The first shows that of the 2 solutions found only the second solves the equation on some interval.
 

restart;
sol:=int(1/sqrt(sin(y)),y);
solve(sol=x+b,y):
res:={%};
numelems(res); #2
res1b:=simplify(eval(sol-x-b,y=res[1]));
res2b:=simplify(eval(sol-x-b,y=res[2]));
plots:-animate(plot,[res1b,x=-10..10],b=-5..5,trace=24);
plots:-animate(plot,[res2b,x=-10..10],b=-5..5,trace=24);

Here is an image of the end of animation 2:

@charlie_fcl I only had to fight to get rid of the .txt in maple.ini.txt.

When I did your worksheets ran.

@charlie_fcl Yes, but there are significant changes made in Maple 2024.

Is rtable_alias documented anywhere?

@Mathrookie94 You only have to do this:

DEtools:-DEplot(ODE,y(t),t=0..350,[y(0)=449],y=0..2000);

where ODE is:

ODE := diff(y(t), t) = -0.000032229*y(t)^2 + 0.065843*y(t) - 15.103;

Obviously, if you have another ode you will want to change the numbers in the first line.
Thus t=0..350, [y(0)=449], and y=0..2000 may be different.
If the dependent variable isn't y(t), but say x(s), you will have to change t to s and y to x.
Here is an example:

restart;
ode:=diff(x(s),s) = -(1 - 2*x(s))*(1 - x(s))*x(s);
#There are 3 constant solutions: x(s) = 0, x(s)=1/2, and x(s) = 1.
#They make the right hand side of ode equal to zero.
#The 3 constant solution and 4 other solutions are plotted here:
DEtools:-DEplot(ode,x(s),s=0..8,
   [x(0)=0,x(0)=1/2,x(0)=1,x(0)=-1/2,x(0)=1/4,x(0)=3/4,x(0)=3/2],x=-1/2..3/2);

Since you are able to use pointplot right after restart, i.e. you don't need plots:-pointplot, you must have a maple.ini file or some start up code.

So what is in that?

@mmcdara I agree.  In fact why should Maple do anything to 1h and 5 min. I myself like that better than 65 min.

@nm Very nice. I would, however, add one requirement:
 

if not has(eq,diff) or not T::`+` or not has(eq,yx) then return eq end if;

Your test case number 2 isn't an ode in y(x) so ought not be handled as such in my view.

The same can be written:

if not ( has(eq,diff) and T::`+` and has(eq,yx) ) then return eq end if;

@nm Number 3 and number 9 work as expected since the very first line in q:

if not has(eq,diff) then return eq end if;

makes those return unevaluated.
Number 7, however, certainly shows a weakness that should be handled.

@nm Thanks for making these points.
The first corrects a silly mistake on my part.
The second point is more tricky.
Here is an attempt:

p:=proc(eq::equation,{known::function:=NULL}) local d,fu,res;
  if not has(eq,diff) then return eq end if;
  d:=indets(indets(eq,specfunc(diff)),function) minus {known};
  fu:=op(remove(has,d,diff));
  if numelems({fu})>1 and known=NULL then 
    error "%1 has derivatives of more than one function. Use a second argument: known=function",eq end if;
  res:=selectremove(has,(lhs-rhs)(eq),fu);
  res[1]=-res[2]  
end proc:
########################
pde:=diff(u(x, t), t, t) + 3 + 2*diff(u(x, t), t) + 4*t + x^2 + x^3/3 + diff(u(x, t), t, x, x) + diff(u(x, t), x, x, x, x) = x*t^2;
ode:=y(x)+diff(y(x),x$2)+x=sin(x);
ode1:=y(x)+diff(y(x),x$2)+diff(f(x),x)=sin(x);
########
p(ode);
p(pde);
p(ode1);
p(ode1,known=f(x));

A much easier solution is to require a second argument, the function to solve for.

q:=proc(eq::equation,yx::function) local res;
  if not has(eq,diff) then return eq end if;
  res:=selectremove(has,(lhs-rhs)(eq),yx);
  res[1]=-res[2]  
end proc:
q(ode,y(x));
q(ode1,y(x));
q(pde,u(x,t));


 

For the fun of it I changed the ode's right hand side to 1/sqrt(Pi):

ode1:=diff(y(x),x)+x*y(x)=1/sqrt(Pi);
dsolve(ode1); # No Pi
ic:=y(0)=0;
Student:-ODEs:-ODESteps([ode1,ic])

That works fine.

@Carl Love Thanks Carl. I will use that too from now on.

@acer Thank you acer.

1 2 3 4 5 6 7 Last Page 3 of 230