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

615 Views Asked by At

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

There are 1 best solutions below

18
On BEST 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$.