On Wed, Mar 31, 2010 at 1:08 PM, Josh Hykes <[email protected]> wrote:
> Hello,
>
> I am doing a Taylor expansion of the classical fourth order Runge-
> Kutta method.  The formula looks like
>
> y[n+1] = y[n] + h/6 * (k_1 + 2*k_2 + 2*k_3 + k_4)
>
> To do the expansion, I have to expand k_1, k_2, k_3, and k_4, where k_n
> +1 is a function of k_n.  Doing a Taylor expansion of k_2 is simple.
> Then I take that expansion and use it in the expansion for k_3, which
> is more complicated.  Finally, I take the expression for k_3 and plug
> into the expansion for k_4, which is now quite large.
>
> Since I only care about terms with powers of h less than 5, is there a
> way that I can quickly kill the high h powers?

You can do series expansion to order 6 and then use .removeO() method.

>
> For k_3, I used the polys.Poly class method coeff() to get the
> coefficients for the lower powers of h, but this method is proving to
> be too slow for k_4.
>
> Does anyone have suggestions for alternatives to try?  Hopefully there
> is something obvious I'm missing.  I'm a relative newcomer to sympy.

Can you post here your whole code? Someone maybe figures something out
to make it faster.

Ondrej

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to