nm

8552 Reputation

19 Badges

12 years, 353 days

MaplePrimes Activity


These are questions asked by nm

Any one knows of a way to have Maple verify that this solution of the ODE is correct?

restart;
ode:=diff(y(x),x)=x*(y(x)^2-1)^(2/3);
sol:=dsolve(ode);
odetest(sol,ode);

gives

-4*x*y(x)^2*hypergeom([3/2, 5/3], [5/2], y(x)^2)*(y(x)^2 - 1)^(2/3)*signum(y(x)^2 - 1)^(1/3) - 9*x*hypergeom([1/2, 2/3], [3/2], y(x)^2)*(y(x)^2 - 1)^(2/3)*signum(y(x)^2 - 1)^(1/3) - 9*x*(-signum(y(x)^2 - 1))^(1/3)

Tried different simplications, but can't get zero.

For reference, this is Mathematica's solution and it verifies it:

Using Maple 2022.1 on windows 10.

I do not remember now if this was asked before. Doing search here is hard. 

But I am trying this now on 2022.1 and this gives FAIL.

What is the correct syntax to use odetest to verify solution to ode using series method with expansion around infinity? Why do I get FAIL here?
 

interface(version)

`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1257 and is the same as the version installed in this computer, created 2022, June 22, 16:27 hours Pacific Time.`

restart;

ode:=x^3*diff(y(x),x$2)+x^2*diff(y(x),x)+y(x)=0;
sol:=dsolve(ode,y(x),'series',x=infinity);
odetest(sol,ode,'series','point'=infinity)

x^3*(diff(diff(y(x), x), x))+x^2*(diff(y(x), x))+y(x) = 0

y(x) = _C1*(1-1/x+(1/4)/x^2-(1/36)/x^3+(1/576)/x^4-(1/14400)/x^5+O(1/x^6))+_C2*(ln(1/x)*(1-1/x+(1/4)/x^2-(1/36)/x^3+(1/576)/x^4-(1/14400)/x^5+O(1/x^6))+2/x-(3/4)/x^2+(11/108)/x^3-(25/3456)/x^4+(137/432000)/x^5+O(1/x^6))

Warning, unable to compute series necessary to test the given solution

FAIL

 


 

Download odetest_series.mw

Update

I've testsed methods given below on 6 random ode's using Maple odetest, VV method and Axel method. THis is the result obtained using Maple 2022.1 

odetest was able to verify the solution zero out of 6 times.
VV method was able to verify the solution 3 out of 6 times.
Axel method was able to verify the solution 5 out of 6 times.

So based on this small test, Axel method seems to do the best. Attached worksheet. I will use this method to verify my series solution to ode's instead of Maple's odetest but will use Maple's odetest for non-series method solutions.


 

interface(version);

`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1257 and is the same as the version installed in this computer, created 2022, June 22, 16:27 hours Pacific Time.`

restart;

Example 1  Regular singular point. Complex roots

 

Order:=6;
ode:=sin(x)*diff(y(x),x$2)+cos(x)*diff(y(x),x)+1/x*y(x)=0;
sol:=dsolve(ode,y(x),type='series',x=0)

6

sin(x)*(diff(diff(y(x), x), x))+cos(x)*(diff(y(x), x))+y(x)/x = 0

y(x) = _C1*x^(-I)*(series(1+(1/48-(1/16)*I)*x^2+(1/57600-(217/57600)*I)*x^4+O(x^6),x,6))+_C2*x^I*(series(1+(1/48+(1/16)*I)*x^2+(1/57600+(217/57600)*I)*x^4+O(x^6),x,6))

VV method

 

odetest(sol,ode):
asympt(%,x);

Error, (in asympt) unable to compute series

odetest method

 

odetest(sol,ode,'series','point'=0);

y(x) = _C1*x^(-I)*(series(1+(1/48-(1/16)*I)*x^2+(1/57600-(217/57600)*I)*x^4+O(x^6),x,6))+_C2*x^I*(series(1+(1/48+(1/16)*I)*x^2+(1/57600+(217/57600)*I)*x^4+O(x^6),x,6))

