Maple 2022 Questions and Posts

These are Posts and Questions associated with the product, Maple 2022

Dear all, 

I'm trying to enter an equation (Navier-Stokes) in Maple using the Physics[Vectors] package. I am having trouble with the term 

$(u\cdot \nabla) u$

but Maple returns an error when entering the commands :

( u_(t,x,y,z) . %Nabla) u_(t,x,y,z)

I tried other combinations of this without success, like :

( u_(t,x,y,z) . %Nabla)(u_(t,x,y,z))

( u_(t,x,y,z) %. %Nabla) u_(t,x,y,z)

( u_(t,x,y,z) %. %Nabla) (u_(t,x,y,z))

Could you please give me some help with this? 

Hello,
I have a small problem with the display of fraction and x_dot at the same time. 

 

This the exemple :

with(Typesetting);
compactdisplay = flase;
Settings(typesetprime = false);
Settings(typesetdot = true);

diff(1/2*LongExpression*x(t), t);

The Results 

when I choose the typesetting level : Extended. I got this result :

And when I choose the typesetting level : Maple Standrad. I got this result 
        

What I  want to have is mix of both, it mean like this 

I have downloaded Maple and install the trial version , i entered the Purchase code  and every thing was done, I did not get any errors , however, while i am trying to open Maple, when I open the software , I see this window which i have uploaded below , and when i click on Active i eneter my purchase code again , and it says it has acitivated and then when i click ok , it exit , what is the issue ?

can you help me ?

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. 

int(int(x^(alpha + 1)*y^(beta + 1)*exp(-(x^2 + y^2)/(4*Pi))/sqrt(x^2 + y^2), x = -R .. R), y = -R..R) assuming x>0, y>0, R>0;

I am trying to evaluate the above symbolic integral but Maple returns the same input in Symbolic form without evaluating it at all. Is there something wrong with my approach?

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

As I was trying things with Maple OOP, I noticed strange behavior which I do not understand. I'll explain the problem in words first then given an example.

I have Person class. Then made one instance of it. In this class, there is one method which is defined to take in an object of same type as the class itself.

I found when I pass the object itself to its own method, it gives an error that the method expects a second argument of type person which is missing. But it is not missing.

Then when creating a second object of same type, and passing the second object, it worked! 

Why?  Here is MWE. Attached worksheet.  I would have expected same behavior in both cases. EIther both work, or both do not work. As as long as the object being passed is the correct type (person).

It seems in the first case, Maple noticed the object being passed to the method happened to be same object where this method is, and it did not pass it. Hence the missing second argument.  Is this a documented behaviour somewhere? (I made sure to make all method static though, so same code is used by all instances of the class. This is strange error message).
 

interface(version)

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

restart;

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

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

    export process::static:=proc(_self, the_input::person ,$)
       print("in person::process. name = ", the_input:-name);
    end proc;

end module;

_m2370471750496

p:=Object(person,"me");

_m2370557462912

p:-process(p);  #why this fail

Error, invalid input: process uses a 2nd argument, the_input (of type person), which is missing

o:=Object(person,"new_name"); #make new object and try again

_m2370557450944

p:-process(o); #why this OK?

"in person::process. name = ", "new_name"

 


 

Download why_first_call_fail.mw

Update

Ok, I am all set. I found a good way to do this. i.e. pass the object to one of its method. One has to make a copy of the object first and pass the copy. Can't use the same object. This is how I do it now. 

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

     export ModuleCopy::static:= overload( 
     [ 
         proc(_self,proto, $)option overload;
            print("Enter 2 args constructor of person");  
            #do nothing    
         end proc,

         proc(_self,proto, name::string, $) option overload; 
             print("Enter 3 args constructor of person");      
             _self:-name := name;
        end proc
     ]);

    export process::static:=proc(_self, the_input::person,$)
       print("the_input:-name = ",the_input:-name);
    end proc;
    
end module; 


p:=Object(person,"me");
#p:-process(p);  #instead of this do the following
o:=Object(p);
p:-process(o)

Which works and gives

              "Enter 3 args constructor of person"
                  p := Object<<2370600065568>>
              "Enter 2 args constructor of person"
                  o := Object<<2370600048288>>
                   "the_input:-name = ", "me"

