Return to computing page for the second course APMA0340
Return to computing page for the fourth course APMA0360
Return to Mathematica tutorial for the first course APMA0330
Return to Mathematica tutorial for the second course APMA0340
Return to Mathematica tutorial for the fourth course APMA0360
Return to the main page for the course APMA0330
Return to the main page for the course APMA0340
Return to the main page for the course APMA0360
Return to Part V of the course APMA0330
Glossary
Preface
This secton provides a stream of examples demonstating applications of power series method for solving initial value problems for second order differential equations.
Examples for second order linear ODEs
Most differential equations can't be solved explicitly in terms of finite combinations of simple familiar functions. Power series solutions, though, are frequently used to obtain recursion equations for the coefficients (of any solution that might be analytic within a neighborhood of the point of expansion). It would be nice, then, to have a function that outputs these equations (given a differential operator as input), rather than just obtaining an approximate solution with a limited radius of accuracy.
As illustration, we present some examples of second order differential equations and show how their solutions could be obtained via power series. It should be noted that power series were historically first used to obtain solutions to initial value problems in 18 and 19 centuries. Now we know some other approximations.
Mathematica is a very powerful package that can be successfully used to determined series solutions of nonlinear differential equations. The following subroutine could be used in this matter.
seriesDSolve[ode_, y_, iter : {x_, x0_, n_}, ics_: {}] :=
Module[{dorder, coeff},
dorder = Max[0, Cases[ode, Derivative[m_][y][x] :> m, Infinity]];
(coeff =
Fold[Flatten[{#1,
Solve[#2 == 0 /. #1,
Union@Cases[#2 /. #1, Derivative[m_][y][x0] /; m >= dorder,
Infinity]]}] &, ics,
Table[SeriesCoefficient[
ode /. Equal -> Subtract, {x, x0, k}], {k, 0, Max[n - dorder, 0]}]];
Series[y[x], iter] /. coeff) /; dorder > 0]
seriesDSolve[ y''[x] + x*y'[x] + y[x] == 0, y, {x, 0, 3}, {y[0] -> a, y'[0] -> b}
(*symbolic initial values*)]
Example: Consider the initial value problem for the second order differential equation:
Series[DifferentialRoot[Function @@ {{y, x}, ivp}][x], {x, 0, 15}]
x^10/3840 - ( 2 x^11)/10395 + x^12/46080 + (2 x^13)/135135 - x^14/645120 - ( 2 x^15)/2027025 + SeriesData[x, 0, {}, 0, 16, 1]
initconds = {y'[0] == 2, y[0] == 1};
x^10/9450 - x^11/21120 + x^12/124740 + \ x^13/299520 - x^14/1891890 - x^15/4838400
Plot[{truncatedSol, y[x] /. approxSol[[1]]}, {x, 0, 4}, PlotLegends -> "Expressions"]
Now we consider nonhomogeneous equation \[ x^2 y'' + x\, y' - y = x^2 , \qquad y(1) = \frac{4}{3}, \quad y' (1) = \frac{5}{3} . \] Its solution is \( \displaystyle y(x) = x + \frac{x^2}{3} . \) ■
Example: The Gross–Pitaevskii equation (GPE, named after Eugene P. Gross and Lev Petrovich Pitaevskii) describes the ground state of a quantum system of identical bosons using the Hartree–Fock approximation and the pseudopotential interaction model. Its stationary model that describes, for example, localization of an atomic gas in trapped Bose--Einstein condensates is
The first four Adomian polyniomials are
Example: We derive the series solution of the simple pendulum equation, subject to the given initial conditions, up to the order, say, O(t10), for example.
LogicalExpand
command to ode
.
eqs
are then solved for each derivative.
Example: Consider a simple pendulum problem when its pivot is undergoing vertical oscillations given by A sin(ωt) as in simple pendulum section. Its motion is modeled by the following second order differential equation:
p1[t_] = a + b*t;
p2[t_] = p1[t] - 1/2*g*Sin[a]*t^2/L ;
p3[t_] = p2[t] + 1/6*(A*omega^3*Sin[a] - g*Cos[a]*b)*t^3/L
p4[t_] = p3[t] + 1/24*(2*A*omega^3*Cos[a]*b*L + L*Sin[a]*b^2*g + Sin[a]*Cos[a]*g^2)* t^4/L^2 ;
p5[t_] = p4[t] - 1/120*(3*A*L*Sin[a]*b^2*omega^3 + A*omega^5*Sin[a]*L + 4*A*Sin[a]*Cos[a]*g*omega^3 - L*Cos[a]*b^3*g + 3*g^2*Sin[a]^2*b - Cos[a]^2*b*g^2)*t^5/L^2
p6[t_]= p5[t] + 1/720 (4 A^2 L Sin[a] Cos[a] omega^6 - 4 A L^2 Cos[a] b^3 omega^3 - 4 A omega^5 Cos[a] b L^2 + 16 A L (Sin[a])^2 b g omega^3 - 6 A L (Cos[a])^2 b g omega^3 - L^2 Sin[a] b^4 g - 11 L Sin[a] Cos[a] b^2 g^2 + 3 (Sin[a])^3 g^3 - Sin[a] (Cos[a])^2 g^3)/(L^3) t^6
p7[t_] = p6[t] - 1/5040 (20 A^2 L (Sin[a])^2 b omega^6 - 10 A^2 L (Cos[a])^2 b omega^6 - 5 A L^2 Sin[a] b^4 omega^3 - 10 A L^2 Sin[a] b^2 omega^5 - A omega^7 Sin[a] L^2 - 78 A L Sin[a] Cos[a] b^2 g omega^3 - 11 A L Sin[a] Cos[a] g omega^5 + 25 A (Sin[a])^3 g^2 omega^3 - 9 A Sin[a] (Cos[a])^2 g^2 omega^3 + L^2 Cos[a] b^5 g - 15 L (Sin[a])^2 b^3 g^2 + 11 L (Cos[a])^2 b^3 g^2 - 33 (Sin[a])^2 Cos[a] b g^3 + (Cos[a])^3 b g^3)/(L^3) t^7
p8[t_] = p7[t] - 1/40320 (138 A^2 L^2 Sin[a] Cos[a] b^2 omega^6 + 26 A^2 L^2 Sin[a] Cos[a] omega^8 - 70 A^2 L (Sin[a])^3 g omega^6 + 28 A^2 L Sin[a] (Cos[a])^2 g omega^6 - 6 A L^3 Cos[a] b^5 omega^3 - 20 A L^3 Cos[a] b^3 omega^5 - 6 A omega^7 Cos[a] b L^3 + 128 A L^2 (Sin[a])^2 b^3 g omega^3 + 66 A L^2 (Sin[a])^2 b g omega^5 - 100 A L^2 (Cos[a])^2 b^3 g omega^3 - 24 A L^2 (Cos[a])^2 b g omega^5 + 348 A L (Sin[a])^2 Cos[a] b g^2 omega^3 - 12 A L (Cos[a])^3 b g^2 omega^3 - g Sin[a] b^6 L^3 - 57 L^2 Sin[a] Cos[a] b^4 g^2 + 78 g^3 (Sin[a])^3 b^2 L - 102 L Sin[a] (Cos[a])^2 b^2 g^3 + 33 (Sin[a])^3 Cos[a] g^4 - Sin[a] (Cos[a])^3 g^4)/(L^4) t^8
p9[t_] = p8[t] - 1/362880 (-28 A^3 L Sin[a] (Cos[a])^2 omega^9 + 16 A Sin[a] (Cos[a])^3 g^3 omega^3 - 1238 A^2 L (Sin[a])^2 Cos[a] b g omega^6 + 600 A L^2 Sin[a] Cos[a] b^4 g omega^3 + 444 A L^2 Sin[a] Cos[a] b^2 g omega^5 + 1338 A L Sin[a] (Cos[a])^2 b^2 g^2 omega^3 - 480 A (Sin[a])^3 Cos[a] g^3 omega^3 + 666 L (Sin[a])^2 Cos[a] b^3 g^3 + 52 A^2 L (Cos[a])^3 b g omega^6 - 266 A^2 L^2 (Sin[a])^2 b^3 omega^6 - 182 A^2 L^2 (Sin[a])^2 b omega^8 + 238 A^2 L^2 (Cos[a])^2 b^3 omega^6 + 98 A^2 L^2 (Cos[a])^2 b omega^8 + 7 A L^3 Sin[a] b^6 omega^3 + 35 A L^3 Sin[a] b^4 omega^5 + 21 A L^3 Sin[a] b^2 omega^7 - 126 A L (Sin[a])^3 g^2 omega^5 - 189 (Sin[a])^4 b g^4 + 70 A^3 L (Sin[a])^3 omega^9 + A omega^9 Sin[a] L^3 - L^3 Cos[a] b^7 g + 63 g^2 (Sin[a])^2 b^5 L^2 - 57 L^2 (Cos[a])^2 b^5 g^2 - 102 L (Cos[a])^3 b^3 g^3 + 306 (Sin[a])^2 (Cos[a])^2 b g^4 - (Cos[a])^4 b g^4 + 22 A L^2 Sin[a] Cos[a] g omega^7 - 966 A L (Sin[a])^3 b^2 g^2 omega^3 + 46 A L Sin[a] (Cos[a])^2 g^2 omega^5)/(L^4) t^9 ; Plot[{p6[t], p9[t], Evaluate[y[t] /. sol]}, {t, 0, 0.7`}, PlotRange -> All, PlotStyle -> {{Thick}, {Thick, Cyan}, {Thick, Black}}, Axes -> {True, True}, AxesLabel -> {t, y}]
- Allame, M. and Azad, N., Solution of Third Order Nonlinear Equation by Taylor Series Expansion, World Applied Sciences Journal, 14 (1): 59-62, 2011.
Return to Mathematica page
Return to the main page (APMA0330)
Return to the Part 1 (Plotting)
Return to the Part 2 (First Order ODEs)
Return to the Part 3 (Numerical Methods)
Return to the Part 4 (Second and Higher Order ODEs)
Return to the Part 5 (Series and Recurrences)
Return to the Part 6 (Laplace Transform)
Return to the Part 7 (Boundary Value Problems)