y(t) = _C1*t^(-I)*(series(1+(1/48-(1/16)*I)*t^2+(1/57600-(217/57600)*I)*t^4+O(t^6),t,6))+_C2*t^I*(series(1+(1/48+(1/16)*I)*t^2+(1/57600+(217/57600)*I)*t^4+O(t^6),t,6))

Axel method

 

rhs(sol):
Y:= unapply(%, x):
eval(lhs(ode), y=Y):
MultiSeries:-asympt(%, x):
convert(%,polynom);

0

Example 2 Regular singular point. Dierence is integer

 

Order:=6;
ode:=sin(x)*diff(y(x),x$2)+cos(x)*y(x)=0;
sol:=dsolve(ode,y(x),type='series',x=0):

6

sin(x)*(diff(diff(y(x), x), x))+cos(x)*y(x) = 0

VV method

 

odetest(sol,ode):
asympt(%,x);
convert(%,polynom);

O(x^7)

0

odetest method

 

odetest(sol,ode,'series','point'=0);

Warning, unable to compute series necessary to test the given solution

FAIL

y(t) = _C1*t^(-I)*(series(1+(1/48-(1/16)*I)*t^2+(1/57600-(217/57600)*I)*t^4+O(t^6),t,6))+_C2*t^I*(series(1+(1/48+(1/16)*I)*t^2+(1/57600+(217/57600)*I)*t^4+O(t^6),t,6))

Axel method

   

rhs(sol):
Y:= unapply(%, x):
eval(lhs(ode), y=Y):
MultiSeries:-asympt(%, x):
convert(%,polynom);

0

Example 3 Regular singular point. Repeated root

 

Order:=6;
ode:=(exp(x)-1)*diff(y(x),x$2)+exp(x)*diff(y(x),x)+y(x)=0;
sol:=dsolve(ode,y(x),type='series',x=0):

6

(exp(x)-1)*(diff(diff(y(x), x), x))+exp(x)*(diff(y(x), x))+y(x) = 0

VV method

 

odetest(sol,ode):
asympt(%,x):
convert(%,polynom);

0

odetest method

 

odetest(sol,ode,'series','point'=0);

Warning, unable to compute series necessary to test the given solution

FAIL

y(t) = _C1*t^(-I)*(series(1+(1/48-(1/16)*I)*t^2+(1/57600-(217/57600)*I)*t^4+O(t^6),t,6))+_C2*t^I*(series(1+(1/48+(1/16)*I)*t^2+(1/57600+(217/57600)*I)*t^4+O(t^6),t,6))

Axel method

   

rhs(sol):
Y:= unapply(%, x):
eval(lhs(ode), y=Y):
MultiSeries:-asympt(%, x):
convert(%,polynom);

0

Example 4 Regular singular point. Repeated root

 

Order:=6;  
ode:=(exp(x)-1)*diff(y(x),x$2)+exp(x)*diff(y(x),x)+y(x)=0;
sol:=dsolve(ode,y(x),type='series',x=0):

6

(exp(x)-1)*(diff(diff(y(x), x), x))+exp(x)*(diff(y(x), x))+y(x) = 0

VV method

 

odetest(sol,ode):
asympt(%,x):
convert(%,polynom);

0

odetest method

 

odetest(sol,ode,'series','point'=0);

Warning, unable to compute series necessary to test the given solution

FAIL

y(t) = _C1*t^(-I)*(series(1+(1/48-(1/16)*I)*t^2+(1/57600-(217/57600)*I)*t^4+O(t^6),t,6))+_C2*t^I*(series(1+(1/48+(1/16)*I)*t^2+(1/57600+(217/57600)*I)*t^4+O(t^6),t,6))

Axel method

   