So I am now able to pass the object (or rather copy of it) as explicit argument to other methods and other modules.  I am not sure why it does not work when using the object itself and had to make a copy. 

As we know, when every Gi is normal in G, then the series is called a normal series:

cs := CompositionSeries(DihedralGroup(8))

We can draw it:

DrawSubgroupLattice(DihedralGroup(8), labels = ids, highlight = cs)

And all Gi is normal in G:

IsNormal~(cs, DihedralGroup(8))

[true, true, true, true, true]

But why type(cs, 'NormalSeries') will get false.. It is a bug or do I have a misunderstanding?

I am still struggling understanding Maple Object  inheritance due to lack of good examples and sparse documenation.

This is what I am trying to do. I have base class Person, and then make Employee class which extends Person class and adds new field.   

The constructor to the Employee class then needs to call the constructor to the Person class (its base class) in order to initialize it. The base class constuctor takes care of initialization the fields in the base class.

I do not know how to do this. Actually it is not clear to me how the proto argument gets into play in all of this. I could not find one example that explains how to use proto with inheritance.

I am trying to implement this python example. I will show the code for the Python, and my Maple translation. The part I do not know how to do, it how to call the constructor for the base class from the sub class.  If I do not do this, then the fields of the base class will remain unitilized.

Python example is from https://www.geeksforgeeks.org/python-access-parent-class-attribute/

# parent class 
class Person( object ):     
    
        # __init__ is known as the constructor          
        def __init__(self, name, idnumber):    
                self.name = name 
                self.idnumber = idnumber 
                  
        def display(self): 
                print(self.name) 
                print(self.idnumber) 
    
# child class 
class Employee( Person ):            
        def __init__(self, name, idnumber, salary): 
                self.salary = salary 
    
                # invoking the constructor of the parent class  
                #----->>>>> HOW TO DO THIS IN MAPLE?
                Person.__init__(self, name, idnumber)  
          
        def show(self):
            print(self.salary)

# creation of an object
# variable or an instance 
a = Employee('Rahul', 886012, 30000000)     
    
# calling a function of the
# class Person using Employee's
# class instance 
a.display()
a.show() 

Here is the Maple code

restart;
person:=module() 
    option object; 
    #I made these exported instead of local for ease of printing from outside while
    #debugging , that is all.. These should otherwise be local

    export idnumber::integer:=0;  
    export name::string:="";  

    export ModuleCopy::static:= proc( _self, proto, name::string, idnumber::integer, $) 
        _self:-idnumber := idnumber;
        _self:-name := name;
    end proc;
 
end module; 
#---- extend the above class 

employee:=module() 
    option object(person); 
    export salary::integer:=0;  

    ModuleCopy::static:= proc( _self, proto, name::string, idnumber::integer, salary::integer , $) 
        _self:-salary := salary;
        # invoking the constructor of the parent class  
        # How to do that in Maple?

        #I could always manually do this. But I do not want to duplicate the code
        #done by the base class constructor.
        #_self:-name := name;
        #_self:-idnumber := idnumber;
        
    end proc;
 
end module; 

 

How does one do the Python example in Maple?

Someone should write a book on programming using OOP in Maple. I'll buy a copy in advance.

Maple 2022.1

I need to make my base class local variable static, so that when extending the class, the subclass will share these variable and use their current values as set by the base class. If I do not make them static, then the base class when extended, will get fresh instance of these variable, losing their original values, which is not what I want.

To do this, one must make the base class variables static

This works, but now I do not know the syntax where to put the type on the variable. 

I can't write   local m::integer::static; nor local m::static::integer;

I could only write local m::static; but this means I lost the ability to have a type on the variable and lost some of the type checking which is nice to have in Maple. From Maple help:

 

Here is example

restart;

base_class:=module()
  option object;
  local n::static;  #I want this type to ::integer also. But do not know how

  export set_n::static:=proc(_self,n::integer,$)
     _self:-n := n;
  end proc;
  
  export process::static:=proc(_self,$)
    local o;
    o:=Object(sub_class);
    o:-process();
  end proc;
end module;    

sub_class:=module()
   option object(base_class);
   process:=proc(_self,$)
      print("in sub class. _self:-n = ",_self:-n);
   end proc;
end module;

o:=Object(base_class);
o:-set_n(10);
o:-process()


            "in sub class. _self:-n = ", 10

