nm

12323 Reputation

20 Badges

14 years, 21 days

MaplePrimes Activity


These are replies submitted by nm

@Kitonum 

But I do not know before hand for what possible values of x the result is zero.  That is the whole point of my question. 

I need Maple to tell me that. The assumption x>0 worked in this example. But might not work for other cases. Below is an example where it does not work

Currently actually I try this also myself, but it is a hit and miss.  I trt x>0 and x<0 and so on, until I get solution.

I need Maple to tell me the domain of x which an expression is zero. The only assumption is that x is real.

Example where x>0 assumption do not work

restart;
ode :=diff(y(x),x)=2*(x*sqrt(y(x))-1)*y(x):
ic  :=y(0)=1:
sol :=dsolve([ode,ic]):
res :=odetest(sol,ode);
solve(simplify(res)) assuming x>0

No solution.

But solve(simplify(res)) assuming real works here.

That is what I mean by hit and miss. 

@Kitonum 

"The output of the second example seems to me incorrect:"

I do not see anything wrong with the answer given by Maple. The ode is y(x)+y'(x)=0 and solving for y(x) gives y(x)=-y'(x). Why is this wrong? 

I do not understand at all what is the point of applying the  solve  command to a differential equation

Ok, this is a separate issue really. But I will happy to try to explain why the program does this.