rhs(sol):
Y:= unapply(%, x):
eval(lhs(ode), y=Y):
MultiSeries:-asympt(%, x):
convert(%,polynom);

0

Example 5 . Regular singular point. Complex roots

 

Order:=6;  
ode:=x^3*diff(y(x),x$2)+sin(x^3)*diff(y(x),x)+x*y(x)=0;
sol:=dsolve(ode,y(x),type='series',x=0):

6

x^3*(diff(diff(y(x), x), x))+sin(x^3)*(diff(y(x), x))+x*y(x) = 0

VV method

 

odetest(sol,ode):
asympt(%,x);
#convert(%,polynom);

Error, (in asympt) unable to compute series

odetest method

 

odetest(sol,ode,'series','point'=0);

Error, (in odetest/series) need to determine the sign of I*3^(1/2)

y(t) = _C1*t^(-I)*(series(1+(1/48-(1/16)*I)*t^2+(1/57600-(217/57600)*I)*t^4+O(t^6),t,6))+_C2*t^I*(series(1+(1/48+(1/16)*I)*t^2+(1/57600+(217/57600)*I)*t^4+O(t^6),t,6))

Axel method

   

rhs(sol):
Y:= unapply(%, x):
eval(lhs(ode), y=Y):
MultiSeries:-asympt(%, x):
#convert(%,polynom);

Error, (in MultiSeries:-multiseries) need to determine the sign of -I*3^(1/2)

Example 6 . Regular singular point. Complex roots

 

Order:=6;  
ode:=x^2*diff(y(x),x$2)+x*diff(y(x),x)+(x+1)*y(x)=0;
sol:=dsolve(ode,y(x),type='series',x=0):

6

x^2*(diff(diff(y(x), x), x))+x*(diff(y(x), x))+(x+1)*y(x) = 0

VV method

 

odetest(sol,ode):
asympt(%,x);
#convert(%,polynom);

Error, (in asympt) unable to compute series

odetest method

 

odetest(sol,ode,'series','point'=0);

y(x) = _C1*x^(-I)*(series(1+(-1/5-(2/5)*I)*x+(-1/40+(3/40)*I)*x^2+(3/520-(7/1560)*I)*x^3+(-1/2496+(1/12480)*I)*x^4+(9/603200+(1/361920)*I)*x^5+O(x^6),x,6))+_C2*x^I*(series(1+(-1/5+(2/5)*I)*x+(-1/40-(3/40)*I)*x^2+(3/520+(7/1560)*I)*x^3+(-1/2496-(1/12480)*I)*x^4+(9/603200-(1/361920)*I)*x^5+O(x^6),x,6))

y(t) = _C1*t^(-I)*(series(1+(1/48-(1/16)*I)*t^2+(1/57600-(217/57600)*I)*t^4+O(t^6),t,6))+_C2*t^I*(series(1+(1/48+(1/16)*I)*t^2+(1/57600+(217/57600)*I)*t^4+O(t^6),t,6))

Axel method

   

rhs(sol):
Y:= unapply(%, x):
eval(lhs(ode), y=Y):
MultiSeries:-asympt(%, x):
convert(%,polynom);

0

 

 


 

Download test_new_odetest.mw

 

 

 

I am reading some expressions from file.

In the file, it is written as GAMMA(-1,x). When read into Maple using the read file command, it shows as  1/x*Ei(2,x)

I know these are the same mathematically. But I am translating these expressions to sagemath. in sagemath, Ei only accepts one argument.

Now the translator sees Ei in the input, then it keeps it as Ei as it does not know it was the GAMMA with two arguments,  which gives an error when used by sagemath since sagemath only has the one argument version of Ei.

If Maple would keep GAMMA(-1,x) as is, then the translator will just translate it to gamma(-1,x) which works in sage.

To keep things simple, I was wondering if there an option to tell Maple to keep the input as GAMMA(-1,x) and not rewrite to Ei?

Otherwise I would have to now parse each Ei to see if it is the two argument version or the one argument version, and use gamma  for the 2 argument version to keep sage happy which will complicate things for me. 

