![]() |
VOOZH | about |
Given a function f(x) on floating number x and two numbers ‘a’ and ‘b’ such that f(a)*f(b) < 0 and f(x) is continuous in [a, b]. Here f(x) represents algebraic or transcendental equation. Find root of function in interval [a, b] (Or find a value of x such that f(x) is 0).
Input: A function of x, for example x3 – x2 + 2.
And two values: a = -200 and b = 300 such that
f(a)*f(b) < 0, i.e., f(a) and f(b) have
opposite signs.
Output: The value of root is : -1.00
OR any other value close to root.
We strongly recommend to refer below post as a prerequisite of this post.
Solution of Algebraic and Transcendental Equations | Set 1 (The Bisection Method)
In this post The Method Of False Position is discussed. This method is also known as Regula Falsi or The Method of Chords.
Similarities with the Bisection Method:
Differences with Bisection Method:
It differs in the fact that we make a chord joining the two points [a, f(a)] and [b, f(b)]. We consider the point at which the chord touches the x axis and named it as c.
Steps:
y – f(a) = ( (f(b)-f(a))/(b-a) )*(x-a)
Now we have to find the point which touches x axis.
For that we put y = 0.
so x = a - (f(a)/(f(b)-f(a))) * (b-a)
x = (a*f(b) - b*f(a)) / (f(b)-f(a))
This will be our c that is c = x.
Since root may be a floating point number and may converge very slow in worst case, we iterate for a very large number of times such that the answer becomes closer to the root.
Following is the implementation.
The value of root is : -1
This method always converges, usually considerably faster than Bisection. But worst case can be very slow.
We will soon be discussing other methods to solve algebraic and transcendental equations.
References:
Introductory Methods of Numerical Analysis by S.S. Sastry
https://en.wikipedia.org/wiki/False_position_method