4.8.23 · Maths › Numerical Methods
d x d y = f ( x , y ) , y ( x 0 ) = y 0 ko solve karna — lekin plain Euler se zyada smart tarike se.
Intuition WHY plain Euler bekar kyun hai, aur yeh method usse kaise fix karta hai?
Plain Euler sirf starting point pe slope use karke aage badhta hai. Lekin slope
change hoti rehti hai jab aap step ke across move karte ho. Sirf start-slope use karna
systematically over/under-shoot karata hai — jaise ek car steer karna sirf yeh dekh ke ki
road abhi kidhar point kar rahi hai, aur kabhi aage nahi dekhna.
Heun ka idea: slope ko start pe bhi dekho AUR predicted slope ko end pe bhi,
phir unka average use karke chalo. Entering aur exiting slopes ko average karna interval
ke upar true behaviour ke kaafi kareeb hota hai. Yahi poora trick hai.
Hume y ( x 1 ) chahiye jahan x 1 = x 0 + h , given y ′ = f ( x , y ) aur y ( x 0 ) = y 0 .
Step 1 — Exact statement. ODE ko ek step pe integrate karo:
y ( x 1 ) − y ( x 0 ) = ∫ x 0 x 1 f ( x , y ) d x
Yeh step kyun? Yeh exact hai (Fundamental Theorem of Calculus). Numerical methods mein
poora khel yeh hai ki hum is integral ko kaise approximate karte hain .
Step 2 — Integration rule choose karo. Plain Euler left-rectangle rule use karta hai:
∫ ≈ h f ( x 0 , y 0 ) . Yeh crude hai. Iske bajaye trapezoidal rule use karo:
∫ x 0 x 1 f ( x , y ) d x ≈ 2 h [ f ( x 0 , y 0 ) + f ( x 1 , y 1 ) ]
Yeh step kyun? Trapezoid dono ends pe height ko average karta hai → yeh slopes ke
straight-line average se match karta hai, exactly wahi jo hamari intuition maang rahi thi.
Step 3 — The catch. Hume f ( x 1 , y 1 ) chahiye lekin hum y 1 jaante nahi — yahi toh hum
solve kar rahe hain! Toh hum isse ek saste Euler step se predict karte hain.
Intuition Do slopes, ek average
Maano k 1 = f ( x 0 , y 0 ) (start pe slope) aur k 2 = f ( x 0 + h , y 0 + h k 1 ) (slope predicted
end pe). Tab y 1 = y 0 + 2 h ( k 1 + k 2 ) . Yeh ek 2-stage Runge–Kutta method hai —
disguise mein RK2.
Intuition WHAT "second order" ka matlab kya hai?
Local error per step ∝ h 3 ; total (global) error ∝ h 2 . Plain Euler globally
∝ h hai. Toh h ko half karne se Heun ka error 4× kam hota hai , lekin Euler ka
sirf 2× kam hota hai.
Quick Taylor check: true value hai
y ( x 1 ) = y 0 + h y ′ + 2 h 2 y ′′ + 6 h 3 y ′′′ + …
Heun ka average-slope formula h aur h 2 terms ko exactly reproduce karta hai (isliye yeh order 2 hai);
yeh pehli baar h 3 term pe disagree karta hai.
Worked example Example 1 —
y ′ = x + y , y ( 0 ) = 1 , y ( 0.1 ) find karo h = 0.1 se
f ( x , y ) = x + y , x 0 = 0 , y 0 = 1 .
Predictor: k 1 = f ( 0 , 1 ) = 0 + 1 = 1 .
y 1 ( p ) = 1 + 0.1 ( 1 ) = 1.1 .
Kyun? Cheap Euler guess taaki hum end-slope evaluate kar sakein.
End slope: k 2 = f ( 0.1 , 1.1 ) = 0.1 + 1.1 = 1.2 .
Kyun? Predicted endpoint pe f evaluate karo.
Corrector: y 1 = 1 + 2 0.1 ( 1 + 1.2 ) = 1 + 0.05 ( 2.2 ) = 1.11 .
Kyun? Do slopes ko average karo → trapezoid.
Check: exact solution y = 2 e x − x − 1 deta hai y ( 0.1 ) = 1.11034 . Heun's 1.11000 → error
0.0003 . (Plain Euler ne 1.10 diya tha, error 0.010 — lagbhag 30× bura!)
Worked example Example 2 —
y ′ = − 2 x y , y ( 0 ) = 1 , y ( 0.2 ) find karo h = 0.2 se
f ( x , y ) = − 2 x y .
k 1 : f ( 0 , 1 ) = 0 . → predictor y ( p ) = 1 + 0.2 ( 0 ) = 1 .
Kyun? Start pe slope flat hai kyunki x = 0 .
k 2 : f ( 0.2 , 1 ) = − 2 ( 0.2 ) ( 1 ) = − 0.4 .
Kyun? Ab x = 0 , toh true curve neeche bend karna shuru ho gayi hai.
Corrector: y 1 = 1 + 2 0.2 ( 0 + ( − 0.4 )) = 1 − 0.04 = 0.96 .
Check: exact y = e − x 2 = e − 0.04 = 0.9608 . Error sirf 0.0008 . Plain Euler 1.0 pe
reh jaata (error 0.039 ) — usne curve ke bend ko kabhi "notice" hi nahi kiya.
Worked example Example 3 — Corrector ki ek iteration (improved Heun)
Ex.1 jaisa hi lekin corrector output ko re-use karo taaki end slope re-predict ho sake:
Pehle corrector ke baad y 1 = 1.11 , recompute k 2 = f ( 0.1 , 1.11 ) = 1.21 , phir
y 1 = 1 + 0.05 ( 1 + 1.21 ) = 1.1105 . 1.11034 ke aur kareeb.
Kyun? Corrector ko iterate karna implicit trapezoid ko zyada exactly solve karta hai.
f ( x 1 , y 1 ) use karo — lekin purani y 0 plug karo."
Kyun sahi lagta hai: naye x pe slope chahiye, toh x ko x 1 kar do.
Fix: end-slope ko predicted y chahiye, y 1 ( p ) = y 0 + h k 1 , na ki y 0 .
f ( x 1 , y 0 ) use karna yeh ignore karta hai ki y kaise move hua → second-order accuracy
kho jaati hai.
2 h bhool jana (h likh dena).
Kyun sahi lagta hai: plain Euler h ⋅ f use karta hai.
Fix: hum do slopes ko average kar rahe hain, toh har ek aadha contribute karta hai: 2 h ( k 1 + k 2 ) .
Agar h ( k 1 + k 2 ) use karo toh double step ho jaayega.
y 1 ko bhi predictor samajh lena.
Fix: basic Heun ek predictor phir ek corrector use karta hai. Sirf
iterated version recycle karta hai. Formulas ko mid-step mix mat karo.
Recall Feynman: ek 12-saal ke bache ko samjhao
Tum hiking kar rahe ho aur jaanna chahte ho ki ek step ke baad tum kahan honge. Plain Euler
tumhare pair abhi trail jis direction mein point kar rahi hai usi direction mein set karta
hai aur chalta hai — lekin trails curve karti hain, toh tum bhatak jaate ho.
Heun ka trick: ek practice step lo taaki dekhein ki trail end pe kahan point karti hai,
phir start-direction aur end-direction ke average se chalo. Commit karne se pehle aage
dekhne se tum real path ke kaafi kareeb land karte ho.
P-A-C: Predict, Average, Correct.
"P eek ahead, A verage the two slopes, phir C orrect step lo (2 h )."
Heun's method ke neeche kaun sa integration rule hai? Trapezoidal rule jo ∫ x 0 x 1 f d x pe apply hota hai.
Heun's method ka predictor likho. y 1 ( p ) = y 0 + h f ( x 0 , y 0 ) (ek plain Euler step).
Heun's method ka corrector likho. y 1 = y 0 + 2 h [ f ( x 0 , y 0 ) + f ( x 1 , y 1 ( p ) ) ] .
Predictor ki zaroorat kyun hai? Trapezoid ko f ( x 1 , y 1 ) chahiye lekin y 1 unknown hai, toh hum isse cheap Euler se predict karte hain.
Heun's method ka global error order kya hai? O ( h 2 ) — second order; h ko half karne se error ~4× kam hota hai.
Plain Euler ka global error order kya hai? O ( h ) — first order.
Heun's method kis Runge–Kutta method ke equivalent hai? RK2 (equal weights ke saath 2-stage Runge–Kutta).
k 2 = f ( x 0 + h , y 0 + h k 1 ) mein y 0 + h k 1 kyun use karte hain na ki y 0 ?Kyunki end-slope ko y ki predicted end-value pe evaluate karna hota hai, start value pe nahi.
y ′ = x + y , y ( 0 ) = 1 , h = 0.1 ke liye Heun se y ( 0.1 ) batao.1.11 (k 1 = 1 , k 2 = 1.2 ke saath).
Corrector ko iterate karne se kya milta hai? Yeh implicit trapezoidal equation ko better solve karta hai, accuracy aur improve hoti hai.
Euler's Method — predictor step exactly plain Euler hai.
Trapezoidal Rule — corrector disguise mein yahi integration rule hai.
Runge-Kutta Methods — Heun = RK2; RK4 famous higher-order cousin hai.
Order of Accuracy and Step Size — kyun O ( h 2 ) beats O ( h ) .
Predictor-Corrector Methods — Heun sabse simple example hai.
Taylor Series Methods — prove karne ke liye use hoti hai ki Heun second order hai.
matches h and h squared terms
Plain Euler start slope only
Second order global error h squared