4.8.27 · D3 · HinglishNumerical Methods

Worked examplesSystems of ODEs — RK4 for systems

2,965 words13 min read↑ Read in English

4.8.27 · D3 · Maths › Numerical Methods › Systems of ODEs — RK4 for systems

Kisi bhi example se pehle, ek reminder us machinery ka jo hum baar baar reuse karte hain.

Yahan "vector" ka matlab sirf numbers ki ek ordered list hai, ek number har unknown ke liye. Agar hum do quantities track kar rahe hain, to ek plane mein ek point hai, aur ek aisa pair return karta hai — direction aur speed jisme har quantity abhi move kar rahi hai. Notation ka yahi matlab hai.


Scenario matrix

Is topic ka har problem in cells mein se kisi ek mein aata hai. Neeche ke worked examples mein se har ek ko us cell ke saath tag kiya gaya hai jo wo cover karta hai, taaki milke poora grid fill ho jaye.

Cell Kya alag banata hai Example
A. Coupled, mixed signs dono doosre variable pe depend karte hain, opposite signs (rotation) Ex 1
B. Decoupled system equations ek doosre ko reference nahi karte — ek sanity check Ex 2
C. Reduced 2nd-order ek single higher-order ODE ko system mein convert kiya Ex 3
D. Nonlinear word problem unknowns ke products, real units (predator–prey) Ex 4
E. Degenerate / steady state initial state jahan (kuch nahi hona chahiye) Ex 5
F. All-positive growth dono variables grow karte hain, positive slopes throughout Ex 6
G. Limiting / stiff twist ek component itni tez decay karta hai ki step size matter karta hai Ex 7
H. Non-autonomous explicitly pe depend karta hai, sirf pe nahi Ex 8

"Sign behaviour" ke columns (dono slopes negative, dono positive, mixed, zero) aur "structure" ke rows (coupled / decoupled / reduced / nonlinear / stiff / time-dependent) sab cover ho jaate hain. Neeche ki figure in chaar cells mein se chaar ko state space mein motions ke roop mein plot karti hai, taaki aap arithmetic grind karne se pehle dekh sako ki scenarios kitne alag hain.

Figure — Systems of ODEs — RK4 for systems

Figure ko ek map ki tarah padhiye: blue arc (Cell A, Ex 1) ek point hai jo circle pe curve kar raha hai — mixed signs isse rotate karte hain; orange arrow (Cell B, Ex 2) dikhata hai ki ek coordinate shrink ho rahi hai jabki doosri grow kar rahi hai — ek decoupled system; green curve (Cell F, Ex 6) mein dono coordinates milke baahir race kar rahe hain — pure growth; red dot (Cell E, Ex 5) ek fixed point pe frozen baitha hai — kuch nahi hil raha. Jab neeche har example in paths mein se ek trace kare to is picture ko apne zehan mein rakhna.


Ex 1 — Cell A: coupled rotation, mixed signs

Forecast: ye ek point ki equations hain jo circle pe spin kar raha hai (position aur velocity ek doosre ko opposite signs ke saath feed kar rahe hain). Ek chhote step ke baad ko se thoda neeche jaana chahiye aur ko thoda negative hona chahiye. Kyunki RK4 order 4 hai, ~4 correct digits expect karo.

Yahan . Yeh figure mein blue arc hai.

  1. . Yeh step kyun? Current state pe slope — yeh hai jahan abhi ja raha hai.
  2. Midpoint state , to . Yeh step kyun? Step ke predicted middle mein slope dobara measure karo — dono components advanced state use karte hain.
  3. , to . Yeh step kyun? Ek refined midpoint slope, ko correct karta hua.
  4. , to . Yeh step kyun? Interval ke end ka slope.
  5. Combine weights over ke saath: Yeh step kyun? Ab hum charon slope vectors ko ek best estimate mein blend karte hain step ki average velocity ka (beech ke slopes double — Simpson weighting) aur ko us average times se move karte hain. Yahi state ka actual advance hai.

