Exercises — Cubic spline interpolation — natural, clamped
4.8.12 · D4· Maths › Numerical Methods › Cubic spline interpolation — natural, clamped
Poore note mein, hum parent se liya hua notation reuse karte hain:
- interval ki width hai (do neighbouring -values ke beech ka gap).
- moment hai — node par spline ki second derivative (yaani bendiness).
- ke liye interior recurrence yeh hai:
Hum do piece formulas yahan dobara print kar rahe hain jo baar baar use hoti hain, taaki kuch bhi assume na karna pade:
Level 1 — Recognition
Problem 1.1 (L1)
Saral shabdon mein bolo ki ek cubic spline ke liye neeche diye gaye mein se har ek kya equal hota hai: (a) , (b) interior node par ki continuity, (c) natural boundary condition, (d) clamped boundary condition.
Recall Solution 1.1
(a) : par ka piece left data point se hoke guzarna chahiye — yeh interpolation hai. (b) : left piece se node mein aane wala slope, right piece par jaane wale slope ke barabar hona chahiye — koi kink nahi. (c) Natural: aur — donon ends par zero curvature (ruler relaxed/straight hai wahan). (d) Clamped: aur — end slopes given numbers par pin kiye gaye hain.
Problem 1.2 (L1)
par data ke liye, saare widths calculate karo. Kitne unknown moments hain, aur recurrence kitne interior equations deta hai?
Recall Solution 1.2
, , . moments hain: . Interior recurrence par chalti hai, jo 2 interior equations deti hai. Hum 2 short hain (4 unknowns, 2 equations), isliye hume 2 boundary conditions chahiye — exactly natural ya clamped.
Level 2 — Application
Problem 2.1 (L2)
Data equal spacing ke saath. Natural spline banao: nikalo.
Recall Solution 2.1
Natural . Sirf unknown hai. par interior recurrence, ke saath: Toh . Result: . Negative middle moment ka matlab hai ki spline peak par concave-down hai, jaise ek hump ke liye expect hota hai.
Problem 2.2 (L2)
Problem 2.1 ke moments use karke, par cubic likho aur verify karo ki aur .
Recall Solution 2.2
Piece formula use karo , , , , , , , ke saath:
Simplify karo: , aur . Toh Check ✓. ✓. Aur , toh ✓ (natural).
Level 3 — Analysis
Problem 3.1 (L3)
Usi data ke liye, aur ke saath clamped spline banao. nikalo, phir ko natural case se compare karo aur fark explain karo.
Recall Solution 3.1
Boundary equations (parent se, ): Left: , yaani . Right: , yaani . Interior (): (RHS Problem 2.1 se). Solve karo: Left se, ; Right se, . Interior mein substitute karo: 2 se multiply karo: Phir aur . Result: . Comparison: Natural ne diya (zero end curvature). Clamped force karta hai: spline ko left end par bend karna padta hai taaki imposed tak slope aa sake. Curvature ek slope pin karne ki keemat hai.
Problem 3.2 (L3)
Explain karo ki spline coefficient matrix diagonally dominant kyun hai aur yeh kyun guarantee karta hai ki moments uniquely determined hain. Tridiagonal structure ka reference do.
Recall Solution 3.2
Har interior row hai Diagonal entry hai . Do off-diagonal entries hain aur , dono positive. Unka sum hai , jo diagonal se strictly less hai. Toh har row mein — yahi strict diagonal dominance ki definition hai. Ek strictly diagonally dominant tridiagonal matrix non-singular hoti hai, isliye system ka ek unique solution hota hai. Practically, Tridiagonal systems & Thomas algorithm ise mein bina pivoting ke solve kar leta hai — dominance elimination ko numerically stable rakhti hai.
Level 4 — Synthesis
Problem 4.1 (L4)
Data , equal spacing . Natural spline banao: ke liye system set up karo, solve karo, aur saare chaar moments state karo.
Recall Solution 4.1
Yahan , nodes . Natural . aur par interior recurrence, saare toh diagonal , off-diagonals : : ke saath: . : ke saath: . Solve karo . Pehle se, . Substitute karo: Phir Result: Antisymmetric data antisymmetric moments produce karta hai — ek clean sanity check.
Problem 4.2 (L4)
4.1 ke moments use karke, par likho aur node par spline ka slope dono left piece aur right piece se evaluate karo taaki wahan slope continuity confirm ho sake.
Recall Solution 4.2
Left piece on : , , , . Boxed formula se slope: par: , , toh Right piece on : , , . par: , toh Dono dete hain ✓ — par slope continuous hai, jo poori construction confirm karta hai. Assembled curve neeche dekho.

Level 5 — Mastery
Problem 5.1 (L5)
Degenerate case. Sirf do points diye gaye hain: , aur aap ek natural cubic spline banate ho. Aap actually kaun sa curve paate ho, aur "cubic spline" yahan kyun collapse ho jaata hai? Ek clamped spline se contrast karo jisme ho.
Recall Solution 5.1
ke saath ek single interval hai aur sirf moments hain. Natural aur set karta hai — aur koi interior nodes nahi hain, toh recurrence koi equations hi nahi deti. Dono moments already fix hain. Kyunki linear hai aur dono ends par vanish karta hai, on . Ek function jiska zero second derivative ho woh ek straight line hai. interpolate karo: Toh natural spline linear interpolant mein degenerate ho jaata hai — koi cubic curvature survive nahi karti. Clamped: ab boundary equations ke through pin hote hain. Left: with : . Right: : . Solve karo : pehle ko 2 se multiply karo: ; doosre ko subtract karo: , phir . Toh : clamped spline ek genuine cubic hai (use right end par slope hit karne ke liye curve karna padta hai). Takeaway: sirf do points ke saath, natural boring hai (ek line) lekin clamped phir bhi real cubic information carry karta hai.
Problem 5.2 (L5)
Non-uniform spacing. Data (teen collinear-at-height-zero points, lekin unequal gaps ). Natural spline banao. Pehle answer predict karo, phir recurrence se verify karo, aur explain karo ki yeh collinear data ke through splines ke baare mein kya sikhata hai.
Recall Solution 5.2
Prediction: saare hain, toh flat line interpolate karti hai aur hai zero curvature ke saath — natural conditions satisfy hoti hain. Toh hum expect karte hain ki saare moments zero honge. Verify karo: Natural . par interior, ke saath: RHS . LHS . Toh . Saare moments zero , unequal spacing ke bawajood prediction se match karta hai. Lesson: ek natural spline ek straight line ko exactly reproduce karta hai (yahan zero line). Isliye splines Runge wobble se nahi suffer karte — woh curvature sirf wahan add karte hain jahan data demand karta hai, aur tridiagonal structure non-uniform ko automatically handle karta hai. (Yeh B-splines se connect hota hai, jahan flat-data reproduction property built-in hoti hai.)
Recall Final self-check — answers cover karo
- Problem 2.1 mein, kya tha? ::: .
- Problem 3.1 (clamped) mein, kya tha? ::: .
- Problem 4.1 mein, chaar moments kya the? ::: .
- Kaun sa slope value 4.2 mein par continuity confirm karta tha? ::: dono pieces se.
- Do-point natural spline kisme collapse hua (5.1)? ::: Straight line mein.