Skip to main content

False position pseudo-code

Short answer

The false position method starts with a and b such that f(a)f(b)<0. Iteratively compute c = (a f(b) - b f(a))/(f(b)-f(a)). If f(c)=0 or |c-c_old|<e, stop. Else if f(a)f(c)<0 set b=c else a=c. The root remains bracketed, ensuring convergence.

Write pseudo-code for finding a real root of a non-linear equation using the False Position Method.

False Position (Regula Falsi) uses the chord joining (a, f(a)) and (b, f(b)) with f(a)·f(b) < 0; the point where the chord cuts the x-axis replaces one end so that the root stays bracketed.

Formula

c = (a f(b) − b f(a)) / (f(b) − f(a))

Pseudo-code

Algorithm: False Position method
Input : f(x), a, b, tolerance e, max iterations N
Output: approximate root

1.  Read a, b, e, N
2.  If f(a) * f(b) >= 0 then
        print "Root not bracketed"; stop
3.  Set i = 1, c_old = a
4.  Repeat steps 5 to 10 while i <= N
5.      c = (a*f(b) - b*f(a)) / (f(b) - f(a))
6.      If f(c) = 0 or |c - c_old| < e then
            print "Root =", c, "after", i, "iterations"
            stop
7.      If f(a) * f(c) < 0 then
            b = c
        else
            a = c
8.      c_old = c
9.      i = i + 1
10. End repeat
11. Print "Method did not converge in N iterations"
12. Stop

The root always remains inside [a, b], so the method cannot diverge, and it is usually faster than bisection.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Numerical Method chapter 2 questions →