5.4.24 · D1 · HinglishScientific Computing (Python)

FoundationsImplementing numerical integration from scratch — trapezoidal, Simpson's

1,866 words8 min read↑ Read in English

5.4.24 · D1 · Coding › Scientific Computing (Python) › Implementing numerical integration from scratch — trapezoida

Parent note par ek bhi formula padhne se pehle, tumhe uske har ek symbol par puri pakad chahiye. Neeche, har cheez ko zero se banaya gaya hai: pehle plain words mein, phir ek picture, phir topic ko yeh kyun chahiye. Upar se neeche padho — har item sirf wahi cheez use karta hai jo usse upar define ho chuki hai.


1. Curve — ek height machine

Picture. Horizontal axis ke saath left–right slide karo (yahi choose karna hai); curve batata hai ki wahan pahaadi kitni oonchi hai.

Topic ko yeh kyun chahiye. Poora game is height curve ke neeche ka area measure karna hai. Height machine nahi → measure karne ke liye kuch nahi.

Figure — Implementing numerical integration from scratch — trapezoidal, Simpson's

2. , aur interval — kahan shuru, kahan khatam

Picture. aur par do seedhe fence-posts gade hue hain. Hum sirf dono fences ke beech pahaadi ke hisse ki parwah karte hain.

Topic ko yeh kyun chahiye. Region ke bina area ka koi matlab nahi. zameen par wahi region hai.


3. Integral sign — "exact area"

Picture. Fences ke beech aur curve ke neeche ke region ko paint se bharo. paint ki matra hai — woh shaded area.

Topic ko yeh kyun chahiye. Yahi exact answer hai jisko hum dhundh rahe hain. Parent page par har method is ek quantity ka approximation hai.


4. Interval ko todna: , , aur nodes

Hum infinitely many slivers handle nahi kar sakte, isliye finite number of chunks mein kaatte hain.

Picture. se tak rakha hua ek ruler, equal spacing par ticked. Har tick ek node hai; tick ke neeche number uska index hai.

Figure — Implementing numerical integration from scratch — trapezoidal, Simpson's

Topic ko yeh kyun chahiye. har area formula mein width factor hai; wahi jagahein hain jahan hum kabhi bhi se height poochte hain.


5. Subscripts , , — samples ko naam dena

Picture. Har ruler tick par, curve tak ek vertical stick khींcho. Uski length hai. Ye sticks wahi numbers hain jo methods kabhi bhi plug in karte hain.

Topic ko yeh kyun chahiye. Dono rules sirf numbers se bani recipes hain — aur kuch nahi.


6. Sigma notation — "yeh sab jodon"

Picture. Ek conveyor belt: yeh ek-ek karke feed karta hai, har baar ek running total mein dalta hai.

Topic ko yeh kyun chahiye. Trapezoidal ya Simpson ka answer ek weighted sum hai. Sigma compact tarika hai "saari sampled heights ko add karo" likhne ka.


7. Weights — kuch heights zyada count karti hain

Picture. Har node ko is hisaab se colour karo ki uspar kitni shapes lean karti hain: endpoints (ek shape) ek colour, shared interior nodes (do shapes) doosra colour.

Figure — Implementing numerical integration from scratch — trapezoidal, Simpson's

Topic ko yeh kyun chahiye. Endpoints ko galat weight dena parent note ka "#1 silent bug" hai. Kyun weights alag hain yeh samajhna us bug ko impossible bana deta hai.


8. Polynomial degree — fit kitna "bendy" ho sakta hai

Picture. Line = ruler ka kinara. Parabola = ek smooth valley ya hill. Cubic = ek gentle S.

Topic ko yeh kyun chahiye. Trapezoid har slice ko ek line (degree 1) fit karta hai; Simpson har pair ko ek parabola (degree 2). Parent note par "degree-1 / degree-3 ke liye exact" ek statement hai ki kaunsi curves yeh shapes perfectly reproduce karti hain. Dekho Polynomial interpolation aur Newton-Cotes formulas.


9. Big-O notation , — error kitni tezi se shrink hoti hai

Picture. Do shrinking staircases: half karna error ko ek chhota stairs neeche le jaata hai, lekin error ko chaar stairs neeche phenk deta hai. Same effort, Simpson jeet jaata hai.

Topic ko yeh kyun chahiye. Yeh parent ki punchline explain karta hai: same number of samples ke liye Simpson trapezoid ko dramatically beat karta hai. Powers khud Taylor series se aate hain.


10. Symbol — "approximately equal"

Topic ko yeh kyun chahiye. Honesty. Har method ek estimate hai; ise front aur centre rakhta hai.


Yeh topic ko kaise feed karte hain

Function f x height machine

Integral = exact area

Limits a and b interval

Approximate with shapes

n pieces and step h

Nodes x i

Sampled heights f i

Sigma sum notation

Weighted sum sum wi fi

Weights wi shared vs edge

Polynomial degree line vs parabola

Trapezoidal rule

Simpsons rule

Big O error order

Jab upar ka har box obvious lagne lage, parent page — the main topic — sirf pure bookkeeping ki tarah padhega.


Equipment checklist

Khud ko test karo: left side padho, answer zor se bolo, phir reveal karo.

ka plain words mein kya matlab hai?
aur ke beech curve ke neeche ka exact area.
kya hai aur yeh kaise compute hota hai?
Har subinterval ki width; .
Agar subintervals ki sankhya hai, toh kitne nodes (points) hain?
.
Node formula tumhe kya deta hai?
ke saath -th cut point ki position.
ko zor se padho.
se tak har interior node par curve ki heights ka sum.
Interior nodes ko endpoints se bada weight kyun milta hai?
Woh do neighbouring shapes ke beech share hote hain, isliye unki height dono mein count hoti hai.
Trapezoid har slice ke liye kaun si shape (degree) fit karta hai? Simpson har pair ke liye?
Trapezoid: seedhi line (degree 1). Simpson: parabola (degree 2).
Agar tum half karo, toh error kitna shrink hoti hai? error?
Lagbhag quarter ho jaati hai; lagbhag sixteenth ho jaati hai.
mein kya signal karta hai?
Result ek approximation hai, exact nahi, jab tak low-degree polynomial na ho.
Interior-node loop range(1, n) use kyun karta hai, range(1, n+1) nahi?
Indices se tak interior nodes hain; endpoint hai, alag handle hota hai.