Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider the differential equation

$\frac{d^2u(x)}{dx^2}+ u(x)^n = 0.$

Let the solution be

$u(x) = u_0(x) + p u_1(x) + p^2u_2(x) + \cdots +p^m u_m(x).$

Now we are interested in substituting the above solution into the original differential equation and collecting the coefficients of $p$. Here, we may assume that $m$ and $n$ are positive integers.

How can we program this with a computer algebra system such as Maple/Mathematica?

Thank you.

share|cite|improve this question
What are the $u_i(x)$ and $p$ intended to be? Usually in solving a DE the series way, one uses a power series (Frobenius) or a Chebyshev series (Clenshaw)... – J. M. Apr 28 '11 at 8:43
You can solve this differential equation exactly: Multiply by $u'(x)$. – Christian Blatter Apr 28 '11 at 11:03
@Christian: yeah, for $n=1$ you have a trigonometric solution, and for $n=2$ and $n=3$, you have elliptic function solutions. Not sure about other values though. – J. M. Apr 28 '11 at 11:46

The answer is relatively straightforward for a standard power series of the form, $u(x) = \sum a_l x^l$. The key is to use Mathematica's built-in series support. First, define $u$

u = With[{lmax = ...}, Sum[ a[l] x^l, {l, 0, lmax}] + O[x]^(lmax + 1) ]

where you set nmax as high as you need to recognize the pattern. For $n = 1$ (using you definition above), the differential equation

D[u, {x, 2}] + u

with lmax = 7 gives

(a[0] + 2 a[2]) + (a[1] + 6 a[3]) x + (a[2] + 12 a[4]) x^2 + (a[3] + 
20 a[5]) x^3 + (a[4] + 30 a[6]) x^4 +(a[5] + 42 a[7]) x^5 + O[x]^6

Note, Mathematica automatically collected the coefficients because we used O[x]^(lmax + 1), and correctly calculated the order of the neglected terms.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.