Series solutions of ODEs?



I could generate the series (to the solution of y'=x^2+y^2, y(0)=1) by
the more simple procedure (obtained by simply integrating through the
DE):

y:1
for i:1 thru 10 y:1+x^3/3+integrate(y^2,x);
expand(y);

*if* there was a way of automatically getting all powers of x greater
than 10 to be set to zero, or else the iteration gets swamped by
unwieldy high powers of x.  Can I use Maxima's rules and patterns to
do this?

Thanks,
Alasdair


On 12/21/05, Alasdair McAndrew  wrote:
> Thank you very much - that seems to work well.  I still think, though,
> that it would be nice to either have a "series" option to desolve or
> ode2, or a new function 'odeseries' which produces a series.
>
> Thanks again,
> Alasdair
>
> On 12/21/05, Stavros Macrakis  wrote:
> > > 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
> >
> > _______________________________________________
> > Maxima mailing list
> > Maxima@math.utexas.edu
> > http://www.math.utexas.edu/mailman/listinfo/maxima
> >
>