The above is all working OK. I just would like to make n in the base class of type ::integer as well as ::static

Is there a syntax for doing this?

 

The suggested solution in the answer https://mapleprimes.com/questions/234325-Use-Of-self--Inside-Object-Constructor  worked OK in the setup shown in that question.

But it does not work when putting the constructor inside overload

Here is an example where it works (i.e. by removing the type from _self as suggested in the above answer)

restart;

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

    #notice no _self::person, just _self
    export ModuleCopy::static:= proc( _self, proto::person, the_name::string, $ )            
           name:= the_name;
    end proc;

end module;


p:=Object(person,"me")

The above works. But since I have different constructors, once I put the above inside overload, using the same exact syntax, now the error comes back

restart;

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

    export ModuleCopy::static:= overload( 
    [
       proc( _self, proto::person, the_name::string, $ ) option overload;           
           name:= the_name;
      end proc
    ]);

end module;
             

p:=Object(person,"me")

Error, static procedure `ModuleCopy` refers to non-static local or export `name::string` in surrounding scope

I did not expect that using overload will cause any change to how it behaves. Is this a bug?

Below is worksheet also.

interface(version);

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

restart;

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

    export ModuleCopy::static:= proc( _self, proto::person, the_name::string, $ )            
           name:= the_name;
    end proc;

end module;

_m2950059551392

p:=Object(person,"me")

_m2950172920000

restart;

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

    export ModuleCopy::static:= overload(
    [
       proc( _self, proto::person, the_name::string, $ ) option overload;           
           name:= the_name;
      end proc
    ]);

end module;

_m2950059551392

p:=Object(person,"me")

Error, static procedure `ModuleCopy` refers to non-static local or export `name::string` in surrounding scope

 

Download OO_version.mw

I have a set of formulas I saved in a matrix and the exported the matrix to Excel. However when I open the file in Excel the equations are in prefix notation (I think).  That's not exactly human readable friendly.  If I copy and paste straight into excel they are readable.

It there a way to make the Maple export similar?

EDIT:-  I exported as a.csv file because if export as .xlsx    all the equation change into "#NUM!" in the spreadsheed.

restart

NULL

Digits := 5

5

(1)

interface(displayprecision = 5); interface(rtablesize = 30)

5

(2)

cosrule := proc (a, b, c, A) options operator, arrow; a^2 = b^2+c^2-2*b*c*cos(A) end proc

proc (a, b, c, A) options operator, arrow; a^2 = b^2+c^2-2*b*c*cos(A) end proc

(3)

Ang := solve(cosrule(a, b, c, A), A)

Pi-arccos((1/2)*(a^2-b^2-c^2)/(b*c))

(4)

Formulas := Matrix(20, 4)

 

 

 

 

data := [L[1] = 619.35, L[2] = 891.12, pos = 180, tos = 90, x1 = 600, y1 = -800, z1 = 500, x2 = 900, y2 = -200, z2 = 850, `&Theta;t` = 29.34*Pi*(1/180), `&Theta;p` = 53.98*Pi*(1/180)]
 

 

 

 

i := 3

res0 := `&Delta;Z` = z2-z1; Formulas[i, 1] := lhs(res0); Formulas[i, 2] := rhs(res0)

`&Delta;Z` = z2-z1

(5)

res0 := eval(res0, data); Formulas[i, 3] := rhs(res0); Formulas; i := i+1

`&Delta;Z` = 350

(6)

res1 := dt[1] = sqrt(tos^2+L[1]^2); Formulas[i, 1] := lhs(res1); Formulas[i, 2] := rhs(res1); res1 := eval(res1, data); Formulas[i, 3] := rhs(res1); Formulas; i := i+1

dt[1] = 625.85

(7)

NULL

res2 := d[1] = sqrt(pos^2+tos^2+L[1]^2); Formulas[i, 1] := lhs(res2); Formulas[i, 2] := rhs(res2); res2 := eval(res2, data); Formulas[i, 3] := rhs(res2); Formulas; i := i+1

d[1] = 651.22

(8)

res3 := dt[2] = sqrt(tos^2+L[2]^2); Formulas[i, 1] := lhs(res3); Formulas[i, 2] := rhs(res3); res3 := eval(res3, data); Formulas[i, 3] := rhs(res3); Formulas; i := i+1

