4.8.28 · D3 · Maths › Numerical Methods › Boundary value problems — shooting method, finite difference
Intuition Yeh page kis liye hai
Parent note ne do engines banaye the: Shooting aur Finite Difference. Yeh page dono ko har road condition se guzaarta hai — linear, nonlinear, convection terms, degenerate grids, limiting refinement, ek physics word problem, aur ek sneaky exam twist. Har example ko uss matrix cell ke saath tag kiya gaya hai jo woh fill karta hai, taaki aap dekh sako ki koi gap nahi hai.
Shuru karne se pehle, ek self-contained toolkit — neeche use hone waale har symbol ki definition yahan di gayi hai.
Definition Linear-BVP finite-difference template (yahan defined, neeche har jagah use hoga)
Ek general linear second-order BVP aise likha jaata hai
y ′′ = p ( x ) y ′ + q ( x ) y + r ( x ) , y ( a ) = α , y ( b ) = β .
==p ( x ) == pehli derivative y ′ ko multiply karta hai — yeh convection term hai (ek "drift" jo ek direction mein push karta hai).
==q ( x ) == y ko hi multiply karta hai — yeh reaction/stiffness term hai.
==r ( x ) == source hai — isme koi y nahi hota (forcing, heating waali cheezein).
[ a , b ] ko N barabar steps mein chop karo, width h = N b − a ; interior nodes hain x 1 , … , x N − 1 . y ′ aur y ′′ ko central differences se replace karke h 2 se multiply karne par, har interior node i par yeh three-coefficient stencil milta hai:
lower ( 1 + 2 h p i ) y i − 1 diag − ( 2 + h 2 q i ) y i + upper ( 1 − 2 h p i ) y i + 1 = RHS h 2 r i .
jahan p i = p ( x i ) , etc. Yahi ek FDM formula hai jo hum use karte hain; har example bas isme numbers plug karta hai.
Common mistake Teen traps jinhe hum inline flag karte hain (yahan defined, neeche naam se referenced)
Trap "RHS": jaane-maane boundary values y 0 = α aur y N = β ko right-hand side par move karna zaroori hai jab woh i = 1 ya i = N − 1 par stencil mein aate hain. Yeh bhool gaye toh matrix ka size galat ho jaayega.
Trap "refine": kabhi bhi ek akele grid par bharosa mat karo. h ko halve karo aur check karo ki error ≈ 4 × girti hai (kyunki central differences O ( h 2 ) hain). Agar nahi girti, toh setup galat hai.
Trap "order": y ′ ke liye central difference use karo (yeh O ( h 2 ) hai); ek one-sided forward difference sirf O ( h ) hai aur poore scheme ko first order par le aata hai.
Do aur words jinhe hum baar baar use karte hain:
Interior node : ek grid point jo strictly do ends ke beech ho — jinhe hume solve karna hota hai . Ends pehle se diye hote hain.
Residual : humara current answer rule ko satisfy karne se kitna door hai. Shooting ke liye yeh hai ϕ ( s ) = y ( b ; s ) − β : humari shot jahan aakar giri aur bucket β ke beech ka gap.
Cell
Kya cheez alag hai
Example
A. Linear + shooting
ϕ ( s ) seedhi line hai → 2 shots mein exact
Ex 1
B. Nonlinear + shooting
ϕ ( s ) curved hai → secant iterate karna padega
Ex 2
C. Linear FDM, p = 0
symmetric tridiagonal, koi convection nahi
Ex 3
D. Linear FDM, p = 0
asymmetric off-diagonals (convection)
Ex 4
E. Degenerate grid (N = 2 )
sirf EK interior node → single equation
Ex 3 ke andar
F. Limiting case: refine h
check karo ki error ∝ h 2 girti hai (h halve → 4 1 error)
Ex 5
G. Sign check: kis taraf aakar gire?
overshoot vs undershoot, negative residual
Ex 6
H. Real-world word problem
heated rod, units, physical read-off
Ex 7
I. Exam twist: derivative (Neumann) boundary
y ′ ( b ) diya gaya hai, y ( b ) nahi → ghost node
Ex 8
Har method-cell (A–I) neeche kam se kam ek baar hit hoti hai.
y ′′ = 4 y , y ( 0 ) = 0 , y ( 1 ) = sinh 2 ko shooting se solve karo.
True solution hai y = sinh ( 2 x ) , toh y ′ ( 0 ) = 2 . Pretend karo ki hume yeh pata nahi.
Forecast: ODE linear hai, toh exact answer milne se pehle kitne shots chahiye — 2, 5, ya "infinitely many"?
Shot 1: guess s 0 = 0 . y ′′ = 4 y , y ( 0 ) = 0 , y ′ ( 0 ) = 0 solve karne par y ≡ 0 milta hai, toh y ( 1 ; 0 ) = 0 .
Yeh step kyun? Hume ek data point ( s , landing ) chahiye. Zero slope sabse sasta probe hai — yeh baseline landing batata hai.
Shot 2: guess s 1 = 1 . Linearity se y = 2 1 sinh ( 2 x ) (slope-1 solution), toh y ( 1 ; 1 ) = 2 1 sinh 2 ≈ 1.8134 .
Yeh step kyun? Ek line ko do points chahiye. Ab hume do slopes par ϕ pata hai.
Root tak interpolate karo. Target β = sinh 2 ≈ 3.6269 :
s ⋆ = s 0 + ( s 1 − s 0 ) y ( 1 ; s 1 ) − y ( 1 ; s 0 ) β − y ( 1 ; s 0 ) = 0 + 1 ⋅ 1.8134 − 0 3.6269 − 0 = 2.0.
Yeh step kyun? Linear ODEs ke liye y ( b ; s ) , s mein ek seedhi line hai, toh exact root ek interpolation mein mil jaata hai — koi iteration nahi.
Verify: s ⋆ = 2 true y ′ ( 0 ) = 2 se exactly match karta hai. Forecast answer: 2 shots. ✓
y ′′ = y 2 , y ( 0 ) = 0 , y ( 1 ) = 1 ko shooting se solve karo.
y 2 ki wajah se ODE nonlinear hai, toh ϕ ( s ) ek curve hai, seedhi line nahi.
Forecast: kya do shots isko nail kar denge, ya do baar interpolate karne ke baad bhi residual nonzero rahega?
Clean, checkable arithmetic ke liye hum secant formula ko made-up-but-consistent landing data par use karte hain. Maan lo IVP solver yeh return karta hai:
y ( 1 ; s 0 = 0.5 ) = 0.60 , y ( 1 ; s 1 = 1.0 ) = 1.30.
Target β = 1 , toh residuals ϕ 0 = 0.60 − 1 = − 0.40 , ϕ 1 = 1.30 − 1 = + 0.30 .
Secant step.
s 2 = s 1 − ϕ 1 ϕ 1 − ϕ 0 s 1 − s 0 = 1.0 − 0.30 ⋅ 0.30 − ( − 0.40 ) 1.0 − 0.5 .
Yeh step kyun? Hum curve ϕ ( s ) ko last do points se seedhi line se approximate karte hain aur uska root nikalte hain — secant idea, ϕ ki derivative ki zaroorat nahi.
Arithmetic. 0.70 0.5 = 0.7143 ; 0.30 × 0.7143 = 0.2143 ; toh s 2 = 1.0 − 0.2143 = 0.7857 .
Yeh step kyun? Yeh agla, better slope guess hai.
Abhi khatam nahi! Hume s 2 par nayi IVP fire karni hai, naya residual lena hai, aur repeat karna hai — kyunki true ϕ hamaari line se curve ho jaata hai.
Yeh step kyun? Curved ϕ par, ek secant line sirf root ko approximate karti hai; iteration ∣ ϕ ∣ → tol tak le jaata hai.
Verify: residual ne zero ko straddle kiya (ϕ 0 < 0 < ϕ 1 ), toh root 0.5 aur 1.0 ke beech bracketed hai; humara s 2 = 0.7857 andar land karta hai — ek sane secant step. Forecast answer: iterate karo, do shots nahi. ✓
y ′′ = y , y ( 0 ) = 0 , y ( 1 ) = sinh 1 , N = 2 lo toh h = 0.5 .
Template se match karo: p = 0 , q = 1 , r = 0 . N = 2 ke saath exactly ek interior node hai x 1 = 0.5 — yeh degenerate case hai.
Forecast: sirf ek unknown ke saath, kitni equations solve karni padengi — ek system, ya ek single line?
Grouped stencil likho template se p = 0 , q = 1 use karke:
( 1 ) y 0 − ( 2 + h 2 ) y 1 + ( 1 ) y 2 = 0.
Yeh step kyun? p = 0 substitute karne se off-diagonal asymmetry khatam ho jaati hai (lower = upper = 1 ); q = 1 , h 2 = 0.25 middle coefficient fix karta hai.
Boundary values insert karo y 0 = 0 , y 2 = sinh 1 = 1.1752 :
0 − 2.25 y 1 + 1.1752 = 0.
Yeh step kyun? y 0 , y N known numbers hain — inhe RHS par move karo (Trap "RHS" ).
Ek equation solve karo. y 1 = 2.25 1.1752 = 0.5223.
Yeh step kyun? Ek interior node ⇒ tridiagonal system ek scalar equation mein collapse ho jaata hai (Cell E).
Verify: true sinh ( 0.5 ) = 0.5211 ; error ≈ 0.0012 . 2 intervals ke saath bhi chhota, aur yeh h 2 ki tarah shrink karega (agle example mein prove hoga). ✓
y ′′ = 2 y ′ − y + e x , y ( 0 ) = 1 , y ( 1 ) = e , N = 4 lo toh h = 0.25 . Node i = 1 (x 1 = 0.25 ) par equation likho.
Template se match karo: p = 2 , q = − 1 , r = e x . Ab off-diagonals alag hain — yeh asymmetry hi convection hai.
Forecast: kya y i − 1 (lower) ko multiply karne wala coefficient y i + 1 (upper) wale se bada ya chhota hoga?
Teen coefficients compute karo h = 0.25 ke saath:
lower = 1 + 2 h p = 1 + 0.25 = 1.25 ,
diag = − ( 2 + h 2 q ) = − ( 2 + 0.0625 ⋅ ( − 1 )) = − ( 2 − 0.0625 ) = − 1.9375 ,
upper = 1 − 2 h p = 1 − 0.25 = 0.75 .
Yeh step kyun? Template ke lower/diag/upper slots mein seedha substitution.
RHS = h 2 e x 1 = 0.0625 e 0.25 = 0.0625 ⋅ 1.2840 = 0.08025 .
Yeh step kyun? r ( x ) = e x ko node par evaluate karo, h 2 se scale karo.
i = 1 par equation (y 0 = 1 right par move karke):
− 1.9375 y 1 + 0.75 y 2 = 0.08025 − 1.25 ( 1 ) = − 1.16975.
Yeh step kyun? y 0 known hai; 1.25 y 0 ko RHS par subtract karo (Trap "RHS" ).
Verify: p = 2 > 0 ke saath, term 2 h p lower mein add hoti hai (1.25 ) lekin upper se subtract hoti hai (0.75 ), toh lower > upper — upwind side heavy hai, yahi positive convection produce karta hai. Forecast answer: lower bada hai. ✓
Worked example Ex 3 ka FDM lo (
y ′′ = y , exact sinh ) x = 0.5 par N = 2 aur N = 4 ke liye. Confirm karo ki error quarter ho jaata hai.
Forecast: h ko halve karne par (0.5 se 0.25), error lagbhag... 2, 4, ya 8 ke factor se shrink hogi?
N = 2 error (Ex 3): ∣0.5223 − 0.5211∣ = 0.00122 .
Yeh step kyun? Yeh humara coarse-grid benchmark hai.
N = 4 system explicitly set up karo. Ab h = 0.25 , h 2 = 0.0625 ; interior nodes x 1 = 0.25 , x 2 = 0.5 , x 3 = 0.75 . p = 0 , q = 1 ke saath har diagonal − ( 2 + h 2 ) = − 2.0625 hai aur har off-diagonal 1 hai. Boundaries y 0 = 0 , y 4 = sinh 1 = 1.1752 RHS par jaati hain (Trap "RHS" ), toh
⎩ ⎨ ⎧ − 2.0625 y 1 + y 2 = − y 0 = 0 , y 1 − 2.0625 y 2 + y 3 = 0 , y 2 − 2.0625 y 3 = − y 4 = − 1.1752.
Yeh step kyun? Finer grid ka matlab hai teen coupled interior equations — ek genuine tridiagonal system.
Thomas method se solve karo (forward-eliminate, back-substitute).
Row 1: y 1 = y 2 /2.0625 .
Row 2 mein substitute karo: ( y 2 /2.0625 ) − 2.0625 y 2 + y 3 = 0 ⇒ − 1.5776 y 2 + y 3 = 0 ⇒ y 3 = 1.5776 y 2 .
Row 3 mein substitute karo: y 2 − 2.0625 ( 1.5776 y 2 ) = − 1.1752 ⇒ y 2 ( 1 − 3.2538 ) = − 1.1752 ⇒ y 2 = − 2.2538 − 1.1752 = 0.52140.
Yeh step kyun? Thomas basically Gaussian elimination hai jo tridiagonal shape ka fayda uthata hai — diagonal ke neeche eliminate karo, phir jo value chahiye uske liye back-substitute karo, y 2 = y ( 0.5 ) .
N = 4 error: ∣0.52140 − 0.52110∣ = 0.00030 . Ratio 0.00030 0.00122 ≈ 4.1 .
Yeh step kyun? Yeh observed error-shrink factor hai.
Verify: central stencil O ( h 2 ) hai, toh h halve karne se × 4 1 error predict hoti hai. Humne dekha ≈ 4.1 × chhota — match karta hai (Trap "refine" : trust karne ke liye hamesha refine karo). Forecast answer: factor 4. ✓
Figure: y ′′ = y , y ( 0 ) = 0 ke liye teen shooting attempts, sabhi left end se launch ki gayi hain. Magenta curve (slope s 0 = 0 ) flat rehti hai aur navy dashed "bucket" line β = sinh 1 se neeche khatam hoti hai — undershoot. Violet curve (slope s 1 = 2 ) steeply upar jaati hai aur bucket se upar khatam hoti hai — overshoot. Orange curve (slope s ⋆ = 1 ) exactly bucket par land karti hai. Residual ka sign seedha picture se padho: dashed line ke neeche ⇒ ϕ < 0 , upar ⇒ ϕ > 0 , us par ⇒ ϕ = 0 .
y ′′ = y , y ( 0 ) = 0 , y ( 1 ) = sinh 1 ≈ 1.1752 ke liye, do shooting shots ko sign se interpret karo.
Forecast: agar hum slope s 0 = 0 se shoot karte hain, toh kya hum bucket β se short land karenge ya aage ?
Shot s 0 = 0 : y ( 1 ; 0 ) = 0 . Residual ϕ 0 = 0 − 1.1752 = − 1.1752 < 0 .
Yeh step kyun? Negative residual ka matlab hai hum target se neeche/short land kiye — undershoot. Figure mein yeh magenta path hai jo navy dashed bucket line ke neeche khatam hoti hai.
Shot s 1 = 2 : y ( 1 ; 2 ) = 2 sinh 1 ≈ 2.3504 . Residual ϕ 1 = 2.3504 − 1.1752 = + 1.1752 > 0 .
Yeh step kyun? Positive residual ka matlab hai humne over shoot kiya — violet path bucket ke upar khatam hoti hai.
Root bracketed hai. Kyunki ϕ 0 < 0 < ϕ 1 , true slope 0 aur 2 ke beech hai; interpolation s ⋆ = 1 par land karti hai (orange path, jo bucket ko touch karti hai).
Yeh step kyun? Opposite signs ek crossing guarantee karte hain — "ek chhote shot aur ek lambe shot ke beech aim karo" ka geometric matlab.
Verify: s ⋆ = 0 + 2 ⋅ 2.3504 − 0 1.1752 − 0 = 1.0 , true slope. Sign logic aur root agree karte hain. ✓
L = 1 m lambe ek rod mein internal source ke saath heat conduct hoti hai. Steady temperature T ( x ) yeh obey karta hai:
T ′′ = − 100 ( ∘ C / m 2 ) , T ( 0 ) = 2 0 ∘ C , T ( 1 ) = 2 0 ∘ C .
FDM se N = 2 (h = 0.5 ) leke mid-rod temperature T ( 0.5 ) estimate karo.
Forecast: dono ends 2 0 ∘ par hain aur andar heating hai, toh kya middle 2 0 ∘ se zyada garam ya thanda hoga?
Template se match karo. T ′′ = 0 ⋅ T ′ + 0 ⋅ T + ( − 100 ) likhte hain, toh p = 0 , q = 0 , r = − 100 .
Yeh step kyun? p , q , r padhne se hum ek hi stencil formula reuse kar sakte hain.
x 1 = 0.5 par stencil , h 2 = 0.25 : y 0 − 2 y 1 + y 2 = h 2 r = 0.25 ( − 100 ) = − 25.
Yeh step kyun? p = q = 0 pure "1, −2, 1" stencil deta hai; RHS mein source r aata hai.
T 0 = T 2 = 20 insert karo: 20 − 2 T 1 + 20 = − 25 ⇒ − 2 T 1 = − 65 ⇒ T 1 = 32. 5 ∘ C .
Yeh step kyun? Dono ends known hain; single equation midpoint deta hai (Trap "RHS" applied).
Verify: exact solution T = 20 + 50 x ( 1 − x ) deta hai T ( 0.5 ) = 20 + 50 ( 0.25 ) = 32. 5 ∘ C — exactly match karta hai (constant r ke liye central stencil is parabola par exact hai). Units poore mein ∘ C hain. Forecast answer: zyada garam, 32. 5 ∘ . ✓
y ′′ = y , y ( 0 ) = 0 , y ′ ( 1 ) = cosh 1 ≈ 1.5431 (right end par slope diya gaya hai). N = 2 , h = 0.5 lo; equations set up karo.
Right boundary ab ek derivative hai, value nahi — classic exam curveball.
Forecast: x = 1 par koi y 2 value humein di nahi gayi. Missing equation kahan se aayegi?
Ghost node y 3 introduce karo x 3 = 1.5 par (rod ke thoda bahar) aur central derivative boundary node x 2 = 1 par likho:
y ′ ( 1 ) ≈ 2 h y 3 − y 1 = cosh 1 ⇒ y 3 = y 1 + 2 h cosh 1 = y 1 + 1.5431.
Yeh step kyun? Boundary par central (one-sided nahi) difference use karne se O ( h 2 ) accuracy maintain rehti hai (Trap "order" ). Ghost node y 3 woh fictitious value hai jo central formula ko chahiye.
DONO unknown nodes i = 1 , 2 par y ′′ = y stencil likho (yahan p = 0 , q = 1 , h 2 = 0.25 , diag = − 2.25 ):
i = 1 : y 0 − 2.25 y 1 + y 2 = 0 , i = 2 : y 1 − 2.25 y 2 + y 3 = 0.
Yeh step kyun? Node 2 ab ek unknown hai (sirf uska slope diya gaya tha, value nahi), toh isko apna stencil equation chahiye — aur us equation mein ghost y 3 hai.
Ghost ko eliminate karo. y 3 = y 1 + 1.5431 (step 1 se) ko node-2 equation mein substitute karo:
y 1 − 2.25 y 2 + ( y 1 + 1.5431 ) = 0 ⇒ 2 y 1 − 2.25 y 2 = − 1.5431.
Yeh step kyun? Ghost value ab ek real unknown aur known data ke terms mein express ho gayi, toh woh gayab ho jaati hai aur hum ek solvable 2 × 2 system ke saath bach jaate hain.
2 × 2 solve karo y 0 = 0 ke saath:
i = 1 se: − 2.25 y 1 + y 2 = 0 ⇒ y 2 = 2.25 y 1 . Step-3 equation mein sub karo: 2 y 1 − 2.25 ( 2.25 y 1 ) = − 1.5431 ⇒ ( 2 − 5.0625 ) y 1 = − 1.5431 ⇒ y 1 = − 3.0625 − 1.5431 = 0.5039. Phir y 2 = 1.1338.
Yeh step kyun? Back-substitution — ek chhote system ke liye haath se Thomas idea.
Verify: exact y = sinh x deta hai sinh ( 0.5 ) = 0.5211 aur sinh ( 1 ) = 1.1752 . Humara coarse N = 2 estimate 0.5039 , 1.1338 sahi ballpark mein hai aur h → 0 ke saath converge karega. Ghost-node trick ne correctly missing equation supply ki. ✓
Recall Rapid self-test
Kaun sa matrix cell iteration maangta hai even though shooting use ho rahi hai? ::: Cell B — nonlinear ODE ϕ ( s ) ko curved banata hai.
Negative residual ϕ ( s 0 ) < 0 ka matlab hai hum shot... ::: short (target β se undershoot kar gaye).
Central-difference FDM mein h halve karne se error roughly... ::: 4 1 factor se change hoti hai (yeh O ( h 2 ) hai).
Neumann boundary y ′ ( b ) diye hone par, hum kya add karte hain? ::: ek ghost node plus slope ke liye central-difference equation.
p > 0 hone par lower off-diagonal upper se bada kyun hota hai? ::: convection term 2 h p lower mein add hoti hai, upper se subtract hoti hai.
Mnemonic Cover-the-matrix checklist
"Line Once, Curve Iterate, Grid Then Ghost."
Linear shoot = ek interpolation; nonlinear = secant loop; FDM interior ko grid karta hai; slope-boundary ek ghost node add karta hai.