- Asked 2/13
- 2074 Bhadra · 6 marks
- 2070 Magh · 6 marks
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)
Related questions
- Bisection method pseudo-code · Numerical Method, chapter 2 · asked 3×
- False position: e^cos x - sin x - 1 · Numerical Method, chapter 2
- Gauss-Jordan pseudo-code · Numerical Method, chapter 3 · asked 4×
- Secant algorithm, versus false position · Numerical Method, chapter 2
- False position: cos x = x e^x · Numerical Method, chapter 2 · asked 2×
- Power method pseudo-code · Numerical Method, chapter 3 · asked 2×
- Real and pseudo-parallelism · Microprocessor, chapter 6
- Algorithm/pseudo-code for software PID · Embedded System, chapter 7 · asked 3×
- Algorithm versus pseudo-code · Computer Programming, chapter 2
- Preemptive vs non-preemptive; real-time scheduling · Operating System, chapter 2