dt[2] = 895.65

(9)

NULL

res4 := d[2] = sqrt(pos^2+tos^2+L[2]^2); Formulas[i, 1] := lhs(res4); Formulas[i, 2] := rhs(res4); res4 := eval(res4, data); Formulas[i, 3] := rhs(res4); Formulas; i := i+1

d[2] = 913.56

(10)

NULL

res7 := tau = arctan(tos/L[1]); Formulas[i, 1] := lhs(res7); Formulas[i, 2] := rhs(res7); res7 := eval(res7, data); Formulas[i, 3] := rhs(res7); 180*(eval(rhs(`%%`), data))/Pi; Formulas[i, 4] := %; Formulas; i := i+1

8.2678

(11)

NULL

res8 := rho = arctan(tos/L[2]); Formulas[i, 1] := lhs(res8); Formulas[i, 2] := rhs(res8); res8 := eval(res8, data); Formulas[i, 3] := rhs(res8); 180*(eval(rhs(`%%`), data))/Pi; Formulas[i, 4] := %; Formulas; i := i+1; data := [op(data), res0, res1, res2, res3, res4, res7, res8]

5.7674

(12)

NULL

res9 := alpha = `&Theta;t`+tau-rho; Formulas[i, 1] := lhs(res9); Formulas[i, 2] := rhs(res9); res9 := eval(res9, data); Formulas[i, 3] := rhs(res9); 180*(eval(rhs(`%%`), data))/Pi; Formulas[i, 4] := %; Formulas; i := i+1; data := [op(data), res9]

31.840

(13)

NULL

NULL

NULL

res10 := dt[3] = solve(cosrule(dt[3], dt[2], dt[1], alpha), dt[3])[1]; Formulas[i, 1] := lhs(res10); Formulas[i, 2] := rhs(res10); res10 := eval(res10, data); Formulas[i, 3] := rhs(res10); Formulas; i := i+1; data := [op(data), res10]

dt[3] = 491.45

(14)

NULL

NULL

res11 := beta = solve(cosrule(dt[1], dt[2], dt[3], beta), beta); Formulas[i, 1] := lhs(res11); Formulas[i, 2] := rhs(res11); res11 := eval(res11, data); Formulas[i, 3] := rhs(res11); 180*(eval(rhs(`%%`), data))/Pi; Formulas[i, 4] := %; Formulas; i := i+1; data := [op(data), res11]

42.215

(15)

NULL

NULL

NULL

NULL

res12 := Zeta = arccos(`&Delta;Z`/dt[3]); Formulas[i, 1] := lhs(res12); Formulas[i, 2] := rhs(res12); res12 := eval(res12, data); Formulas[i, 3] := rhs(res12); 180*(eval(rhs(`%%`), data))/Pi; Formulas[i, 4] := %; Formulas; i := i+1; data := [op(data), res12]

44.588

(16)

NULL

NULL

res13 := dt[4] = dt[3]*sin(Zeta); Formulas[i, 1] := lhs(res13); Formulas[i, 2] := rhs(res13); res13 := eval(res13, data); Formulas[i, 3] := rhs(res13); Formulas; i := i+1; data := [op(data), res13]

Matrix(%id = 36893490716944981036)

(17)

 

``

NULL

``

NULL

currentdir()

"C:\Users\Ronan\Documents\MAPLE\A & Q Maple primes"

(18)

NULL

with(ExcelTools)

[Export, Import, WorkbookData]

(19)

NULLExport(Formulas, "Frmls.csv")NULL

Download test_eqn_export.mw

I noticed in object constructor I had to write  _self:-name  to refer to object own variable called name.  But inside a another proc I can use just name without having to add _self:- to it. It also works when adding _self:-

Is this becuase constructor is special proc, and the object is not yet full constructed?  Here is a MWE

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

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

           #Why this fails here, but not in process proc? Is it because of special
           #case since done inside constructor?
           #print(name); 

           print(_self:-name);
    end proc;
 
   export process::static :=proc(_self,$)
     #here both cases work
     print(_self:-name);
     print(name);
   end proc;

end module;

#and now

p:=Object(person,"me")

The above works. But if I uncomment #print(name); inside the constructor, maple gives error

p:=Object(person,"me")
Error, static procedure `ModuleCopy` refers to non-static local or export `name::string` in surrounding scope

