# How to perform the Runge-Kutta method with symbolic constant variables?

As I had no clue how to solve a differential equation, I resolved to perform the Runge-Kutta method. Yet the problem was that while there were constants in my differential equation, they were symbolic. The initial method I undertook was to leave them as constants and run the Runge-Kutta method. Yet as by the 8th iteration the terms become extremely large, the process did not move ahead from that point.

The next approach I undertook was to have each constant to have values ranging from 1 to 25 and perform loops for all of them to be able to find a relationship between each constant and the output. Yet as there were 5 constants this approach took too much memory(a couple of GB currently) and an excessive amount of time(currently not completed yet so far, a day and a half).

Now, to get to my question, is there a better way to go about doing this?

As a reference, the differential equation I am running Runge-Kutta on was \begin{align} & C_0 \cos \theta + C_1 \sin \theta \\ & - \ddot{\theta}(\mu C_2 \cos 2\theta + C_2 \sin 2\theta - \dfrac{\mu}{2} C_3 \sin 2\theta + \dfrac{\mu}{2} C_4 \sin 2\theta + C_3 \cos ^2 \theta + C_4 \sin ^2 \theta) \\ & - {\dot{\theta}}^2 (C_2 \cos 2\theta - \mu C_2 \sin 2 \theta - \dfrac{C_3}{2} \sin 2\theta + \dfrac{C_4}{2} \sin 2\theta - \mu C_3 \cos ^2 \theta - \mu C_4 \sin ^2 \theta) \\ &= 0 \end{align} which was given in one of my questions here

## 1 Answer

Yes, using symbolic parameters within numeric computations tends to be a very bad idea, with the results after a few iterations being horrendously complicated functions of the parameters.

A better idea might be to explore a few terms of a multivariate Taylor series for the solution in terms of the parameters. Thus if $\theta$ satisfies the differential equation $\dot{\theta} = F(\theta, C)$, $\alpha = \partial \theta/\partial C$ satisfies the equation $\dot{\alpha} = F_1(\theta, C) \alpha + F_2(\theta, C)$ obtained by differentiating the first DE with respect to $C$. You can then use numerical methods to solve the system $\dot{\theta} = F(\theta, C_0), \; \dot{\alpha} = F_1(\theta,C_0)\alpha + F_2(\theta,C_0)$ for some particular $C_0$.

• Thanks for the answer! Sorry, I am quite inexperienced in differential equations. How can I find $a$? I assume for $\theta$ I can just rearrange the terms in my differential equation. – Isamu Isozaki Jan 4 '18 at 3:09
• As I said, you use a numerical solver to solve the system. Your case is a bit more complicated because the equation for $\theta$ is second order: $\ddot{\theta} = F(\theta, \dot{\theta}, C)$, and differentiating with respect to $C$ gives you $\ddot{\alpha} = F_1(\theta, \dot{\theta}, C) \alpha + F_2(\theta, \dot{\theta}, C) \dot{\alpha} + F_3(\theta, \dot{\theta}, C)$. – Robert Israel Jan 4 '18 at 3:17
• Oh, I think I got it. Thank you! – Isamu Isozaki Jan 4 '18 at 3:25
• Thanks for the edit! I'll look into that! – Isamu Isozaki Jan 4 '18 at 5:00
• $\theta(0) = \dot{\theta}(0) = 0$ according to your previous question. These do not depend on the parameters, so $\alpha(0) = \dot{\alpha}(0) = 0$. – Robert Israel Jan 5 '18 at 0:14