Verify: (~5 decimals tak match), (~4 decimals tak match). Ek step mein agreement. Forecast confirmed.


Ex 2 — Cell B: decoupled sanity check

Forecast: dono equations kabhi ek doosre ka zikr nahi karti. Ek decoupled system pe RK4 ko, component-by-component, exactly wahi reproduce karna chahiye jo scalar RK4 har equation pe alag se dega. shrink hogi (negative slope), tez grow karegi (slope ). Yeh figure mein orange arrow hai.

Yahan .

  1. . Kyun? pe slope.
  2. State , . Kyun? Midpoint slope.
  3. State , . Kyun? Refined midpoint.
  4. State , . Kyun? End slope.
  5. Combine: Yeh step kyun? Har component ko apna blend milta hai — kyunki equations decoupled hain, yeh literally scalar RK4 hai jo do baar parallel mein run ho raha hai.

Verify: (error ), (error ). Bada growth rate () per unit ek bada step banata hai, isliye uska error bada hai — expected. Dono wahi same numbers hain jo aapko scalar RK4 har line pe akele run karne se milte.


Ex 3 — Cell C: ek 2nd-order ODE ko reduce karna

Forecast: yeh reduction trick hai. ke saath exact solution hai, to ko track karna chahiye.

Set karo . Tab to , starting at .

  1. . Kyun? pe slope: , .
  2. State , . Kyun? Midpoint slope — components swap karo.
  3. State , . Kyun? Refined midpoint.
  4. State , . Kyun? End slope.
  5. Combine (dono components yahan identical hain kyunki throughout hai): Yeh step kyun? Charon slopes ko fixed weights ke saath blend karo (aur ) ko ek step advance karne ke liye; reduction ne is averaging mein kuch nahi badla.

Verify: ; error . 2nd-order ODE usi systems recipe se solve hua — reduction karne ki koi cost nahi thi.


Ex 4 — Cell D: nonlinear predator–prey word problem

Forecast: ke products isko nonlinear banate hain — coupling multiplicative hai. Shuru mein aur : rabbits momentarily steady, foxes rise kar rahe hain. To expect karo (nearly flat) aur roughly tak.

Yahan , state .

  1. . Kyun? Current slopes.
  2. State ; . Kyun? Midpoint slope, dono populations advance.
  3. State ; , to . Kyun? Refined midpoint.
  4. State ; , to . Kyun? End slope.
  5. Combine: Yeh step kyun? Chahe nonlinear ho, averaging step unchanged hai — hum phir bhi charon slope vectors ko over se weight karte hain. Nonlinearity sirf affect karti hai ki har kaise compute hua, unhe blend karne ke tarike ko nahi.

Verify: rabbits hazaar (barely girre, jaise forecast tha — wo apne peak ke near the), foxes hazaar (rise kiye, jaise forecast tha). Units throughout animals ke hazaar hain; koi negative populations nahi aayi.


Ex 5 — Cell E: degenerate steady state

Forecast: pe aur milte hain — field exactly zero hai. Ek steady state ka matlab hai kuch nahi hona chahiye: answer dobara hona chahiye, machine precision tak. Yeh woh degenerate case hai jo sloppy code ko pakad leta hai — figure mein red dot.

  1. . Kyun? Fixed point pe slope definition se zero hai.
  2. State ; . Kyun? Hum kabhi se bahar nahi gaye, to slope abhi bhi zero hai.
  3. State ; . Kyun? Same reasoning.
  4. State ; . Kyun? Same.
  5. Combine: . Yeh step kyun? Chaar zero vectors ka blend zero hai, to average velocity zero hai aur state advance nahi hota — exactly wahi jo ek equilibrium demand karta hai.

Verify: state unchanged hai — RK4 equilibria ko exactly respect karta hai (kyunki har ). Agar aapke program ne "akele ek component advance kiya hota," to shayad fixed point se thoda hat jaata; synchronized recipe aisa nahi karti.


Ex 6 — Cell F: all-positive growth