But this works with no error

p:-process()

                              "me"
                              "me"

But no such error when doing same thing inside a local static proc inside same module.

Is this special just for the constructor than one must use :-self ? Just wanted to make sure.

Maple 2022.1

Hi.

What wrong could be there with the color line?

restart:

with(plots):

equ1 := BesselJ(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4) + BesselY(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4):

equ2 := BesselJ(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4) + 5*BesselY(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4):

equ3 := BesselJ(sqrt(17)/2, 10*sqrt(t))/t^(1/4) + 5*BesselY(sqrt(17)/2, 10*sqrt(t))/t^(1/4):

tmax   := 30:
colors := ["Red", "Violet", "Blue"]:

p1 := plot([equ1, equ2, equ3], t = 0 .. tmax, labels = [t, T[2](t)], tickmarks = [0, 0], labelfont = [TIMES, ITALIC, 12], axes = boxed, color = colors):

ymin := min(op~(1, op~(2, op~(2, [plottools:-getdata(p1)])))):
ymax := max(op~(2, op~(2, op~(2, [plottools:-getdata(p1)])))):
dy   := 2*ymax:

legend1 := typeset(C[3] = 1, ` , `, C[4] = 1, ` , `, Omega^2 = 50):
legend2 := typeset(C[3] = 1, ` , `, C[4] = 5, ` , `, Omega^2 = 50):
legend3 := typeset(C[3] = 1, ` , `, C[4] = 5, ` , `, Omega^2 = 25):

p2 := seq(textplot([tmax-2, ymax-k*dy/20, legend||k], align=left), k=1..3):

p3 := seq(plot([[tmax-2, ymax-k*dy/20], [tmax-1, ymax-k*dy/20]], color=colors[k]), k=1..3):
display(p1, p2, p3, view=[default, -ymax..ymax], size=[800, 500])

Error, (in plot) invalid color specification: colors[1]

 

display(p1, p2, p3, view = [default, -ymax .. ymax], size = [800, 500])

(1)

 

Download Legend_Inside.mw

NULL

Loading Student:-ODEs

xi^2*(diff(psi[m](xi), xi, xi))+2*xi*(diff(psi[m](xi), xi))+(xi^2-m*(m+1))*psi[m](xi) = 0

xi^2*(diff(diff(psi[m](xi), xi), xi))+2*xi*(diff(psi[m](xi), xi))+(xi^2-m*(m+1))*psi[m](xi) = 0

(1)

Student:-ODEs:-ODESteps(xi^2*(diff(psi[m](xi), `$`(xi, 2)))+2*xi*(diff(psi[m](xi), xi))+(xi^2-m*(m+1))*psi[m](xi) = 0, psi[m](xi))

