Lesson 5 of 18
Newton's Method
Newton's Method
Newton's method (also called Newton-Raphson) finds roots of using derivatives. It is one of the most important applications of calculus in numerical computing.
Idea
Starting from a guess , draw the tangent line at . Where does the tangent line cross the x-axis? That crossing is a better guess.
Repeat:
Convergence
Newton's method has quadratic convergence: the number of correct decimal places roughly doubles each iteration. Starting from a decent guess, 10 iterations typically gives machine precision (15+ digits).
Example:
Find the root of , so :
After 5 steps: — 8 correct digits from 3 iterations.
Pitfalls
- If , the method fails (division by zero)
- A bad initial guess can diverge or cycle
- Works best near a simple root where
Your Task
Implement double newton(double (*f)(double), double (*df)(double), double x0, int iters) that applies Newton's method for iters iterations.
TCC compiler loading...
Loading...
Click "Run" to execute your code.