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.