Step 1 — Write the secant line. We have two points on the curve:
Pn−1=(xn−1,f(xn−1)),Pn=(xn,f(xn)).Why this step? These are the two most recent guesses — we use the latest information.
Step 2 — Slope of the chord. The slope m of the line through them is
m=xn−xn−1f(xn)−f(xn−1).Why this step? This is the rise-over-run of the secant — it approximatesf′(xn). (Compare Newton, which uses the exact f′(xn).)
Step 3 — Equation of the line through Pn with slope m:
y−f(xn)=m(x−xn).
Step 4 — Where does it cross the x-axis? Set y=0 and call that x=xn+1:
0−f(xn)=m(xn+1−xn).Why this step? A root is where f=0; the line's x-intercept is our best linear guess for that root.
Step 5 — Solve for xn+1:xn+1−xn=−mf(xn)=−f(xn)−f(xn−1)f(xn)(xn−xn−1).xn+1=xn−f(xn)f(xn)−f(xn−1)xn−xn−1
Secant: p=21+5≈==1.618== (the golden ratio!) — superlinear but below quadratic.
WHY 1.618? The error recurrence for Secant is en+1≈Kenen−1 (proved below). Assume en+1=Aenp. Then en=Aen−1p⇒en−1=(en/A)1/p. Substituting:
Aenp=Ken(en/A)1/p.
Matching powers of en: p=1+p1⇒p2−p−1=0⇒p=21+5.
No nice derivative needed. Take x0=0,x1=1.
f(0)=1,f(1)=cos1−1=−0.4597.x2=1−(−0.4597)⋅−0.4597−11−0=1−(−0.4597)(−0.6850)=0.6851.Why this step? Same recipe; Secant doesn't care that cosx−x has no simple closed-form root.
Continuing gives x3≈0.7363, x4≈0.7391 — converging to 0.73909.
Imagine a hill where the height is zero exactly at the spot you want to find. You stand at two spots and measure how high you are at each. Draw a straight ruler connecting those two heights. Where the ruler touches the ground (zero height) is your next guess — walk there, drop the older of your two spots, measure again, and draw a new ruler. Each ruler is straighter and closer to the magic zero-spot, so after a few tries you basically land on it. The clever part: you never need to know how steep the hill is — just two heights are enough.
Dekho, Secant method ka core idea bahut simple hai. Newton-Raphson mein humein har step pe derivative f′(x) chahiye hota hai, lekin kabhi-kabhi derivative nikalna mushkil ya expensive hota hai. To Secant kehta hai — "derivative ki tension hi kyun lo? Do points le lo curve pe, unke beech ek seedhi line (chord/secant) kheencho, aur dekho woh line x-axis ko kahan kaatti hai. Wahi tumhara next guess hai." Bas isi liye humein do starting points x0 aur x1 chahiye — ek line banane ke liye do points lagte hain na.
Formula yaad rakhna easy hai: xn+1=xn−f(xn)⋅f(xn)−f(xn−1)xn−xn−1. Yeh actually Newton ka hi formula hai, bas f′(xn) ki jagah humne chord ka slope ΔxΔf daal diya. Aur ek mast baat — yeh slope, jaise-jaise do points paas aate hain, exact derivative ban jaata hai (derivative ki definition yahi to hai).
Speed ke maamle mein Secant ka order 1.618 hai (golden ratio!), jo Newton ke 2 se thoda kam hai — lekin har step mein sirf ek naya f evaluate karna padta hai, derivative nahi. Isliye jab derivative mehenga ho, Secant practically Newton ko bhi beat kar deta hai. Ek important warning: Secant ek "open" method hai, matlab bisection ki tarah root ko bracket karke guarantee nahi deta — iterate kabhi-kabhi bahar bhi jaa sakta hai, aur agar denominator f(xn)−f(xn−1) zero ke paas chala gaya to formula phat sakta hai. Isiliye code mein hamesha tolerance aur max-iteration ka guard lagao.