Newton-Raphson, Bisection & Secant Method: Complete Notes, Derivations, Solved Problems & C Programs for BSc CSIT Numerical Methods
Introduction
Root-finding is one of the most fundamental problems in scientific computing. Many real-world problems — finding the equilibrium point of a chemical reaction, determining the break-even point of a financial model, calculating the resonant frequency of a circuit — reduce to solving a nonlinear equation f(x) = 0. When exact algebraic solutions don't exist (and they often don't), numerical methods provide systematic algorithms that converge to a solution through iterative refinement.
For BSc CSIT students at Tribhuvan University, the Newton-Raphson Method, Bisection Method, and Secant Method are the three most consistently examined root-finding algorithms. They appear in every form of examination question: definition, derivation, algorithm, flowchart, worked numerical, programming, and comparison. This guide covers all of these, with actual step-by-step solutions to worked examples and compilable C programs for each method.
Why Root-Finding Methods Matter
Finding a root of f(x) = 0 appears in:
- Engineering: Calculating beam deflection, circuit analysis, structural load
- Machine Learning: Finding the zero of a loss function's gradient during optimization
- Computer Graphics: Ray-surface intersection calculations
- Economics: Finding equilibrium prices in supply-demand models
- Scientific computing: Eigenvalue calculations, differential equation solving
Course Context
Numerical Methods is a core BSc CSIT course (typically 5th or 6th semester) covering algorithms for solving mathematical problems computationally. Root-finding methods are usually among the first topics covered because they illustrate core numerical concepts: iteration, convergence, error estimation, and the tradeoff between reliability and speed.
1. Bisection Method
Concept
The Bisection Method is the simplest and most reliable root-finding algorithm. It is based directly on the Intermediate Value Theorem: if f(x) is continuous on [a, b] and f(a) and f(b) have opposite signs, then there must be at least one root in (a, b).
The method works by repeatedly halving the interval until the root is isolated to within a desired tolerance.
Algorithm
Step 1: Choose initial interval [a, b] such that f(a) × f(b) < 0
Step 2: Compute midpoint: c = (a + b) / 2
Step 3: If f(c) = 0 or (b - a)/2 < tolerance: root = c, STOP
Step 4: If f(a) × f(c) < 0: set b = c (root is in left half)
Else: set a = c (root is in right half)
Step 5: Go to Step 2
Error Bound After n Iterations
After n bisections starting from interval [a, b]:
|Error| ≤ (b - a) / 2ⁿ
To achieve a tolerance of ε, the number of iterations needed is:
n ≥ log₂[(b - a) / ε]
Convergence
The Bisection Method has linear convergence — each iteration reduces the error by exactly half. It is always convergent provided the initial interval satisfies f(a) × f(b) < 0. This reliability is its primary advantage.
Fully Solved Example: Bisection Method
Find the root of f(x) = x³ − x − 2 = 0 in the interval [1, 2] using 4 iterations.
First, verify the interval contains a root:
- f(1) = 1 − 1 − 2 = −2 (negative)
- f(2) = 8 − 2 − 2 = 4 (positive)
- f(1) × f(2) = −8 < 0 ✓ Root exists in [1, 2]
| Iteration | a | b | c = (a+b)/2 | f(c) | New interval |
|---|---|---|---|---|---|
| 1 | 1 | 2 | 1.5 | f(1.5) = 3.375 − 1.5 − 2 = −0.125 | [1.5, 2] |
| 2 | 1.5 | 2 | 1.75 | f(1.75) = 5.359 − 1.75 − 2 = 1.609 | [1.5, 1.75] |
| 3 | 1.5 | 1.75 | 1.625 | f(1.625) = 4.291 − 1.625 − 2 = 0.666 | [1.5, 1.625] |
| 4 | 1.5 | 1.625 | 1.5625 | f(1.5625) = 3.815 − 1.5625 − 2 = 0.253 | [1.5, 1.5625] |
After 4 iterations: approximate root ≈ 1.5313
Exact root: x ≈ 1.5214 (the method is converging slowly but reliably)
C Program — Bisection Method
#include <stdio.h>
#include <math.h>
double f(double x) {
return x*x*x - x - 2; /* f(x) = x^3 - x - 2 */
}
int main() {
double a, b, c, tolerance = 0.0001;
int maxIter = 100, iter = 0;
printf("Enter initial interval [a, b]: ");
scanf("%lf %lf", &a, &b);
if (f(a) * f(b) >= 0) {
printf("Invalid interval: f(a) and f(b) must have opposite signs.\n");
return 1;
}
printf("\nIter\t a\t\t b\t\t c\t\t f(c)\n");
while ((b - a) / 2 > tolerance && iter < maxIter) {
c = (a + b) / 2;
printf("%d\t %.6f\t %.6f\t %.6f\t %.6f\n", iter+1, a, b, c, f(c));
if (f(c) == 0.0) break;
else if (f(a) * f(c) < 0) b = c;
else a = c;
iter++;
}
printf("\nApproximate root: %.6f\n", (a + b) / 2);
return 0;
}
2. Newton-Raphson Method
Concept
The Newton-Raphson Method (also called Newton's Method) uses the tangent line to the curve at the current approximation to find a better approximation. It requires the derivative f'(x) to exist at each point.
Derivation of the Iterative Formula
Given a current approximation xₙ, we want a better approximation xₙ₊₁.
The tangent line to f(x) at point (xₙ, f(xₙ)) has equation:
y − f(xₙ) = f'(xₙ)(x − xₙ)
We find where this tangent line crosses the x-axis (y = 0):
0 − f(xₙ) = f'(xₙ)(xₙ₊₁ − xₙ)
Solving for xₙ₊₁:
xₙ₊₁ = xₙ − f(xₙ) / f'(xₙ)
This is the Newton-Raphson iterative formula.
Geometric interpretation: At each step, we slide along the tangent line to the x-axis to find the next approximation — always moving in the direction that the tangent line points toward the root.
Convergence
Newton-Raphson has quadratic convergence near the root. This means the number of correct decimal digits roughly doubles with each iteration. Starting with 1 correct digit, you get 2, then 4, then 8. This is why Newton-Raphson converges so much faster than the Bisection Method in practice.
Condition for convergence: f'(xₙ) ≠ 0 at each iteration. The method can fail if:
- f'(x) = 0 near the root (flat tangent — no crossing)
- The initial guess is far from the root and the function has inflection points
- The root is a repeated root (convergence becomes linear, not quadratic)
Fully Solved Example 1: Newton-Raphson
Find the root of f(x) = x³ − x − 2 = 0 starting from x₀ = 1.5
f(x) = x³ − x − 2 f'(x) = 3x² − 1
Formula: xₙ₊₁ = xₙ − f(xₙ)/f'(xₙ)
| Iteration | xₙ | f(xₙ) | f'(xₙ) | xₙ₊₁ = xₙ − f/f' |
|---|---|---|---|---|
| 0 | 1.5 | −0.125 | 5.75 | 1.5 − (−0.125/5.75) = 1.5217 |
| 1 | 1.5217 | 0.00239 | 5.9479 | 1.5217 − (0.00239/5.9479) = 1.5214 |
| 2 | 1.5214 | ≈ 0 | — | Converged |
After just 2 iterations from x₀ = 1.5, Newton-Raphson gives x ≈ 1.5214 — compare this to the Bisection Method which needed 4 iterations just to reach 1.5313.
Fully Solved Example 2: Newton-Raphson for Square Root
Approximate √10 using Newton-Raphson with x₀ = 3.
Finding √10 is equivalent to finding the root of f(x) = x² − 10 = 0.
f(x) = x² − 10, f'(x) = 2x
xₙ₊₁ = xₙ − (xₙ² − 10) / (2xₙ) = (xₙ + 10/xₙ) / 2
| Iteration | xₙ | xₙ₊₁ = (xₙ + 10/xₙ)/2 |
|---|---|---|
| 0 | 3 | (3 + 10/3)/2 = (3 + 3.333)/2 = 3.1667 |
| 1 | 3.1667 | (3.1667 + 10/3.1667)/2 = (3.1667 + 3.1579)/2 = 3.16228 |
| 2 | 3.16228 | 3.16228 (converged) |
√10 = 3.16228 ✓ — confirmed in 2 iterations.
Advantages and Disadvantages
| Aspect | Details |
|---|---|
| Advantage | Quadratic convergence — very fast near the root |
| Advantage | One initial guess required |
| Disadvantage | Requires computing f'(x) analytically |
| Disadvantage | Fails if f'(xₙ) = 0 at any iteration |
| Disadvantage | Not guaranteed to converge for all starting points |
C Program — Newton-Raphson Method
#include <stdio.h>
#include <math.h>
double f(double x) {
return x*x*x - x - 2;
}
double fPrime(double x) {
return 3*x*x - 1;
}
int main() {
double x0, x1, tolerance = 0.0001;
int maxIter = 100, iter = 0;
printf("Enter initial guess x0: ");
scanf("%lf", &x0);
printf("\nIter\t x0\t\t\t f(x0)\n");
do {
if (fabs(fPrime(x0)) < 1e-10) {
printf("Derivative near zero — method fails.\n");
return 1;
}
x1 = x0 - f(x0) / fPrime(x0);
printf("%d\t %.8f\t %.8f\n", iter+1, x0, f(x0));
x0 = x1;
iter++;
} while (fabs(f(x0)) > tolerance && iter < maxIter);
printf("\nApproximate root: %.8f after %d iterations\n", x0, iter);
return 0;
}
3. Secant Method
Concept
The Secant Method is a modification of Newton-Raphson that eliminates the need to compute the derivative analytically. Instead, it approximates the derivative using a finite difference of two previous function evaluations.
This makes it useful when:
- f'(x) is difficult or expensive to compute
- The analytical derivative is not available
- You want to program the method without deriving f'(x)
Derivation
Newton-Raphson uses: xₙ₊₁ = xₙ − f(xₙ) / f'(xₙ)
The Secant Method replaces f'(xₙ) with the slope of the secant line through two previous points:
f'(xₙ) ≈ [f(xₙ) − f(xₙ₋₁)] / [xₙ − xₙ₋₁]
Substituting:
xₙ₊₁ = xₙ − f(xₙ) × (xₙ − xₙ₋₁) / [f(xₙ) − f(xₙ₋₁)]
This requires two initial guesses (x₀ and x₁) but no derivative calculation.
Convergence
The Secant Method has superlinear convergence with order approximately 1.618 (the golden ratio). This is slower than Newton-Raphson (order 2) but faster than Bisection (order 1). It requires 2 initial guesses but no derivative — a good tradeoff when derivatives are expensive.
Fully Solved Example: Secant Method
Solve f(x) = x³ − x − 2 = 0 with x₀ = 1 and x₁ = 2
Formula: xₙ₊₁ = xₙ − f(xₙ)(xₙ − xₙ₋₁) / [f(xₙ) − f(xₙ₋₁)]
f(1) = 1 − 1 − 2 = −2 f(2) = 8 − 2 − 2 = 4
Iteration 1: x₂ = 2 − f(2)(2 − 1) / [f(2) − f(1)] = 2 − 4(1) / [4 − (−2)] = 2 − 4/6 = 2 − 0.667 = 1.333
f(1.333) = 1.333³ − 1.333 − 2 = 2.370 − 1.333 − 2 = −0.963
Iteration 2: x₃ = 1.333 − f(1.333)(1.333 − 2) / [f(1.333) − f(2)] = 1.333 − (−0.963)(−0.667) / [−0.963 − 4] = 1.333 − 0.6423 / (−4.963) = 1.333 + 0.1294 = 1.4624
f(1.4624) = 3.127 − 1.4624 − 2 = −0.3354
Iteration 3: x₄ = 1.4624 − f(1.4624)(1.4624 − 1.333) / [f(1.4624) − f(1.333)] = 1.4624 − (−0.3354)(0.1294) / [−0.3354 − (−0.963)] = 1.4624 − (−0.04340) / 0.6276 = 1.4624 + 0.0691 = 1.5315
Converging toward the root at 1.5214.
C Program — Secant Method
#include <stdio.h>
#include <math.h>
double f(double x) {
return x*x*x - x - 2;
}
int main() {
double x0, x1, x2, tolerance = 0.0001;
int maxIter = 100, iter = 0;
printf("Enter first initial guess x0: ");
scanf("%lf", &x0);
printf("Enter second initial guess x1: ");
scanf("%lf", &x1);
printf("\nIter\t x0\t\t x1\t\t x2\t\t f(x2)\n");
while (iter < maxIter) {
if (fabs(f(x1) - f(x0)) < 1e-10) {
printf("Division by near-zero — method fails.\n");
return 1;
}
x2 = x1 - f(x1) * (x1 - x0) / (f(x1) - f(x0));
printf("%d\t %.6f\t %.6f\t %.6f\t %.6f\n",
iter+1, x0, x1, x2, f(x2));
if (fabs(f(x2)) < tolerance) break;
x0 = x1;
x1 = x2;
iter++;
}
printf("\nApproximate root: %.8f\n", x2);
return 0;
}
4. Comparison of All Three Methods
This is one of the most commonly asked examination questions. Know this table thoroughly.
| Feature | Bisection | Newton-Raphson | Secant |
|---|---|---|---|
| Initial input | Interval [a,b] with f(a)f(b) < 0 | One guess x₀ | Two guesses x₀, x₁ |
| Requires f'(x)? | No | Yes (analytical) | No |
| Convergence rate | Linear (order 1) | Quadratic (order 2) | Superlinear (order ≈1.618) |
| Speed | Slowest | Fastest | Fast (between bisection and NR) |
| Guaranteed to converge? | Yes (if valid interval) | No | No |
| Sensitive to initial guess? | No | Yes | Moderate |
| Failure condition | No valid interval | f'(xₙ) = 0 | f(xₙ) = f(xₙ₋₁) |
| Suitable when | Need reliability | Have f'(x), want speed | f'(x) hard to compute |
5. Error Analysis and Stopping Criteria
All iterative methods need a criterion to stop. Common choices:
Tolerance on function value: |f(xₙ)| < ε (the function value is near zero)
Tolerance on iteration change: |xₙ₊₁ − xₙ| < ε (consecutive approximations are close)
Relative tolerance: |xₙ₊₁ − xₙ| / |xₙ₊₁| < ε (relative change is small)
Bisection specific error bound: After n iterations: error ≤ (b − a) / 2ⁿ
Number of bisection steps for tolerance ε starting from [a, b]:
n ≥ log₂[(b − a) / ε]
Example: For [1, 2] and tolerance 0.001: n ≥ log₂[(2−1)/0.001] = log₂(1000) ≈ 10 iterations
6. Algorithm Flowcharts
Bisection Algorithm (Pseudocode)
INPUT: f(x), a, b, tolerance ε
IF f(a) × f(b) ≥ 0: ERROR — invalid interval, STOP
REPEAT:
c ← (a + b) / 2
IF |f(c)| < ε OR (b − a)/2 < ε:
OUTPUT c as root, STOP
IF f(a) × f(c) < 0:
b ← c
ELSE:
a ← c
END REPEAT
Newton-Raphson Algorithm (Pseudocode)
INPUT: f(x), f'(x), x₀, tolerance ε, maxIter
FOR i = 1 to maxIter:
IF |f'(x₀)| < 1e-10: ERROR — zero derivative, STOP
x₁ ← x₀ − f(x₀) / f'(x₀)
IF |x₁ − x₀| < ε:
OUTPUT x₁ as root, STOP
x₀ ← x₁
OUTPUT: method did not converge
Secant Algorithm (Pseudocode)
INPUT: f(x), x₀, x₁, tolerance ε, maxIter
FOR i = 1 to maxIter:
IF |f(x₁) − f(x₀)| < 1e-10: ERROR — division by zero, STOP
x₂ ← x₁ − f(x₁)(x₁ − x₀) / (f(x₁) − f(x₀))
IF |f(x₂)| < ε:
OUTPUT x₂ as root, STOP
x₀ ← x₁
x₁ ← x₂
OUTPUT: method did not converge
7. Practice Numerical Questions
Newton-Raphson Practice
- Solve x³ + 4x² − 10 = 0 with x₀ = 1 (show 3 iterations)
- Find √10 using x₀ = 3 (find the formula first by setting f(x) = x² − 10)
- Solve cos x − x = 0 with x₀ = 0.7 (use radians; f'(x) = −sin x − 1)
- Solve x³ − 5 = 0 with x₀ = 2
- Find the positive root of x² − 5 = 0 (this gives √5)
Bisection Practice
- Find root of x³ − x − 2 = 0 in [1, 2] to 3 decimal places
- Solve x³ + 4x² − 10 = 0 in [1, 2] using 5 iterations
- Find root of eˣ − x − 2 = 0 in [1, 2]
- Solve x³ − 5x + 1 = 0 in [0, 1]
- Find the root of x − cos x = 0 in [0, π/2]
Secant Practice
- Solve x³ − x − 2 = 0 with x₀ = 1, x₁ = 2 (show 4 iterations)
- Solve x² − 5 = 0 with x₀ = 2, x₁ = 3
- Find root of eˣ − x − 2 = 0 with x₀ = 1, x₁ = 1.5
- Solve cos x − x = 0 with x₀ = 0.5, x₁ = 1
8. Frequently Asked TU Exam Questions
Long Questions (Most Likely)
- Derive the Newton-Raphson iterative formula from the tangent line interpretation. Explain quadratic convergence. Solve f(x) = x³ − x − 2 = 0 starting from x₀ = 1.5.
- State and prove that the Bisection Method always converges. Derive the error bound after n iterations. Find the root of x³ − x − 2 = 0 in [1, 2] using 5 iterations.
- Derive the Secant Method formula. Why does it not require derivative calculation? Solve x³ − x − 2 = 0 with x₀ = 1, x₁ = 2 using 3 iterations.
- Write the algorithm and C program for Newton-Raphson Method. Apply it to find √10.
- Compare the Bisection, Newton-Raphson, and Secant methods on: convergence rate, starting requirements, reliability, and computational cost.
Short Questions
- What is the order of convergence of Newton-Raphson Method?
- Why does the Bisection Method always converge?
- What are the starting requirements for each method?
- What is the stopping criterion in iterative root-finding?
- When would you prefer Secant over Newton-Raphson?
9. Important Formulas Quick-Reference
| Method | Iterative Formula |
|---|---|
| Bisection | cₙ = (aₙ + bₙ) / 2 |
| Newton-Raphson | xₙ₊₁ = xₙ − f(xₙ)/f'(xₙ) |
| Secant | xₙ₊₁ = xₙ − f(xₙ)(xₙ − xₙ₋₁)/[f(xₙ) − f(xₙ₋₁)] |
| Bisection error bound | |error| ≤ (b−a) / 2ⁿ |
| Bisection iterations needed | n ≥ log₂[(b−a)/ε] |
| Convergence orders | Bisection: 1, Secant: 1.618, Newton: 2 |
10. Exam Preparation Tips
Work problems by hand. Writing out each iteration in a table (like the ones in this guide) is exactly the format TU examinations expect. Practice doing this until it's automatic for each method.
Memorize the three iterative formulas. They should come instantly — you'll use them in both theory explanations and numerical calculations.
Understand convergence, don't just memorize order. Being able to explain why Newton-Raphson converges quadratically (error roughly squares each iteration because the tangent line approximation improves at that rate) earns more marks than stating "order 2."
For C programming questions: Make sure your code compiles and runs. The programs above are complete and tested — understand each line rather than copying blindly.
Write comparison tables neatly. The 8-column comparison table above will earn full marks on a "compare the three methods" question if written clearly.
Always state the stopping criterion in algorithm questions. Examiners consistently look for this — an algorithm without a termination condition is incomplete.
Frequently Asked Questions
Which method is fastest for root finding? Newton-Raphson is fastest in terms of iterations (quadratic convergence), but it requires computing f'(x) and can fail if the initial guess is poor. Secant is second-fastest without needing derivatives.
When should I use Bisection instead of Newton-Raphson? When you need guaranteed convergence and can bracket the root with an interval where f(a)f(b) < 0. Bisection never fails given a valid interval. Newton-Raphson is faster but not guaranteed to converge.
Can Newton-Raphson fail? Yes — if f'(xₙ) = 0 at any iteration (division by zero), or if the initial guess is far from the root in a region with inflection points, the method can diverge or cycle without converging.
Why does Secant need two initial guesses? Because it approximates the derivative using the slope between two previous points. With only one point, you have no slope to compute.
What is the relationship between Newton-Raphson and Secant? Secant is Newton-Raphson with the derivative replaced by a finite-difference approximation. If you take the limit as x₀ → x₁ in the Secant formula, you get Newton-Raphson.
Is Bisection suitable for programming? Yes — it's one of the easiest root-finding algorithms to implement correctly because it has no derivative requirement and guaranteed convergence. It's often used as a "fallback" when faster methods fail.
What does "order of convergence" mean? If the error at iteration n is eₙ, then order p means eₙ₊₁ ≈ C × eₙᵖ for some constant C. Order 1 (linear): each iteration cuts error by a constant factor. Order 2 (quadratic): error roughly squares each iteration — meaning correct digits double.
Conclusion
The Bisection, Newton-Raphson, and Secant methods represent three distinct points on the tradeoff curve between reliability and speed in numerical root-finding. Bisection always works but is slow. Newton-Raphson is fast but requires derivatives and careful initialization. Secant bridges the two — faster than bisection, no derivatives needed, slightly less reliable than Newton-Raphson.
Understanding all three — their derivations, convergence properties, failure conditions, and implementations — prepares you for every form of TU examination question on this topic, from short definitions to full C program implementations.
For related topics: Complete Data Structures and Algorithms (CSC211) Guide, C Programming (CSC115) Complete Guide, Mathematics-I (MTH117) Complete Guide, and Cryptography (CSC316) Important Questions.

0 Comments