4.6.2Ordinary Differential Equations

Direction fields and Euler's method — visual - numerical intuition first

1,900 words9 min readdifficulty · medium2 backlinks

1. What is a direction field?

WHY it works: The ODE is a constraint "your slope here must equal f(x,y)f(x,y)." The segment just visualises that constraint. A solution is any curve that obeys the constraint everywhere.


2. Euler's method — derive it from scratch

We can't always solve the ODE with formulas. But we can follow the arrows numerically.

Derivation (first principles — local linear approximation):

The derivative is the slope of the tangent line. Near xnx_n, the true solution is well-approximated by its tangent: y(xn+h)y(xn)+hy(xn).y(x_n+h) \approx y(x_n) + h\cdot y'(x_n).

This is just the first-order Taylor expansion: y(xn+h)=y(xn)+hy(xn)+h22y(ξ).y(x_n+h)=y(x_n)+h\,y'(x_n)+\tfrac{h^2}{2}y''(\xi).

But the ODE gives us y(xn)=f(xn,yn)y'(x_n)=f(x_n,y_n). Substitute and drop the h2h^2 remainder:


3. Worked example: walk it by hand

Figure — Direction fields and Euler's method — visual - numerical intuition first

4. Common mistakes (Steel-man + fix)


5. Active recall

Recall Quick self-test (hide answers)
  • Q: What does f(x,y)f(x,y) in y=f(x,y)y'=f(x,y) physically give you? → the slope of the solution at (x,y)(x,y).
  • Q: Euler update formula? → yn+1=yn+hf(xn,yn)y_{n+1}=y_n+h f(x_n,y_n).
  • Q: Order of global error? → O(h)O(h) (first order).
  • Q: Where does Euler evaluate the slope? → at the current/left point.
Recall Feynman: explain to a 12-year-old

Imagine you're walking in fog and a magic compass tells you which way is "downhill" right where you stand. You can't see the whole hill, but you take a small step in that direction, ask the compass again, take another small step, and so on. The path you trace is your best guess of the trail. The ODE is the magic compass; Euler's method is taking tiny steps. Tiny steps = closer to the real trail, but you do more work.


6. Connections


What does f(x,y)f(x,y) in y=f(x,y)y'=f(x,y) tell you geometrically?
The slope of the solution curve at the point (x,y)(x,y).
Define a direction (slope) field.
At each point (x,y)(x,y) a short segment of slope f(x,y)f(x,y); solutions are curves tangent to these segments everywhere.
What is an isocline?
The locus f(x,y)=mf(x,y)=m where all field segments share the same slope mm.
State Euler's method update.
yn+1=yn+hf(xn,yn)y_{n+1}=y_n+h\,f(x_n,y_n) with xn+1=xn+hx_{n+1}=x_n+h.
Derive Euler from Taylor.
y(xn+h)=yn+hyn+h22y(ξ)y(x_n+h)=y_n+h y'_n+\tfrac{h^2}{2}y''(\xi); replace yn=f(xn,yn)y'_n=f(x_n,y_n) and drop the O(h2)O(h^2) term.
What is the local truncation error of Euler?
h22y(ξ)\tfrac{h^2}{2}y''(\xi), i.e. O(h2)O(h^2) per step.
What is the global error order of Euler?
O(h)O(h) — first order; halving hh roughly halves total error.
Which point's slope does explicit Euler use?
The current (left) point (xn,yn)(x_n,y_n), not the new one.
Why does Euler undershoot a convex (y>0y''>0) solution?
Tangent lines lie below a convex curve, so each step lands too low.
Common error: omitting which factor?
Multiplying the slope by the step hh; Δy=hf\Delta y=h f, not ff.

Concept Map

gives

visualised as

parallel dashes build

tangent everywhere

starting point

drop h squared term

supplies f in

initial value for

dropped term is

accumulates over N steps

ODE dy/dx = f of x,y

Slope at every point

Direction field

Isoclines f=m

Solution curve

Initial condition x0,y0

Taylor expansion

Euler's method

Local error O of h squared

Global error O of h

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, ek first-order ODE dydx=f(x,y)\frac{dy}{dx}=f(x,y) tumhe seedha yy nahi batati — wo har point (x,y)(x,y) par solution curve ka slope batati hai. Matlab plane ke har jagah ek chhota sa arrow (dash) bana sakte ho jiska tilt f(x,y)f(x,y) ke barabar ho. In saare dashes ka collection hi direction field (slope field) hai. Solution curve wahi hai jo har point par us dash ke "tangent" ho — bas arrows ko follow karte jao, manzil mil jayegi.

Jab formula se solve nahi hota, tab Euler's method kaam aata hai. Idea simple hai: agar tum ek point par khade ho aur slope ff pata hai, to thoda sa step hh aage chalo us slope ke direction me. Taylor expansion se: y(x+h)y+hyy(x+h)\approx y+h\,y', aur y=f(x,y)y'=f(x,y), to formula banta hai yn+1=yn+hf(xn,yn)y_{n+1}=y_n+h\,f(x_n,y_n). Yaad rakhne ka tarika: "Stand, Slope, Step" — khade ho, slope padho, step lo. Dhyan rahe slope ko hh se multiply karna zaroori hai, kyunki slope "rise per run" hai aur rise == slope ×h\times h.

Error ki baat: har ek step me chhoti si galti h2\sim h^2 hoti hai, aur L/hL/h steps lagte hain, to total error h\sim h — isliye Euler ko first-order method kehte hain. hh aadha karo to error lagभग aadha. Lekin bahut zyada steps lene par rounding error bhi badhta hai, aur stiff equations me blow up ho sakta hai — isliye aage RK4 jaise better methods aate hain.

Exam aur intuition dono ke liye golden point: pehle field ka picture socho (kaunsi taraf curve jhuk raha hai), phir Euler ke number nikaalo, aur exact solution se compare karke dekho ki Euler overshoot kar raha hai ya undershoot — convex curve (y>0y''>0) me Euler hamesha neeche reh jaata hai.

Go deeper — visual, from zero

Test yourself — Ordinary Differential Equations

Connections