Some ode's have the form of y(x)=f(x,y'(x)).  For example, the Clairaut or d’Alembert (Lagrange) ODE's can be recognized when in this form. An example of  the Clairaut ODE is x*y'(x)-y(x)*y'(x)=1 but to detect if it is Clairaut, the program solves for y(x) and checks if the solution is of the form x*y'(x)+f(y'(x)).  If it is, then it calls the Clairaut ode solver.

https://en.wikipedia.org/wiki/D%27Alembert%27s_equation

An example of d’Alembert ode is (y'(x))^2-1-x-y(x)=0 . To detect it is d’Alembert the program solves for y(x) and checks if the solution of the form x*g(y'(x))+f(y'(x)) where f,g are functions of y'(x). If it is, it calls the d’Alembert ode solver.

This is the reason why the program needs to solve for y(x), as part of determining the type of ODE. 

So it first converts the ODE to D, using the convert() command, before calling solve(), since solve does not work on equation that has both diff(y(x),x) and y(x) in it, but it works after conversion to D.

 

 

@Kitonum 

Thank for the suggestion of possible explanation. But this can not be the correct reason for the error.

I am well aware that one can not have diff(y(x),x) in the equation, and also solve for y(x). This is why I changed the ODE to D(y)(x) before calling solve.

I have been using this same code for over a year now and run my program over many thousands of ODE's, hundreds of times by now, and never saw such an error. This is the first time I see this error.

You could try it yourself. 

restart;
interface(warnlevel=4):
kernelopts('assertlevel'=2):
eq:=exp(x)*sin(y(x))-3*x^2+(exp(x)*cos(y(x))+(1/3)/y(x))*(D(y))(x) = 0;
timelimit(30,solve(eq,y(x)));

No errror. If you like me to post 4,000 more examples I have that does the same thing and give no error, I will be happy to, but one can pick any random ODE and do the same thing, i.e. solve for y(x) after converting the diff to D, and it works.

restart;
interface(warnlevel=4):
kernelopts('assertlevel'=2):
ode:=diff(y(x),x)+y(x)-x=0;
eq:=convert(ode,D);
timelimit(30,solve(eq,y(x)));

If your theory is correct, then could you please explain why it works in the almost 4,000 other ODE's I have in my collection, and been running it for over a year with no error, but it failed on this specific equation I just added last night?

 

This is what I get on 2020.2

Are you sure it is (sin(t)^2)^exp(t) and not (sin(t)^2)*exp(t) ?

Need to use numerical integration. But Maple have hard time with numerical integration when x starts at some points vs. others. 

I tried it in Mathematica, and it can do it for all points (numerically).

May be there are other options to make Maple integrate this numerically. I only tried the basic int command with numeric option. Here is Mathematica result (do not know if it accurate or not)

 

It doesn't seem that Maple has a built-in procedure to construct the syntactic graph of a mathematical expression.
But maybe I'm wrong?

I think you are correct. This is build-in Mathematica. It is called TreeForm

Here is the result applied to your example

It will be useful to have this in Maple as well. Maple's  dismantle is not the same, and it is more like Mathematica's other command called FullForm

@acer 

 Are they the same?

No. The result from Rubi was not automatically simplified optimally. FullSimplify was needed to simplify it more.

@Parham2016 

"there was not the function of InverseJacobiAM, but your second solution did include it."

This is how Maple translated the Mathematica output. 

But if you say you have Mathematica itself allready, why not run Rubi there and see the solution I posted for yourself? You can install Rubi from the here

 

Any way, please find Rubi integrate output below. I just asked Maple to translate it.

Get["Rubi`"]; 
integrand = ((k/2)*x^2 + x + c)/Sqrt[lambda^2*(1 + k*x)^4 - ((k/2)*x^2 + x + c)^2]; 
sol = FullSimplify[Int[integrand, x]]

it gives

-((Sqrt[-4*c^2 + 4*lambda^2*(1 + k*x)^4 - 4*c*x*(2 + k*x) - x^2*(2 + k*x)^2]*(2*Sqrt[-1 + 2*c*k]*(1 - 4*k^2*lambda^2)^(1/4)*(1 + k*x)*
      Sqrt[(k^2*(4*c^2 - 4*lambda^2*(1 + k*x)^4 + 4*c*x*(2 + k*x) + x^2*(2 + k*x)^2))/(-1 + 2*c*k + Sqrt[1 - 4*k^2*lambda^2] + 
          k*Sqrt[1 - 4*k^2*lambda^2]*x*(2 + k*x))^2] + (2 - 4*c*k)*EllipticE[2*ArcTan[((1 - 4*k^2*lambda^2)^(1/4)*(1 + k*x))/Sqrt[-1 + 2*c*k]], 
       (1/2)*(1 - 1/Sqrt[1 - 4*k^2*lambda^2])] + (-1 + 2*c*k)*(1 + Sqrt[1 - 4*k^2*lambda^2])*
      EllipticF[2*ArcTan[((1 - 4*k^2*lambda^2)^(1/4)*(1 + k*x))/Sqrt[-1 + 2*c*k]], (1/2)*(1 - 1/Sqrt[1 - 4*k^2*lambda^2])]))/
   (2*Sqrt[-1 + 2*c*k]*(1 - 4*k^2*lambda^2)^(3/4)*(-1 + 2*c*k + Sqrt[1 - 4*k^2*lambda^2] + k*Sqrt[1 - 4*k^2*lambda^2]*x*(2 + k*x))*
    Sqrt[(k^2*(4*c^2 - 4*lambda^2*(1 + k*x)^4 + 4*c*x*(2 + k*x) + x^2*(2 + k*x)^2))/
      (-1 + 2*c*k + Sqrt[1 - 4*k^2*lambda^2] + k*Sqrt[1 - 4*k^2*lambda^2]*x*(2 + k*x))^2]))

To translate the above to Maple, copy it to your Maplework sheet, and put ` and ` on each side of the expression and then call MmaTranslator on it as shown in the screen shot above. Maple will translate the above Mathematica expression to Maple syntax.

 

@lcz 

Yes, in Mathematica one can do this

ls[[1 ;; -1 ;; 2]]

But same thing is not possible in Maple. At least I could not figure how to do it. One can only take a slice, with increment of one, as in

ls[1..nops(ls)]

But not using different increments, say by 2

ls[1..nops(ls),2]

That is why seq is needed.

 

@lcz 

At the beginning I thought there would be a simple and fast function. Just like mathematica. 

The first Mathematica code from the link you have

Table[a[[i]], {i, 1, le, 2}]

is really the same as the Maple code 

seq(ls[i],i=1..nops(ls),2)

In Mathematica, Table[] is like seq() in Maple.  Notice, you asked for odd and even. The question you linked to asked for just odd. So may be that why the Maple code I posted looked a little longer.

@vv 

"It seems that there is an easy method."

yes. That is easier. This is the method that I wrote down yesterday below.  

@mmcdara 

Thanks for the idea. But it does not work for all case. For example given this

It does not do it:

restart:
expr:=y^2+y^3*sin(x)+3*x*y^(7/2);
convert(expr, horner, y)

But when doing this by hand, we see it can be factored as

proof:

should_be:=y^2*(1+y*sin(x)+3*x*y^(3/2));
expand( should_be )

@Parham2016 

Rubi is a Mathematica package. There is no port for it for Maple at this time. So you need Mathematica to run the above.

Here is the above result in Maple syntax

-sqrt(-4*c^2 + 4*lambda^2*(k*x + 1)^4 - 4*c*x*(k*x + 2) - x^2*(k*x + 2)^2)*(2*sqrt(2*c*k - 1)*(-4*k^2*lambda^2 + 1)^(1/4)*(k*x + 1)*sqrt(k^2*(4*c^2 - 4*lambda^2*(k*x + 1)^4 + 4*c*x*(k*x + 2) + x^2*(k*x + 2)^2)/(-1 + 2*c*k + sqrt(-4*k^2*lambda^2 + 1) + k*sqrt(-4*k^2*lambda^2 + 1)*x*(k*x + 2))^2) + (-4*c*k + 2)*EllipticE(sin(2*arctan((-4*k^2*lambda^2 + 1)^(1/4)*(k*x + 1)/sqrt(2*c*k - 1))), sqrt(1/2 - 1/(2*sqrt(-4*k^2*lambda^2 + 1)))) + (2*c*k - 1)*(1 + sqrt(-4*k^2*lambda^2 + 1))*InverseJacobiAM(2*arctan((-4*k^2*lambda^2 + 1)^(1/4)*(k*x + 1)/sqrt(2*c*k - 1)), sqrt(1/2 - 1/(2*sqrt(-4*k^2*lambda^2 + 1)))))/(2*sqrt(2*c*k - 1)*(-4*k^2*lambda^2 + 1)^(3/4)*(-1 + 2*c*k + sqrt(-4*k^2*lambda^2 + 1) + k*sqrt(-4*k^2*lambda^2 + 1)*x*(k*x + 2))*sqrt(k^2*(4*c^2 - 4*lambda^2*(k*x + 1)^4 + 4*c*x*(k*x + 2) + x^2*(k*x + 2)^2)/(-1 + 2*c*k + sqrt(-4*k^2*lambda^2 + 1) + k*sqrt(-4*k^2*lambda^2 + 1)*x*(k*x + 2))^2))

Rubi gives simplest solution.

 

@Carl Love 

Your first one worked

     foo:= proc(..., {ic::`=`:= ()=()}) ....

I will use this. Thanks. Its default  type is equation, so now I can pass it, and it is still type equation.

But your second choice is not type equation. Maple says it is type expression sequence 

Thanks. Will use the first one you showed. It works for what I need.

restart;
foo:=proc(n::integer, {ic::{`=`, identical()}:= ()})
    print(whattype(ic));
    print(type(ic,`=`));
end proc;

foo(3);

First 47 48 49 50 51 52 53 Last Page 49 of 95