The derivation of k1 and k2 in the context of the second-order Runge-Kutta method
involves approximating the solution of an ordinary differential equation (ODE) using
Taylor series expansions. Let's go through the derivation step by step:
Consider the first-order ODE:
dy
dt
= f (t, y)
The goal is to find an approximation for y(t + h), where h is the step size.
Taylor Expansion around tn , yn :
∣ ∣
dy h2 d2 y
y(t + h) = y(tn ) + h ⋅
dt
+ 2
⋅ dt2
+ O(h3 )
∣ (tn ,yn )
∣ (tn ,yn )
Approximate y(t + h) with k1 :
If we truncate the series at the first-order term, we get:
y(t + h) ≈ yn + h ⋅ f (tn , yn )
This is our approximation, and we define k1 as:
k1 = h ⋅ f (tn , yn )
Now, Evaluate k2 :
To improve our approximation, we'll include the second-order term. Substitute y(t +
h) into the Taylor expansion:
∣
h2 df
y(t + h) ≈ yn + h ⋅ f (tn , yn ) +
2
⋅ dt
∣ (tn ,yn )
Now, let's use the midpoint to estimate f (tn + h2 , yn +
k1
2
), which is k2 :
h k1
k2 = h ⋅ f ( t n +
,y
2 n
+ 2
)
So, k1 is obtained by approximating the solution using the first-order term, and k2 is
obtained by considering the midpoint and incorporating the second-order term into
the Taylor expansion.
You
show the same derivation for ranga kutta fourth order
ChatGPT
Certainly! Let's derive the Runge-Kutta (RK4) method, a fourth-order numerical
method, using Taylor series expansions. Consider a first-order ordinary differential
equation (ODE):
dy
dt
= f (t, y)
The RK4 method involves four steps, and we'll derive the expressions for k1 , k2 , k3 , and
k4 :
Taylor Expansion around tn , yn :
∣ ∣ ∣ ∣
dy h2 d2 y h3 d3 y h4 d4 y
y(t + h) = y(tn ) + h ⋅
dt
+ 2
⋅ dt2
+ 6
⋅ dt3
+ 24
⋅ dt4
+
∣ (tn ,yn )
∣ (tn ,yn )
∣ (tn ,yn )
∣ (tn ,yn )
O(h5 )
Approximate y(t + h) with k1 :
If we truncate the series at the first-order term, we get:
y(t + h) ≈ yn + h ⋅ f (tn , yn )
This is our approximation, and we define k1 as:
k1 = h ⋅ f (tn , yn )
Approximate y(t + h) with k2 :
Include the second-order term in the Taylor expansion:
∣
h2 df
y(t + h) ≈ yn + h ⋅ f (tn , yn ) +
2
⋅ dt
∣ (tn ,yn )
Define k2 as:
k2 = h ⋅ f (tn + h2 , yn +
k1
2)
Repeat for k3 and k4 :
Continue the process for the third- and fourth-order terms:
k3 = h ⋅ f (tn + h2 , yn + k22 )
k4 = h ⋅ f (tn + h, yn + k3 )
Now, the RK4 update formula is:
yn+1 = yn + 16 (k1 + 2k2 + 2k3 + k4 )
The RK4 method provides a more accurate approximation of the solution compared to
lower-order methods.