# Runge-Kutta Numerical Integration

1. Dec 1, 2009

### iamalexalright

1. The problem statement, all variables and given/known data
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?).