Runge-Kutta Method for a double pendulum

In summary, the user attempted to solve the equations of motion for a double pendulum using the fourth order Runge-Kutta method. However, they were not able to get the correct output. They attempted to use different initial values for omega and theta, but were not successful.
  • #1
heycoa
75
0
Hello, I am trying to program a double pendulum via the 4th order Runge-Kutta method and I cannot seem to be getting the right output. At first I used the Euler-Cromer method, but now I am aiming to make it more accurate.

Homework Statement



I have the equations of motion: d(omega)/dt and d(theta)/dt = omega

also, my step size is "h"

Homework Equations



The Runge-Kutta method can be found here: http://en.wikipedia.org/wiki/Runge–Kutta_methods

The Attempt at a Solution



for omega I tried the following:
k1=d(omega)/dt
k2=d(omega)/dt + 0.5*h*k1
k3=d(omega)/dt + 0.5*h*k2
k4=d(omega)/dt + 0.5*h*k3

omega= omega_initial + (1/6)*h*(k1 + 2*k2 + 2*k3 + k4)

and for theta:
k1=omega
k2=omega + 0.5*h*k1
k3=omega + 0.5*h*k2
k4=omega + 0.5*h*k3

theta = theta_initial + (1/6)*h*(k1 + 2*k2 + 2*k3 + k4)
 
Last edited:
Physics news on Phys.org
  • #2
heycoa said:
Hello, I am trying to program a double pendulum via the 4th order Runge-Kutta method and I cannot seem to be getting the right output. At first I used the Euler-Cromer method, but now I am aiming to make it more accurate.

Homework Statement



I have the equations of motion: d(omega)/dt and d(theta)/dt = omega

Homework Equations



The Runge-Kutta method can be found here: http://en.wikipedia.org/wiki/Runge–Kutta_methods

The Attempt at a Solution



for omega I tried the following:
k1=d(omega)/dt
k2=d(omega)/dt + 0.5*dt*k1
k3=d(omega)/dt + 0.5*dt*k2
k4=d(omega)/dt + 0.5*dt*k3

omega= omega_initial + (1/6)*dt*(k1 + 2*k2 + 2*k3 + k4)

and for theta:
k1=omega
k2=omega + 0.5*dt*k1
k3=omega + 0.5*dt*k2
k4=omega + 0.5*dt*k3

theta = theta_initial + (1/6)*dt*(k1 + 2*k2 + 2*k3 + k4)

Not quite; the [itex]k_i[/itex] are vectors with one component for each variable, and you need to compute each component of [itex]k_1[/itex] before computing any components of [itex]k_2[/itex] and so forth. Thus if you have [itex]x = (x_1, \dots, x_N)[/itex] and you wish to solve [itex]\dot x = f(x)[/itex] then you would need (in C):
Code:
double k1[N], k2[N], k3[N], k4[N], xTemp[N], xNew[N];

for(i = 0; i < N; i++)
{
   k1[i] = f(xOld)[i];
}

for(i = 0; i < N; i++)
{
   xTemp[i] = xOld[i] + 0.5*dt*k1[i];
}

for(i = 0; i < N; i++)
{
   k2[i] = f(xTemp)[i]; 
}
for(i = 0; i < N; i++)
{
   xTemp[i] = xOld[i] + 0.5*dt*k2[i];
}
with similar loops to calculate [itex]k_3[/itex] and [itex]k_4[/itex].

Of course if you're using a language which understands vector operations then you don't need to expressly loop through the components.
 
  • #3
Thank you very much for the response! But I'm not sure I understand. What is N here?
 
  • #4
I guess I just don't understand what K is. In my case, is K the slope of d(omega)/dt? So do I have to take the derivative of d(omega)/dt and then calculate the slope at each point?
 
  • #5


Hello, it looks like you are on the right track with using the 4th order Runge-Kutta method for your double pendulum problem. However, I noticed a few things that may be causing issues with your output.

First, in your equations for theta, you are using the same values for k1, k2, k3, and k4. This may be causing your results to be incorrect. Instead, for theta, you should use the equations:

k1 = d(theta)/dt
k2 = d(theta)/dt + 0.5*h*k1
k3 = d(theta)/dt + 0.5*h*k2
k4 = d(theta)/dt + h*k3

Then, for your final theta equation, you should use:

theta = theta_initial + (1/6)*h*(k1 + 2*k2 + 2*k3 + k4)

Second, it looks like you are using the same value for d(omega)/dt in each of your k equations for omega. This may also be causing issues with your results. Instead, you should use the equations:

k1 = d(omega)/dt
k2 = d(omega)/dt + 0.5*h*k1
k3 = d(omega)/dt + 0.5*h*k2
k4 = d(omega)/dt + h*k3

Then, for your final omega equation, you should use:

omega = omega_initial + (1/6)*h*(k1 + 2*k2 + 2*k3 + k4)

By using these updated equations, you should be able to get more accurate results for your double pendulum using the Runge-Kutta method. It's also important to double check your initial conditions and make sure they are accurate, as well as your step size, as these can also affect the accuracy of your results.

Good luck with your programming!
 

FAQ: Runge-Kutta Method for a double pendulum

What is the Runge-Kutta Method for a double pendulum?

The Runge-Kutta Method is a numerical algorithm used to solve differential equations, including those governing the motion of a double pendulum. It uses a series of calculations to approximate the solution at various points in time.

How does the Runge-Kutta Method work for a double pendulum?

The Runge-Kutta Method works by breaking down the motion of the double pendulum into smaller time intervals. At each interval, the algorithm calculates the position and velocity of the pendulum based on the previous values and the governing equations. These calculations are repeated until the desired time interval is reached.

What are the advantages of using the Runge-Kutta Method for a double pendulum?

The Runge-Kutta Method is highly accurate and can handle complex systems such as the double pendulum. It also allows for a flexible time step, meaning that the calculations can be adjusted to achieve the desired level of precision. Additionally, it is a widely used and well-understood method in the scientific community.

Are there any limitations to the Runge-Kutta Method for a double pendulum?

One limitation of the Runge-Kutta Method is that it can be computationally expensive, especially for systems with a large number of variables. Additionally, it may not accurately capture chaotic behavior in the double pendulum system, as the method assumes a smooth and predictable motion.

How is the Runge-Kutta Method for a double pendulum used in research?

The Runge-Kutta Method is commonly used in research to model the motion of the double pendulum and other complex systems. It allows scientists to investigate the behavior of the system under different conditions and make predictions about its future behavior. It is also used in engineering and other fields to simulate and analyze systems that are difficult to study experimentally.

Similar threads

Replies
15
Views
2K
Replies
36
Views
4K
Replies
4
Views
1K
Replies
6
Views
2K
Replies
3
Views
2K
Replies
2
Views
2K
Replies
4
Views
2K
Replies
1
Views
2K
Back
Top