4.8.5 · Maths › Numerical Methods
Intuition Ek-sentence idea
Computers numbers ko finite precision ke saath store karte hain. Jab tum do nearly-equal numbers subtract karte ho , toh leading agreeing digits cancel ho jaate hain, aur last digits mein chhupe tiny rounding errors achanak aage aa jaate hain — accuracy tabah ho jaati hai. Isse catastrophic cancellation kehte hain.
Definition Floating-point aur relative error
Ek real number x ko fl ( x ) = x ( 1 + δ ) ke roop mein store kiya jaata hai, jahaan ∣ δ ∣ ≤ u hai, aur u unit roundoff hai (machine epsilon /2 ). IEEE double precision ke liye, u ≈ 1.1 × 1 0 − 16 hai (lagbhag 16 significant decimal digits ).
Definition Catastrophic cancellation
Jab do nearly equal, rounded quantities subtract ki jaati hain, tab relative accuracy ki badi loss hoti hai. Absolute error chhota rehta hai, lekin relative error badh jaata hai kyunki bachne wale significant digits bahut kam hote hain.
Definition Stability vs instability
Ek algorithm numerically stable hota hai agar chhote input/rounding errors computation ke through bounded rehein (amplify na hon) . Woh unstable hota hai agar woh errors uncontrollably badhein. Cancellation instability ka ek common mechanism hai.
Maano true values a aur b hain jahan a ≈ b . Computer hold karta hai
a ^ = a ( 1 + δ a ) , b ^ = b ( 1 + δ b ) , ∣ δ a ∣ , ∣ δ b ∣ ≤ u .
Ab difference a ^ − b ^ banao. Error hai:
a ^ − b ^ = ( a − b ) + ( a δ a − b δ b ) .
Toh absolute error hai a δ a − b δ b , jo u ( ∣ a ∣ + ∣ b ∣ ) se bound hai — chhota , bilkul expected.
Dikkat relative error mein hai:
a − b ( a ^ − b ^ ) − ( a − b ) = a − b a δ a − b δ b .
Intuition Yeh step kyun matter karta hai
Numerator order u ⋅ ∣ a ∣ ka hai. Denominator a − b tiny hai jab a ≈ b . Ek chhote-lekin-fixed error ko ek tiny denominator se divide karo → huge relative error . a jitna b ke kareeb, utna bura.
Bound karte hain:
rel error ≲ u ∣ a − b ∣ ∣ a ∣ + ∣ b ∣
Factor ∣ a − b ∣ ∣ a ∣ + ∣ b ∣ subtraction ka condition number hai. Jab a ≈ b ho toh yeh enormous hota hai — yahi catastrophe hai.
Ilaaj almost hamesha algebra hai: expression ko aise rewrite karo ki khatarnak subtraction kabhi na ho.
Worked example Example 1 —
x + 1 − x bade x ke liye
Lo x = 1 0 10 . Dono square roots ≈ 1 0 5 hain, toh unhe subtract karne se cancellation hoti hai.
Fix: rationalise karo (conjugate se multiply karo):
x + 1 − x = x + 1 + x ( x + 1 − x ) ( x + 1 + x ) = x + 1 + x 1 .
Yeh step kyun? Conjugate ek difference ko denominator mein sum mein badal deta hai — positive numbers ka addition kabhi cancel nahi hota. Naya form ≈ 2 × 1 0 5 1 = 5 × 1 0 − 6 full precision ke saath deta hai.
Worked example Example 2 — quadratic formula
x 2 − 200 x + 1 = 0 solve karo. Roots x = 100 ± 9999 hain, aur 9999 ≈ 99.995 .
Root x 2 = 100 − 99.995 … catastrophically cancel ho jaata hai.
Fix: pehle safe root compute karo, phir roots ka product x 1 x 2 = c / a use karo (Vieta):
x 1 = 100 + 9999 ( safe, addition ) , x 2 = x 1 c / a = x 1 1 .
Yeh step kyun? Vieta ka relation x 1 x 2 = c / a hame chhota root division se deta hai subtraction ki jagah — well-behaved numbers ka division stable hota hai.
Worked example Example 3 —
1 − cos x chhote x ke liye
x = 0 ke paas, cos x ≈ 1 , toh 1 − cos x cancel hota hai.
Fix: identity use karo 1 − cos x = 2 sin 2 2 x .
Yeh step kyun? sin 2 x khud ≈ x /2 hai — chhota lekin accurately computed, aur squaring kabhi cancel nahi hoti. (Ya Taylor series 2 x 2 − 24 x 4 + ⋯ use karo.)
Worked example Example 4 — variance, two-pass cure
"Textbook" one-pass formula σ 2 = n 1 ∑ x i 2 − x ˉ 2 do bade nearly-equal numbers subtract karta hai jab data ka mean bada ho.
Fix: two-pass — pehle x ˉ compute karo, phir σ 2 = n 1 ∑ ( x i − x ˉ ) 2 . Deviations chhote hote hain; koi cancellation nahi.
Common mistake Galat intuitions ko steel-man karna
"Rounding errors random hote hain, average ho jaayenge — koi badi baat nahi."
Kyun sahi lagta hai: zyaadatar additions/multiplications mein relative error sach mein u ke paas rehta hai, toh mushkil kam dikhti hai.
Fix: subtraction special hai. Woh error create nahi karta — woh already present error ko expose aur magnify karta hai. Error absolute terms mein nahi badhta; sach wala answer uske neeche sink ho jaata hai . Toh koi averaging kaam nahi aata.
"Higher precision use karna (zyada digits) isse solve kar dega."
Kyun sahi lagta hai: zyada digits problem ko aur aage push kar dete hain.
Fix: yeh sirf problem ko delay karta hai. x + 1 − x tab bhi fail hoga jab x itna bada ho ki roots saari available digits mein agree karein. Algorithm ko reformulate karna asli ilaaj hai.
"Catastrophic cancellation = unstable algorithm."
Kyun sahi lagta hai: cancellation instability ka mashoor source hai.
Fix: dono alag concepts hain. Conditioning problem ki property hai; stability algorithm ki property hai. Ek stable algorithm unnecessary cancellation se bachta hai; ek ill-conditioned problem chahe kuch bhi karo sensitive ho sakti hai.
Recall Feynman: ek 12-saal ke bachche ko samjhao
Socho do lambe block towers hain, ek 1000 blocks oonchi, doosri 1001. Tumne har ek ko sirf nearest block tak measure kiya — toh har ek aadhe block tak off ho sakti hai. Ab tum poochho "doosri kitni zyada oonchi hai?" Jawab hai lagbhag 1 block — lekin tumhari aadhe-block uncertainties ab us 1-block answer ke comparison mein BAHUT BADI hain! Tum towers ke baare mein confident ho lekin chhote se difference ke baare mein clueless. Trick yeh hai: dono towers measure karke subtract mat karo — ek aisa tarika dhundho jo gap directly measure kare.
"Big minus Big ek Jhooth hai." Jab do bade, nearly-equal numbers ladte hain, sirf noise bachti hai. → Rationalise karo, factor karo, ya identity use karo is duel se bachne ke liye.
Cancellation mein relative error kyun phatta hai lekin absolute error chhota rehta hai?
Kaun sa ek quantity govern karta hai ki subtraction kitni buri hai?
x + 1 − x ko kaise fix karte hain?
Conditioning aur stability mein fark kya hai?
Catastrophic cancellation kya hai? Do nearly-equal rounded numbers subtract karne par relative accuracy ki badi loss; bachne wale significant digits bahut kam hote hain.
Kya cancellation absolute error badhata hai? Nahi — absolute error ≲ u ( ∣ a ∣ + ∣ b ∣ ) rehta hai. Yeh relative error magnify karta hai kyunki a − b tiny hai.
a − b subtract karne ka condition number kya hai?∣ a − b ∣ ∣ a ∣ + ∣ b ∣ — huge jab a ≈ b ho.
Khoye hue digits ka rule of thumb? Agar a , b k leading digits mein agree karte hain, toh a − b lagbhag k significant digits khota hai.
x + 1 − x ka stable fix?Conjugate se multiply karo:
x + 1 + x 1 (difference ko sum mein badal deta hai).
Chhote quadratic root ka stable fix? Addition se large-magnitude root compute karo, phir chhote ke liye Vieta x 1 x 2 = c / a use karke divide karo.
Chhote x ke liye 1 − cos x ka stable form? 2 sin 2 ( x /2 ) , ya Taylor series x 2 /2 − x 4 /24 + ⋯ .
Conditioning vs stability? Conditioning = problem ki sensitivity; stability = algorithm ka error-amplification.
Kya higher precision cancellation cure karta hai? Nahi, yeh sirf delay karta hai; algorithm ko reformulate karna asli ilaaj hai.
IEEE double ke liye unit roundoff u ? ≈ 1.1 × 1 0 − 16 (~16 significant decimal digits).
stores as fl x = x 1+delta
absolute error stays small
e.g. conjugate rationalise
Finite precision floating-point
Rounding error bounded by u
Subtract nearly-equal numbers
Catastrophic cancellation
Absolute error ~ u times abs a + abs b
Condition number abs a + abs b over abs a - b
Lose about k significant digits
Stable: errors stay bounded
Rewrite to avoid subtraction
sqrt x+1 minus sqrt x becomes a sum