Step 1 — Exact statement. Integrate the ODE over one step:
y(x1)−y(x0)=∫x0x1f(x,y)dx
Why this step? It's exact (Fundamental Theorem of Calculus). The whole game in numerical
methods is how we approximate this integral.
Step 2 — Choose the integration rule. Plain Euler uses the left-rectangle rule:
∫≈hf(x0,y0). That's crude. Instead use the trapezoidal rule:
∫x0x1f(x,y)dx≈2h[f(x0,y0)+f(x1,y1)]
Why this step? The trapezoid averages the height at both ends → it matches the
straight-line average of slopes, the exact thing our intuition demanded.
Step 3 — The catch. We need f(x1,y1) but we don't know y1 yet — that's what we're
solving for! So we predict it with one cheap Euler step.
Quick Taylor check: the true value is
y(x1)=y0+hy′+2h2y′′+6h3y′′′+…
Heun's average-slope formula reproduces the h and h2 terms exactly (that's why it's order 2);
it first disagrees at the h3 term.
You're hiking and want to know where you'll be after one step. Plain Euler points your feet
in the direction the trail goes right now and walks — but trails curve, so you drift off.
Heun's trick: take a practice step to peek where the trail points at the end, then walk
using the average of the start-direction and end-direction. Looking ahead before
committing makes you land much closer to the real path.
Dekho, normal Euler method ka problem ye hai ki wo sirf shuru wale point ka slope use
karke aage chala jaata hai. Lekin curve toh aage badhte hue mudta rehta hai, isliye Euler
hamesha thoda over ya under shoot kar deta hai. Heun's method (Modified Euler) bolta hai —
"itni jaldi mat karo, pehle aage jhaank ke dekho."
Trick simple hai: pehle ek predictor step lo (yeh bilkul plain Euler hai) — isse ek
guess milta hai ki end pe y kya hoga. Us guessed point pe slope nikaalo. Ab tumhare paas
do slope hain — ek shuru ka (k1) aur ek end ka (k2). In dono ka average lo, aur usse
asli step maaro: y1=y0+2h(k1+k2). Yeh average wala kaam hi
trapezoidal rule hai integration ka, isliye accuracy badhti hai.
Kyun important hai? Kyunki Heun second order hai (O(h2)) jabki Euler sirf first order
(O(h)). Matlab agar tum step size h aadha karo, toh Euler ki galti aadhi hoti hai par Heun
ki galti chaar guna kam ho jaati hai. Itna fayda sirf ek extra f evaluation se! Yaad
rakhne ka formula: P-A-C — Predict, Average, Correct. Bas 2h wala factor mat
bhoolna, warna double step pad jaayega.