nm

11353 Reputation

20 Badges

13 years, 19 days

MaplePrimes Activity


These are questions asked by nm

Fyi, there seems to be some problem here

Maple 2020.2 with Physics 897

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)^(2/3))*(D(y))(x) = 0;
timelimit(30,solve(eq,y(x)));

 

Full screen shot:

 



Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/solve_error.mw .
 

Download solve_error.mw

When doing solve(res,x); maple returns back x

Does this means the equation is true for any x?

Also, doing PDEtools:-Solve(res,x) returns nothing.

I was trying to check if my solution is valid for an ode, and I obtained res above is what odetest() gives back, I wanted to find for what could res be zero.

Here is the code

restart;
ode:=diff(y(x),x)=2*sqrt(1+y(x))*cos(x);
my_sol:=y(x)=sin(x)^2+2*sin(x);
res:=odetest(my_sol,ode);
res:=simplify(res)=0;
solve(res,x);

And now 

PDEtools:-Solve(res,x)

gives nothing.

So I am a little confused what is going on. does solve result mean the equation is true for any (I think the solution I have is correct, so may be what this means,  but wanted to make sure, as I do not think I've seen this before)  And if so, why then PDEtools:-Solve did not return the same result.

Maple 2020.2, windows 10, Physics 897

Maple gives solution to equation as RootOf when there is no explicit solution

restart;
eq:=x*sin(x*y)+y+1=0;
sol:=solve(eq,y)

The _Z above, is the variable we wanted to solve for, which is in this example. My question is, why did not Maple give the solution as

sol2:=RootOf(x*sin(_Z*x)+_Z+1)

Which is a little simpler looking. Is the above not the same as what Maple gives?  I just replace by _Z 

Digits:=100;
plot(evalf(sol-sol2),x=0..Pi)

sometimes Maple's solution for an ode is not valid for all x. When I run odetest on the solution, it is not zero.

For the case when the output of odetest contains one csgn(), I am trying to determine if odetest result will become zero, when csgn is +1  or -1. If so, then next look into the argument of csgn and solve for x under this condition and hence find the range of x when the solution is valid.

I wrote the following to do this and check the idea.

I'd like to ask if the Maple experts here can suggest improvement or if there a better way to do this.

The code below works if there is only instance of csgn() in the output of odetest. Which covers almost all the cases I saw so far.

The code first checks if csgn is present in the output of odetest. If so, it then uses indents to pick up the function csgn out. Then uses op to pick its argument. Then uses solve with inquality to find when the argument is either positive or negative. This results in the range of x needed to make odetest zero.

This is just a quick prototype to test the idea. This not the final code I will be using as that will include more checks and be more robust. 

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

So we see odetest did not give zero.  The issue is that I can't just do 

solve(res=0,x)

It does not work.  So that is why I had to look inside as follows:

The goal is to check if when csgn is either +1 or -1, if it will then become zero.

And if so, then also find the range of x which will caused this.  In the above, we see that when 1/(x+1) is +1, then odetest result  will become zero. This means x has to be larger than -1.

Note that this is all done in code, without being able to look at the screen and then decide what to do

if res<>0 then
    if has(res,csgn) then
        if simplify( subsindets(res,csgn(anything),f->1)) = 0 then      
            print("the odetest becomes zero when csgn is POSITIVE");
            Z:=indets(res,specfunc(csgn));
            the_args:=map(x->op(x),Z);
            print("Now solve ",the_args," for x, when the expression is POSTIVE");
            for tmp in the_args do
                result:=solve(tmp>0,x);
                print("the solution is valid for x>", op([1,1],result));
            od;
        else
            if simplify( subsindets(res,csgn(anything),f->-1)) = 0 then      
                print("the odetest becomes zero when csgn is POSITIVE");
                indets(res,specfunc(csgn));
                the_args:=map(x->op(x),Z);
                print("Now solve ",the_args," for x, when the expression is negative");
                for tmp in the_args do
                    result:=solve(tmp<0,x);
                    print("the solution is valid for x<", op([1,1],result));
                od;
            else
                print("give up. Tried when csgn is positive or negative");
            fi;
        fi;
    fi;
fi;

If there is more than one csgn function in the odetest result, it will become much more complicated, since one have to check all combinations to find under which combination odetest will become zero. So for now, I am just doing this only for one case of csgn present.

 

I found small problem in Latex(). When putting solution of ODE inside a Vector, Latex() fails to convert and returns empty vector.

restart;
sol:=[dsolve(diff(diff(y(x),x),x)*y(x) = 1,y(x))];
sol:=convert(sol,Vector);

And now

Latex(sol)


               \left[\begin{array}{c} \\ \end{array}\right]

Empty array. But if not in a Vector, it works

restart;
sol:=[dsolve(diff(diff(y(x),x),x)*y(x) = 1,y(x))];
Latex(sol)

# no problem here ====>

\left[
{\textcolor{gray}{\int}}_{}^{y \! \left(x \right)}\frac{1}{\sqrt{2 \ln \! \left(\mathit{\_a} \right)-2 \mathit{\_C1}}}\textcolor{gray}{d}\mathit{\_a} -x -\mathit{\_C2}
 = 0, 
{\textcolor{gray}{\int}}_{}^{y \! \left(x \right)}-\frac{1}{\sqrt{2 \ln \! \left(\mathit{\_a} \right)-2 \mathit{\_C1}}}\textcolor{gray}{d}\mathit{\_a} -x -\mathit{\_C2}
 = 0\right]

 

This seems to happen on some solutions (may be those with Int because in this other example, it works with Vector):

restart;
sol:=[dsolve(diff(diff(y(x),x),x)*y(x)^2 = 0)];
sol:=convert(sol,Vector);

And now

Latex(sol)

#now it works ===>

\left[\begin{array}{c}y \! \left(x \right)=0 \\y \! \left(x \right)=\mathit{\_C1} x +\mathit{\_C2}  \end{array}\right]

I am using Maple 2020.2 with Physics 897

Edit 1/2/2021

I found another strange problem with Latex conversion related to Vector. If the first entry is y(x)=0 in the vector, then it keeps this, but throws away the rest of the entries in the Vector.

This might be related to the same bug. Not sure. Here is an example

restart;
ode:=(2*cot(x)*diff(y(x),x)*y(x)+diff(y(x),x)^2-y(x)^2 = 0,singsol=all);
sol:=convert([dsolve(ode)],Vector)

Now watch what happens when converting sol to Latex

Latex(sol)

    \left[\begin{array}{c}y \! \left(x \right)=0 \\ \\ \end{array}\right]

Only reason I use Vector() is to display in Latex many solutions on top of each others, so easier to see instead of as a list() where they are all on one line, which might not fit the page.

I need to find an alternative to using Vector to do this. 

First 98 99 100 101 102 103 104 Last Page 100 of 199