Forecast: aur field ke saath jo "har component doosre ki value pe grow kare," dono slopes throughout positive rehte hain — pure exponential growth. Expect karo ki dono reach karen. Yeh figure mein green curve hai.

Yahan , state .

  1. . Kyun? Start pe slope.
  2. State , . Kyun? Midpoint.
  3. State , . Kyun? Refined midpoint.
  4. State , . Kyun? End slope.
  5. Combine (dono components identical): Yeh step kyun? Chaar positive slopes ko over se weight karo aur aage badhao; doubled midpoints exponential ki accelerating curve ko accurate rakhte hain.

Verify: ; error . Dono slopes forecast ke mutabiq positive rahi.


Ex 7 — Cell G: limiting / stiff twist

Forecast: true solution hai; pe woh hai. Lekin fast component rate ke saath decay karta hai, aur bada hai. ke liye RK4 ki stability limit roughly chahiye. ke saath hum iske bahar hain — expect karo ki estimate reason se aage blow karega (possibly wrong sign ya magnitude), jabki (rate , ) theek rahega.

compute karo (ek scalar RK4 ke saath, , to ). Linear ke liye, ek RK4 step multiply karta hai

  1. . Kyun? Step ka stability argument.
  2. . Kyun? Polynomial mein plug karo.
  3. To . Kyun? Ek step state ko se scale karta hai — yeh factor hai ek linear field ke liye four-slope blend ka combined effect.
  4. ke liye: , . Kyun? Chhota , safely stable.

Verify: true lekin RK4 ne diya — ek catastrophic overshoot (factor se galat, aur to yeh har step grow karega). ne diya vs true — perfect. Fix: chhota karo taaki stiffest rate ke liye ho, matlab , ya ek implicit method use karo. Explicit RK4 sabse fast component se limited hota hai.


Ex 8 — Cell H: non-autonomous (explicit )

Forecast: ab explicitly mention karta hai, to aur arguments actually matter karte hain — yeh woh case hai jahan time advance karna bhool jaane se sab galat ho jaata hai. Start slope , : position rise kar rahi hai, velocity flat. Kyunki exact answer straight line hai, RK4 ko aur essentially zero error ke saath return karna chahiye.

Yahan , state at .

  1. . Kyun? , state pe slopes.
  2. , state ; . Kyun? Midpoint — note karo ki humne use kiya, nahi.
  3. State ; . Kyun? pe refined midpoint.
  4. , state ; . Kyun? End, pe.
  5. Combine: Yeh step kyun? Charon slopes ka blend average velocity deta hai, to hum se step karte hain — lekin sirf isliye kyunki humne har ko correct time pe evaluate kiya.

Verify: exact solution hai (check: , to ✓; , ✓), jisse aur milta hai. RK4 ne exactly aur return kiya — zero error. Yeh isliye hua kyunki humne har stage mein sahi se advance kiya; agar hum freeze karte, to term galat time pe evaluate hota aur answer galat hota.


Recall

Recall Quick self-test

Ex 5 exactly apni jagah kyun raha? ::: Fixed point pe hai, to charon vanish ho jaate hain aur weighted average kuch add nahi karta. Ex 7 ne ke near ki bajaye kyun return kiya? ::: RK4 amplification at equals hai, to step decay ki bajaye amplify karta hai — hum stability region ke bahar the. Ex 8 mein agar aap har stage mein rakhte to kya break hota? ::: term galat time pe evaluate hota, galat 's milte aur exact answer kho jaata.


Connections

  • Parent: RK4 for systems
  • RK4 for a single ODE — Ex 2 dikhata hai ki decoupled case isme reduce ho jaata hai.
  • Reducing higher-order ODEs to first-order systems — Ex 3, Ex 8.
  • Euler's method for systems — sasta cousin; agar accuracy gap dekhna ho to in examples ko iske saath try karo.
  • Local vs Global Truncation Error — kyun Ex 2 mein bade rates ne bada error diya.
  • Stiff systems and stability — Ex 7 mein failure.
  • Simpson's Rule — woh quadrature jo RK4 imitate karta hai.