expr:=GAMMA(-1,x)

               Ei(2, x)/x

Maple 2022.1

This is the problem: My object is getting large with many private methods.

In non-OOP setup, I could make different modules A,B,C and put relevent methods inside each module.

Now I find I can not do this inside the object. All methods have to be flat and at same level. So I lose the benefit of using different name space for different methods.

It will be easier to explain with a simple example. Lets say I have this now

restart;

A:=module() 
    option object; 
    local name::string:="";  

    export ModuleCopy::static:= proc( self, proto, name::string, $)          
         self:-name := name;
    end proc;

    export process_1::static:=proc(_self,$)
       _self:-process_2();
    end proc;

    local process_2::static:=proc(_self,$)
       print("in process_2 ",_self:-name);
    end proc;

end module; 

The above works by having all methods at same level. I can now do 

o:=Object(A,"me");
o:-process_1()

                  "in process_2 ", "me"

But now as the number of private methods increases I want to put a name space around collection of these for better orgnization, but keep all methods logically as part of the object as before.

I change the above to be

restart;

A:=module() 
    option object; 
    local name::string:="";  

    export ModuleCopy::static:= proc( self, proto, name::string, $)          
         self:-name := name;
    end proc;

    export process_1::static:=proc(_self,$)
       o:-B:-process_2();
    end proc;
    
    #method process_2 is now inside a module. 
    local B::static:=module()
       export process_2::static:=proc(_self,$)
           print("in B:-process_2 ",_self:-name);
       end proc;
    end module;

end module; 

Now

o:=Object(A,"me");
o:-process_1()

Gives an error

Error, (in unknown) invalid input: process_2 uses a 1st argument, _self, which is missing

I tried many different combinations, but nothing works.

So right now I have all methods flat. All at same level. But I do not like this setup. Since I lose the nice modular orgnization I had with using different modules with different methods inside different modules.  

Is there a way to have a module inside an object and call its methods from inside the object as if these method were part of the object private method with only differece is adding the module name in between?

So instead of _self:-foo()  I just change it to  _self:-B:-foo() and have both behave the same way?

In C++, one can use what is called a friend class to do this. 

This is another bizzar behaviour of objects. I created a basic object of type person.  Noticed that after issuing the call copy(object,deep) and not doing anything at all with the result. Just made the call only, then I am not longer able to create new objects of this class. I had to restart the session to be able to create new objects again.

Why?  This seems like something went messy with memory layout. I put a print message in the constructor, and see that this message no longer show up  after the call copy(object,deep) even though this call was not used for any purpose as you see, but to only to see its effect on the session.

Any explanation why one can no longer create new objects after doing this?  Here is the workseet


 

interface(version)

`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

restart;

person:=module()
    option object;
    export name::string:="";  

    export ModuleCopy::static:=proc(_self,proto, name::string, $)
      print("Enter constructor of person");
      _self:-name := name;
    end proc;
end module;

_m2370471750336

p1:=Object(person,"me");
p1:-name;
do_not_care := copy(p1,deep);  

"Enter constructor of person"

_m2370557462816

"me"

_m2370557440576

p2:=Object(person,"me");  #WHy constructor no long called?
p2:-name;   #this no longer work.

_m2370556941056

""

p3:=Object(person,"me");  #WHy constructor no long called?
p3:-name;   #this no longer work.

_m2370556932032

""

restart;  #had to call restart to fix things.

person:=module()
    option object;
    export name::string:="";  

    export ModuleCopy::static:=proc(_self,proto, name::string, $)
      print("Enter constructor of person");
      _self:-name := name;
    end proc;
end module;

_m2370471750336

p4:=Object(person,"me");  #now it works again
p4:-name;   

"Enter constructor of person"

_m2370557462816

"me"

 


 

Download deep_call_problem.mw

First 33 34 35 36 37 38 39 Last Page 35 of 164