---
title: "Newton-Raphson algorithm"
subject: "Numerical Method"
chapter: 2
key: "semester_4/numerical_method:newton-raphson-algorithm"
source: https://www.bctengineer.com/q/semester_4/numerical_method/newton-raphson-algorithm
site: BCT Engineering
---

# Newton-Raphson algorithm

Numerical Method · Chapter 2: Solutions of Nonlinear Equations

- Asked in: 2068 Magh, 4 marks
- Video: [Newton-Raphson method | Animated and explained | Algorithm for finding roots of a function](https://www.youtube.com/watch?v=qlNqPE_X4ME) — MathAndPhysics
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/numerical_method/newton-raphson-algorithm
- Whole chapter: https://www.bctengineer.com/md/semester_4/numerical_method/chapter-2

## Question

Write an algorithm to find a real root of a non-linear equation using the Newton-Raphson method.

## Short answer

Newton-Raphson iteration: x(n+1) = x(n) - f(x(n))/f'(x(n)). Algorithm: input f, f', x0, tolerance e, max N. Loop: if |f'(x0)| near 0 stop; compute x1 = x0 - f(x0)/f'(x0); if |x1-x0| < e or |f(x1)| < e, root = x1; else x0 = x1; repeat until convergence or N iterations.

## Answer

Newton-Raphson iteration: x(n+1) = x(n) − f(x(n)) / f′(x(n)).

#### Algorithm / pseudo-code
```text
Algorithm: Newton-Raphson method
Input : f(x), f'(x), initial guess x0,
        tolerance e, maximum iterations N
Output: approximate root

1.  Read x0, e, N
2.  Set i = 1
3.  Repeat steps 4 to 9 while i <= N
4.      If |f'(x0)| is very small (near 0) then
            print "Derivative is zero; choose another x0"
            stop
5.      x1 = x0 - f(x0) / f'(x0)
6.      If |x1 - x0| < e (or |f(x1)| < e) then
            print "Root =", x1, "after", i, "iterations"
            stop
7.      x0 = x1
8.      i = i + 1
9.  End repeat
10. Print "Method does not converge in N iterations"
11. Stop
```

#### Notes
- Both f(x) and f′(x) must be coded as functions.
- The check in step 4 avoids division by zero.
- The iteration limit N stops an endless loop when the method diverges or oscillates.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Newton-Raphson algorithm needs:
   A. f(x), f'(x), x0, tolerance, N
   B. Only f
   C. Two guesses
   D. An interval
   Answer: A. Both functions coded. (Key point: Inputs)

2. Step 4 checks f'(x0) near 0 to:
   A. Test convergence
   B. Avoid division by zero
   C. Count steps
   D. Swap roots
   Answer: B. Derivative is the denominator. (Key point: Check)

3. Maximum iterations N prevents:
   A. Roundoff
   B. Zero derivative
   C. An endless loop on divergence or oscillation
   D. Bracketing
   Answer: C. Stops runaway iteration. (Key point: Limit N)

4. After testing, the algorithm sets:
   A. x1 = x0
   B. e = x1
   C. N = 0
   D. x0 = x1
   Answer: D. Next guess is the new value. (Key point: Update)

## Related in Numerical Method

- [Limitations of Newton-Raphson](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Alimitations-newton-raphson) — Numerical Method, chapter 2
- [Derive Newton-Raphson formula](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Anewton-raphson-derive) — Numerical Method, chapter 2, asked 2×
- [Secant method algorithm](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Asecant-method-algorithm) — Numerical Method, chapter 2, asked 2×

## Related in other subjects

- [Loop closure equation and Newton-Raphson method](https://www.bctengineer.com/question.md?key=semester_6%2Ftheory_of_mechanism_and_machine_i%3Aloop-closure-equation-newton-raphson) — Theory of Mechanism and Machine I, chapter 2
- [Preemptive vs non-preemptive; real-time scheduling](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apreemptive-nonpreemptive-realtime) — Operating System, chapter 2
- [Linear momentum and impulse-momentum equation](https://www.bctengineer.com/question.md?key=semester_5%2Ffluid_machines%3Alinear-momentum-impulse-equation) — Fluid Machines, chapter 1
- [What is a stack; linear or non-linear](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Astack-linear-or-nonlinear) — Data Structure and Algorithm, chapter 2