"[[,,"Let's solve"],[,,xi^2 (((&DifferentialD;)^2)/(&DifferentialD;xi^2) psi[m](xi))+2 xi ((&DifferentialD;)/(&DifferentialD;xi) psi[m](xi))+(xi^2-m (m+1)) psi[m](xi)=0],["&bullet;",,"Highest derivative means the order of the ODE is" 2],[,,((&DifferentialD;)^2)/(&DifferentialD;xi^2) psi[m](xi)],["&bullet;",,"Isolate 2nd derivative"],[,,((&DifferentialD;)^2)/(&DifferentialD;xi^2) psi[m](xi)=((m^2-xi^2+m) psi[m](xi))/(xi^2)-(2 ((&DifferentialD;)/(&DifferentialD;xi) psi[m](xi)))/xi],["&bullet;",,"Group terms with" psi[m](xi) "on the lhs of the ODE and the rest on the rhs of the ODE; ODE is linear"],[,,((&DifferentialD;)^2)/(&DifferentialD;xi^2) psi[m](xi)+(2 ((&DifferentialD;)/(&DifferentialD;xi) psi[m](xi)))/xi-((m^2-xi^2+m) psi[m](xi))/(xi^2)=0],["&EmptyVerySmallSquare;",,"Check to see if" xi[0]=0 "is a regular singular point"],[,"?","Define functions"],[,,[P[2](xi)=2/xi,P[3](xi)=-(m^2-xi^2+m)/(xi^2)]],[,"?",xi*P[2](xi) "is analytic at" xi=0],[,,([]) ? ()|() ? (xi=0)=2],[,"?",xi^2*P[3](xi) "is analytic at" xi=0],[,,([]) ? ()|() ? (xi=0)=-m^2-m],[,"?",xi=0 "is a regular singular point"],[,,"Check to see if" xi[0]=0 "is a regular singular point"],[,,xi[0]=0],["&bullet;",,"Multiply by denominators"],[,,(-m^2+xi^2-m) psi[m](xi)+2 xi ((&DifferentialD;)/(&DifferentialD;xi) psi[m](xi))+xi^2 (((&DifferentialD;)^2)/(&DifferentialD;xi^2) psi[m](xi))=0],["&bullet;",,"Assume series solution for" psi[m](xi)],[,,psi[m](xi)=(&sum;)a[k] xi^(k+r)],["&EmptyVerySmallSquare;",,"Rewrite ODE with series expansions"],[,"?","Convert" xi^m*psi[m](xi) "to series expansion for" m=0..2],[,,[]=(&sum;)a[k] xi^(k+r+m)],[,"?","Shift index using" k "->" k-m],[,,[]=(&sum;)a[k-m] xi^(k+r)],[,"?","Convert" xi*((&DifferentialD;)/(&DifferentialD;xi) psi[m](xi)) "to series expansion"],[,,[]=(&sum;)a[k] (k+r) xi^(k+r)],[,"?","Convert" xi^2*(((&DifferentialD;)^2)/(&DifferentialD;xi^2) psi[m](xi)) "to series expansion"],[,,[]=(&sum;)a[k] (k+r) (k+r-1) xi^(k+r)],[,,"Rewrite ODE with series expansions"],[,,a[0] (r+1+m) (r-m) xi^r+a[1] (r+2+m) (r-m+1) xi^(1+r)+((&sum;)(a[k] (r+1+m+k) (r-m+k)+a[k-2]) xi^(k+r))=0],["&bullet;",,a[0] "cannot be 0 by assumption, giving the indicial equation"],[,,(r+1+m) (r-m)=0],["&bullet;",,"Values of r that satisfy the indicial equation"],[,,r in {m,-m-1}],["&bullet;",,"Each term must be 0"],[,,a[1] (r+2+m) (r-m+1)=0],["&bullet;",,"Solve for the dependent coefficient(s)"],[,,a[1]=0],["&bullet;",,"Each term in the series must be 0, giving the recursion relation"],[,,a[k] (r+1+m+k) (r-m+k)+a[k-2]=0],["&bullet;",,"Shift index using" k "->" k+2],[,,a[k+2] (r+3+m+k) (r-m+k+2)+a[k]=0],["&bullet;",,"Recursion relation that defines series solution to ODE"],[,,a[k+2]=-(a[k])/((r+3+m+k) (r-m+k+2))],["&bullet;",,"Recursion relation for" r=m],[,,a[k+2]=-(a[k])/((2 m+3+k) (k+2))],["&bullet;",,"Solution for" r=m],[,,[psi[m](xi)=(&sum;)a[k] xi^(k+m),a[k+2]=-(a[k])/((2 m+3+k) (k+2)),a[1]=0]],["&bullet;",,"Recursion relation for" r=-m-1],[,,a[k+2]=-(a[k])/((k+2) (-2 m+1+k))],["&bullet;",,"Solution for" r=-m-1],[,,[psi[m](xi)=(&sum;)a[k] xi^(k-m-1),a[k+2]=-(a[k])/((k+2) (-2 m+1+k)),a[1]=0]],["&bullet;",,"Combine solutions and rename parameters"],[,,[psi[m](xi)=((&sum;)a[k] xi^(k+m))+((&sum;)b[k] xi^(k-m-1)),a[k+2]=-(a[k])/((2 m+3+k) (k+2)),a[1]=0,b[k+2]=-(b[k])/((k+2) (-2 m+1+k)),b[1]=0]]]6""

(2)

Solving for Sum(a[k]*xi^(k+m), k = 0 .. infinity)

 

q := a(k+2) = -a(k)/((2*m+3+k)*(k+2))

a(k+2) = -a(k)/((2*m+3+k)*(k+2))

(1.1)

``

When m =1

 

NULL

m[1] := eval(q, m = 1)

