Series solutions of ODEs?



> Can Maxima produce the solution of an ODE in form of a power series?
> For example, the Riccati equation:
>
> dy/dx=x^2+y^2, y(0)=1
>
> has a complicated closed-form solution using Bessel functions, but
> sometimes a few terms of the series is all you need.

I'm sure there are better ways -- maybe even a share package -- to do
this, but here's a simple way:

y: taylor(sum(a[i]*x^i,i,0,6),x,0,6)$  /* Generate a truncated series */

eq: x^2+y^2 - diff(y,x)$

tayeq: taylor(eq,x,0,6)$
    /* Taylor step not needed in this case since all terms are polynomials,
       but needed in general */

coeffs: makelist ( ratcoeff(tayeq, x, i), i , 0 , 6) $

solve( cons(subst(0,x,y)=1,   /* initial condition */
                  coeffs),
          makelist(a[i],i,0,6));

Note that a[6] is not correct, because we were using only a 6th order
expansion.  Unfortunately, Taylor doesn't "know" that the 6th term is
unknown.

This approach can also be used to solve functional equations.  For
example, applying it to

     sin(y)-x

will get you the expansion of arcsin.

            -s