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.
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$
where you set nmax as high as you need to recognize the pattern. For $n = 1$ (using you definition above), the differential equation
with
lmax = 7givesNote, Mathematica automatically collected the coefficients because we used
O[x]^(lmax + 1), and correctly calculated the order of the neglected terms.