Appendix A1. Power Series and Special Functions
Series Solutions
Maple's dsolve procedure can be used to obtain series solutions to differential equations. Add the optional equation
type=series
The unknown function must also be inserted directly after the IVP.
Example Obtain a series solution to the following differential equation (Ledder, A4, Exercise 2)
y'' + 2x y' - y = 0
Then obtain the first 6 non-zero terms of the series solution satisfying y(0) = 1, y'(0) = 3. Plot the approximate and the exact solutions. (Think of a mass spring system with a "repelling" spring moving in a fluid that is thickening with time.)
> | DE := diff(y(x),x,x) + 2*x*diff(y(x),x) - y(x) = 0; |
> | gen_soln := dsolve( DE, y(x), type=series); |
Lacking initial conditions, Maple finds the series solution near x = 0. This is why the general solution formula is given in terms of the initial values y(0) and D(y)(0). The "order 6" solution is obtained by default. The term
represents an error term that, as x approaches 0, also goes to 0 at least as fast as x^6 does. To obtain approximate solution values (or curves) convert the output to a polynomial.
> | convert(gen_soln,polynom); |
If initial values are given, they are substituted into the series. To obtain the first 6 non-zero terms ask for the order 7 solution by inserting the equation
order=7
> | soln := dsolve( {DE,y(0)=1,D(y)(0)=3}, y(x), type=series, order=7); |
> | y_approx := convert(rhs(soln),polynom); |
The next entry generates an exact solution formula. It is rather complicated, given in terms of Bessel functions, exponential functions, and the Gamma function.
> | exact_soln := dsolve( {DE,y(0)=1,D(y)(0)=3} ); |
Compare the exact and approximate solution curves. The approximation is the blue dashed curve (linestyle=3).
> | plot( [rhs(exact_soln), y_approx], x=0..3, 0..8, color=[red,blue], linestyle=[1,3]); |
Want a recursion relation: Use powsolve
When the differential equation has polynomial coefficients and x = 0 is not a singular point, the recursion relation can be obtained by applying the powsolve procedure in the powseries package.
> | with(powseries); |
> | pow_soln := powsolve( {DE, y(0)=1, D(y)(0)=3} ); |
The output is a procedure that can be used to generate power series solutions.
Apply the tpsform procedure ("to power series form") to pow_soln as follows to generate the 10th order solution formula
tpsform(pow_soln,x,10)
> | tpsform(pow_soln,x,10); |
Apply pow_soln directly to the expression _k as shown below to obtain the recursion relation.
> | pow_soln(_k); |
Interpret this output as
For numbers and graphs, you may be better off with dsolve/numeric
The dsolve/numeric procedure and odeplot will also produce a good picture of the exact solution curve.
> | numeric_soln := dsolve( {DE, y(0)=1, D(y)(0)=3}, y(x), numeric); |
> | with(plots):
display( odeplot( numeric_soln, [x,y(x)], x=-3..3, color=red), plot( y_approx, x=-3..3, -8..8, color=blue, linestyle=3) ); |
Here is now the value of the numeric solution compares to the exact value, say at x = 3.
> | Numeric,numeric_soln(3);
Exact,eval(exact_soln,x=3): evalf(%); |
Special functions
Maple has, as built in procedures, all of the special functions that are found in most elementary differential equations textbooks. For example, the Bessel functions of the first and second kind of order n are denoted BesselJ(n,x) and BesselY(n,x) respectively. Compare the plots below to the the ones appearing in Chapter 3, Figures 3.7.3 and 3.7.4 in Ledder.
> | plot( [BesselJ(0,x),BesselJ(1,x)], x=0..20, color=red, linestyle=[1,3]); |
> | plot( [BesselY(0,x),BesselY(1,x)], x=0..20, -1..0.6, color=red, linestyle=[1,3]); |
To see a list of all the functions that are initially known to Maple (without loading any special packages) go here.
> | ?inifcn |
If you would like to get more information about the functions that are "built in" to Maple go see the FunctionAdvisor.
> | ?FunctionAdvisor |