Start from the exact integral over one step:
y(t+h)=y(t)+∫tt+hf(s,y(s))ds.
RK4 approximates this integral with Simpson-like sampling, evaluating f at the start, twice at the midpoint, and at the end — but using estimated states, not the unknown true ones.
Solve y1′=y2,y2′=−y1 with y(0)=(1,0). (True solution: y1=cost,y2=−sint.) Take h=0.1, one step.
So f(t,y)=(y2,−y1).
Step k1.k1=(y2,−y1)=(0,−1).
Why this step? Slope at the start using the current state (1,0).
Step k2. Intermediate state y+2hk1=(1,0)+0.05(0,−1)=(1,−0.05).
k2=(−0.05,−1).
Why this step? We re-evaluate the slope at the predicted midpoint — note both components used the advanced state, not just one.
Step k3.y+2hk2=(1,0)+0.05(−0.05,−1)=(0.9975,−0.05).
k3=(−0.05,−0.9975).
Why this step? A refined midpoint slope using k2.
Step k4.y+hk3=(1,0)+0.1(−0.05,−0.9975)=(0.995,−0.09975).
k4=(−0.09975,−0.995).
Why this step? Slope at the end of the interval.
Combine.y1,1=1+60.1(0+2(−0.05)+2(−0.05)+(−0.09975))=1+60.1(−0.29975)≈0.99500.y2,1=0+60.1(−1+2(−1)+2(−0.9975)+(−0.995))=60.1(−5.99)≈−0.099833.
True: cos0.1=0.995004, −sin0.1=−0.099833. The y1 value matches to ~4 decimals; the y2 value matches to ~3 decimals — with one step.
Solve y′′+y=0, y(0)=1,y′(0)=0. Reduce: u1=y,u2=y′:
u1′=u2,u2′=−u1.Why this step? Same physics as Example 1 — the pendulum/oscillator. We converted a 2nd-order ODE into a system so RK4-for-systems applies directly. The result is identical: y1 tracks cost. This proves the reduction trick lets one method handle all orders.
Imagine two friends running and holding hands — wherever one goes affects the other. To guess where they'll be in a moment, you don't peek once; you peek four times: at the start, twice in the middle, and at the end, each time guessing where both friends moved together. Then you take a clever weighted average (count the middle peeks double). Because they're holding hands, you must move both at each peek, never one alone. That careful four-peek average is RK4 for systems.
Dekho, ek single ODE mein sirf ek quantity ka rate hota hai. Lekin real life mein cheezein juddi hoti hain — jaise position aur velocity, ya predator aur prey. Inko alag-alag solve nahi kar sakte kyunki ek dusre par depend karte hain. Toh trick simple hai: saari unknowns ko ek vectory maan lo, aur jo RK4 scalar ke liye chalta tha, wahi recipe bilkul same — sirf har symbol ko bold (vector) bana do. Weights 1,2,2,1 over 6 same rehte hain.
Sabse important baat (yahi 80% marks dilata hai): stages ko synchronize karo. Pehle poora k1 nikalo — yaani saare components ka slope. Phir us advanced state se poora k2, phir k3, phir k4. Galti yeh hoti hai ki log ek equation ka pura RK4 finish kar dete hain phir doosre ka — yeh galat hai kyunki f1 ko y2 ki updated value chahiye. Dono haath pakad ke chal rahe hain, ek ko akele aage nahi badha sakte.
Aur ek bonus: koi bhi higher-order ODE ko first-order system mein todo. y′′=−y ko u1=y,u2=y′ rakh ke u1′=u2,u2′=−u1 bana do. Ab same RK4-for-systems chala do. Isliye yeh ek hi method actually saari ODEs handle kar leta hai — bahut powerful aur exam mein guaranteed aata hai.