# Runge-Kutta Numerical Integration

• iamalexalright
In summary, the conversation discusses a stellar model and the equations used to solve it. The equations are transformed into logarithmic variables and the Runge-Kutta method is used for numerical integration. The logarithm is used to simplify the equations, but the same methods can be used to solve for the variables.
iamalexalright

## Homework Statement

In brief, I am working on a stellar model.

We started with these four equations:
$$\delta q/\delta x = px^{2}/t$$
$$\delta p /\delta x = -pq/tx^{2}$$
$$\delta t /\deltax = -Cp^{1.75} / x^{2}t^{8325}$$
$$\delta t /\delta x = -2q/5x^{2}$$

In the model you switch to the 4th equation instead of the 3rd when the ratio of the 3rd to the 4th is less than 1.

Because the variables p and t vary over orders of magnitude we switch to logarithmetic variables.

$$g_{1}=log(p)$$
$$g_{2}=log(q)$$
$$g_{3}=log(t)$$
$$y=log(x)$$

The 4 equations transform to:
$$log[-\delta g_{1}/\delta y] = g_{2} - g_{3} - y$$
$$log[\delta g_{2}/\delta y] = g_{1} + 3y - g_{2} - g_{3}$$
$$log[-\delta g_{3}/\delta y] = log(C) + 1.75g_{1} - y - 9.25g_{3}$$
$$log[-\delta g_{3}/\delta y] = log(2/5) + g_{2} - g_{3} - y$$

log(C) = -5.51674

The initial conditions are:
x = 1, q = 1, t = 0, p = 0

Since we encounter problems we use:

$$p^{1.75} = 1.75t^{8.25}/8.25C$$
$$t = 1.75/8.25(1/x - 1)$$

to find these initial values.

We then work on way inward (from x = 1 to x = 0)

2. The attempt at a solution
I worked out
g1 = -8.37512874
g2 = 1
g3 = -2.36361205
y = -0.00877392431

to be initial values.

Now I am having troubles doing the actual numerical integration...for instance if I try to find g1 at a point x-h(where h I have .02) i do this:

$$g_{1 at x-h} = g_{1 at x} + (1/6)(k_{1} + 2k_{2} + 2k_{3} + k_{4})}$$

Now $$k_{1}$$ is simply the derivative of $$g_{1}$$ at x.
For $$k_{2}$$ I use $$x + .5hk_{1}$$ instead of x in the derivative equation(and the same method for k3 and k4).

Is this correct? Also I don't know what to do about that log outside(meaning, do I raise 10 by the right-hand side to get the actual derivative and not the log of it?).

Hello, thank you for sharing your work on your stellar model. It seems like you have a good understanding of the equations and have made some progress in finding initial values.

In terms of your numerical integration, it is important to first understand the equations you are working with. In this case, you have a system of differential equations, which means you need to use numerical methods specifically designed for that type of problem.

One commonly used method is the Runge-Kutta method, which uses a series of approximations to calculate the next value in the solution. The equation you have written for g_{1 at x-h} is a variation of the fourth-order Runge-Kutta method, which is a good choice for this problem.

However, it is important to note that the derivatives you are using for k_{2}, k_{3}, and k_{4} should be evaluated at different points, not just x + 0.5hk_{1}. This is because the Runge-Kutta method uses a weighted average of these derivatives to calculate the next value, so they need to be evaluated at different points in order to capture the behavior of the function accurately.

As for the logarithm, you do not need to raise 10 to the right-hand side to get the actual derivative. The logarithm is used to transform the equations into a form that is easier to work with, but you can still use the same numerical methods to solve for the values of g_{1}, g_{2}, g_{3}, and y.

I hope this helps and good luck with your stellar model!

## 1. What is Runge-Kutta numerical integration?

Runge-Kutta numerical integration is a method used to solve ordinary differential equations (ODEs) numerically. It is a type of numerical integration that approximates the solution of an ODE by using a series of calculations to predict the value of the function at discrete points in time.

## 2. How does Runge-Kutta numerical integration work?

Runge-Kutta numerical integration works by using a set of equations to estimate the slope of the ODE at different points in time. These slopes are then used to predict the value of the function at the next time step. The process is repeated iteratively until the desired accuracy is achieved.

## 3. What are the advantages of using Runge-Kutta numerical integration?

One advantage of Runge-Kutta numerical integration is that it is a more accurate method of solving ODEs compared to simpler numerical methods. It is also more efficient and can handle a wider range of ODEs, including stiff equations.

## 4. Are there any limitations to using Runge-Kutta numerical integration?

One limitation of Runge-Kutta numerical integration is that it requires more computational resources compared to simpler methods. It also may not be suitable for solving ODEs with discontinuities or highly oscillatory solutions.

## 5. How is the accuracy of Runge-Kutta numerical integration measured?

The accuracy of Runge-Kutta numerical integration is measured by comparing the results to the exact solution of the ODE. The difference between the two is known as the error, and it can be reduced by using smaller time steps or higher-order methods.

• Calculus and Beyond Homework Help
Replies
1
Views
558
• Calculus and Beyond Homework Help
Replies
5
Views
430
• Calculus and Beyond Homework Help
Replies
7
Views
696
• Calculus and Beyond Homework Help
Replies
12
Views
1K
• Calculus and Beyond Homework Help
Replies
5
Views
902
• Calculus and Beyond Homework Help
Replies
2
Views
421
• Other Physics Topics
Replies
2
Views
5K
• Special and General Relativity
Replies
24
Views
634
• Special and General Relativity
Replies
4
Views
323
• Calculus and Beyond Homework Help
Replies
8
Views
1K