So I guess you need to dump the higher powers as you go, as they are only going to contribute to even higher powers. For example, if you only care about x**2 or lower in (1 + x + x**2 + x**3)*(2 + x**2 + x**3), you can just look at (1 + x + x**2)*(2 + x**2), since the other terms are just going to create powers that are greater than 2.
You could probably simplify it more if you know that there are no constant terms (e.g. for just (x + x**2)*(x**2 + x**3), nothing will have powers less than 2). I don't know much about runge-kutta, so I don't know if this will actually apply. Aaron Meurer On Mar 31, 2010, at 2:08 PM, Josh Hykes 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? > > 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. > > Thanks in advance, > > Josh > > -- > 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. > -- 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.
