Solving 4th Order Runge-Kutta w/ dy/dt = y, y(0)=1

In summary, the fourth order Runge-Kutta formula can be used to advance a first-order ODE by evaluating the derivative at specific points and using it to calculate the next value of the function. To use this method, you must know the step size and the initial value of the function. The RK4 algorithm involves calculating four different values (k1-k4) and using them to find the next value of the function.
  • #1
kmeado07
40
0

Homework Statement



Use the fourth order Runge-Kutta formula to advance the differential equation:
dy/dt = y with y(0)=1 forward one step h. That is find y(h).


Homework Equations





The Attempt at a Solution



The Runge-Kutta formula is:
x(i+1)=x(i)+h/6 [k(1)+2k(2)+2k(3)+k(4)]

where,
k(1)=f[x(i),t(i)]
k(2)=f[x(i)+1/2 hk(1), t(i)+1/2 h]
k(3)=f[x(i)+1/2 hk(2), t(i)+1/2h]
k(4)=f[x(i)+hk(3),t(i)+h]

I have no idea how to continue though, so any help would be great! thanks
 
Physics news on Phys.org
  • #2
A first-order ODE is given as,

[tex]dy/dx = f(x,y)[/tex]

this is the defintion. So when one states, [tex]f(x_i,y_i)[/tex], this simply means, evaluate the first-order derivative at [tex]x_i[/tex] and [tex]y_i[/tex].

This is how the method breaks down:

[tex]The general form of the RK4 algorithm is given as,
\begin{equation}\begin{split}
k_{1}&=f(x_{i},y_{i})\\
k_{2}&=f(x_{i}+\dfrac{1}{2}h, y_{i}+\dfrac{1}{2}k_{1}h)\\
k_{3}&=f(x_{i}+\dfrac{1}{2}h,y_{i}+\dfrac{1}{2}k_{2}h)\\
k_{4}&=f(x_{i}+h,y_{i}+k_{3}h)\\
y_{i+1}&=y_{i}+\dfrac{1}{6}\cdot(k_{1}+2k_{2}+2k_{3}+k_{4})\cdot h
\label{eq:}
\end{split}\end{equation}[/tex]

[tex]Simplified as eight equations,
\begin{equation}\begin{split}
k_1&=f(x_i,y_i)\\
z_1&=y_i+\dfrac{1}{2}k_{1}h\\
k_2&=f(x_{i}+\dfrac{1}{2}h, z_1)\\
z_2&=y_i+\dfrac{1}{2}k_{2}h\\
k_3&=f(x_{i}+\dfrac{1}{2}h, z_2)\\
z_3&=y_i+k_{3}h\\
k_4&=f(x_{i}+h, z_3)\\
y_{i+1}&=y_i+\left(\dfrac{h\cdot(k_1+2(k_2+k_3)+ k_4)}{6}\right)
\label{eq:}
\end{split}\end{equation}
[/tex]

Say for example you are given, [tex]y'=(-y)ln(y),\;\;y(0)=0.5.[/tex]

Hence,
[tex]f(x_0,y_0)=(-0.5)\cdot ln(0.5)[/tex]

In this example, it only varied in terms of y. However, you could be faced with an ODE such as [tex]y'=4e^{0.8x}-0.5y[/tex], in which case you need to take care how you substitute in the 'x' value. For the [tex]x_i+\dfrac{1}{2}h[/tex] bits, you need to evaluate it at [tex]x_{i+1}=x_i+\dfrac{1}{2}h[/tex].

For example, if [tex]x_0=0[/tex] and h=0.5, then [tex]x_1=0+\dfrac{1}{2}(0.5)=0.25[/tex].

Hope this helps...
 
  • #3
thankyou very much for that...i understand all of what you have said.

So i found for my equation that f[t(0),y(0)] = 1, since y'=y and y(0)=1

Im still slightly confused as to how to find y(h)?
 
  • #4
How do i find what k(1) - k(4) is? Do i substitute anything in for h?

Also what are the value for t(i) and y(i)?
 
  • #5
You shouldn't jump to using RK4 if you don't understand the basics. Try using the Euler method (it's basically a first-order RK). You also need to know the stepsize 'h'. This is given with questions,

[tex]y_{i+1}=y_i+hf(x_i,y_i)[/tex]

As for your question, y'=y, you can ignore the x or 'time' component as it were, as it only varies in y.

The first RK4 application would be, note [tex]y_0=y(0)=1[/tex],

[tex]k_1 = f(0, 0) =1[/tex]
[tex]k_2 = y_0+0.5*k_1*h[/tex]
[tex]k_3 = y_0+0.5*k_2*h[/tex]
[tex]k_4 = y_0+k_3*h[/tex]

Hence,
[tex]y_1=y_0+\left(\dfrac{h*(k_1+2(k_2+k_3)+k_4)}{6}\right)[/tex]

For the next iteration, use [tex]y_1[/tex] to start off :)
 

1. What is the 4th order Runge-Kutta method?

The 4th order Runge-Kutta method is a numerical technique used for solving differential equations. It is an improvement over the Euler's method and involves using four intermediate values to approximate the solution at a given point.

2. What is dy/dt = y?

In this context, dy/dt represents the derivative of the function y with respect to t. This equation is a first-order ordinary differential equation, where the rate of change of y is directly proportional to its value.

3. What does y(0)=1 mean?

The notation y(0)=1 indicates the initial condition of the differential equation at t=0. This means that at t=0, the value of y is equal to 1. This initial condition is necessary for solving the differential equation using the 4th order Runge-Kutta method.

4. How is the 4th order Runge-Kutta method used to solve the equation?

The 4th order Runge-Kutta method involves calculating four intermediate values, k1, k2, k3, and k4, and using them to obtain the final approximation of the solution at a given point. These values are calculated using a specific formula that takes into account the slope of the function at different points.

5. What are the advantages of using the 4th order Runge-Kutta method?

The 4th order Runge-Kutta method is a more accurate and efficient method compared to the Euler's method. It allows for a larger step size, which means fewer iterations are needed to reach the same level of accuracy. It is also a widely used method for solving differential equations in various fields, such as physics, engineering, and economics.

Similar threads

  • Calculus and Beyond Homework Help
Replies
14
Views
2K
Replies
38
Views
431
  • Calculus and Beyond Homework Help
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
4
Views
104
  • Calculus and Beyond Homework Help
Replies
2
Views
149
  • Calculus and Beyond Homework Help
Replies
3
Views
567
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
252
  • Calculus and Beyond Homework Help
Replies
6
Views
849
  • Calculus and Beyond Homework Help
Replies
3
Views
491
Back
Top