a(k+2) = -a(k)/((5+k)*(k+2))

(2.1)

A := rsolve({m[1], a(0) = 1, a(1) = 0}, a(k))

3*(k+2)*cos((1/2)*k*Pi)/GAMMA(k+4)

(2.2)

add(A*(eval(xi^(k+m), m = 1)), k = 0 .. 16)

xi-(1/10)*xi^3+(1/280)*xi^5-(1/15120)*xi^7+(1/1330560)*xi^9-(1/172972800)*xi^11+(1/31135104000)*xi^13-(1/7410154752000)*xi^15+(1/2252687044608000)*xi^17

(2.3)

``

When m =2

 

 

NULL

m[2] := eval(q, m = 2)

a(k+2) = -a(k)/((7+k)*(k+2))

(3.1)

A := rsolve({m[2], a(0) = 1, a(1) = 0}, a(k))

105*(k+4)*(k+2)*(k+6)*cos((1/2)*k*Pi)/GAMMA(k+8)

(3.2)

add(A*(eval(xi^(k+m), m = 2)), k = 0 .. 16)

xi^2-(1/18)*xi^4+(1/792)*xi^6-(1/61776)*xi^8+(1/7413120)*xi^10-(1/1260230400)*xi^12+(1/287332531200)*xi^14-(1/84475764172800)*xi^16+(1/31087081215590400)*xi^18

(3.3)

NULL

When m=3

 

NULL

m[3] := eval(q, m = 3)

a(k+2) = -a(k)/((9+k)*(k+2))

(4.1)

A := rsolve({m[3], a(0) = 1, a(1) = 0}, a(k))

105*(k+4)*(k+2)*(k+6)*cos((1/2)*k*Pi)/GAMMA(k+8)

(4.2)

add(A*(eval(xi^(k+m), m = 3)), k = 0 .. 16)

xi^3-(1/18)*xi^5+(1/792)*xi^7-(1/61776)*xi^9+(1/7413120)*xi^11-(1/1260230400)*xi^13+(1/287332531200)*xi^15-(1/84475764172800)*xi^17+(1/31087081215590400)*xi^19

(4.3)

NULL

When m=4

 

NULL

m[4] := eval(q, m = 4)

a(k+2) = -a(k)/((11+k)*(k+2))

(5.1)

A := rsolve({m[4], a(0) = 1, a(1) = 0}, a(k))

945*(k+4)*(k+8)*(k+2)*(k+6)*cos((1/2)*k*Pi)/GAMMA(k+10)

(5.2)

add(A*(eval(xi^(k+m), m = 4)), k = 0 .. 16)

xi^4-(1/22)*xi^6+(1/1144)*xi^8-(1/102960)*xi^10+(1/14002560)*xi^12-(1/2660486400)*xi^14+(1/670442572800)*xi^16-(1/215882508441600)*xi^18+(1/86353003376640000)*xi^20

(5.3)

``

When m=5

 

NULL

m[5] := eval(q, m = 5)

a(k+2) = -a(k)/((13+k)*(k+2))

(6.1)

A := rsolve({m[5], a(0) = 1, a(1) = 0}, a(k))

10395*(k+10)*(k+4)*(k+8)*(k+2)*(k+6)*cos((1/2)*k*Pi)/GAMMA(k+12)

(6.2)

add(A*(eval(xi^(k+m), m = 5)), k = 0 .. 16)

xi^5-(1/26)*xi^7+(1/1560)*xi^9-(1/159120)*xi^11+(1/24186240)*xi^13-(1/5079110400)*xi^15+(1/1401834470400)*xi^17-(1/490642064640000)*xi^19+(1/211957371924480000)*xi^21

(6.3)

NULL

Now solving  for Sum(b[k]*xi^(k-m-1), k = 0 .. infinity)

 

s := b(k+2) = -b(k)/((k+2)*(-2*m+1+k))

b(k+2) = -b(k)/((k+2)*(-2*m+1+k))

(7.1)

NULL

The final solution is the sum of 2 terms and I am doing it individually for 1st term. I think I am doing it wrong because answer did not match when comparing with textbook answer. Can anyone teach me or hint me compute the final series for m=1 to 10. An example of final series for m=1 would be helpful. 

Download ODE_sol.mw

First 37 38 39 40 41 42 43 Page 39 of 43