# Thread: What is wrong with my application of the Regula Falsi numerical method?

1. ## What is wrong with my application of the Regula Falsi numerical method?

The problem:
I'm trying to find the root of the function f(x) = x e^x - 2, correct to six decimal places.

In addition to doing this problem by hand (to rule out computer problems, for one), without any rounding until the end, and by using a software calculator (as shown below), I also created a Java program which did the same thing and came up with the same problem.

Basically, to describe my work below with words, what I am doing is I keep computing x_i values, using the Regula Falsi formula, and I keep using the largest x_L value known, in the given iteration, where f(x_L) < 0 (since f(a) = f(0) < 0) as well as the smallest x_R value known, in the given iteration, where f(x_R) > 0 (since f(b) = f(1) > 0). Then, I keep computing new x_i until I find two consecutive values that, when rounded to m (in this case, m = 6) decimal places, and those x_i values rounded to m decimal places is the final answer. However, for this problem, when I do that, I get the root, correct to six decimal places, as being 0.852605, as opposed to the actual root's value rounded to six decimal places, which is 0.852606. I know the actual root's value by using the WolframAlpha.com website.

Here is the specific Wolfram Apha link I am consulting.:
Wolfram|Alpha: Computational Knowledge Engine

Here is my work.:
f(0) < 0
f(1) > 0

f(0) f(1) < 0

x_1 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0 and x_R = 1
x_1 = 0.7357588823428847
f(x_1) = f(0.7357588823428847) < 0

x_2 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.7357588823428847 and x_R = 1
x_2 = 0.8395207719865585
f(x_2) = f(0.8395207719865585) < 0

x_3 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.8395207719865585 and x_R = 1
x_3 = 0.8511838581593802
f(x_3) = f(0.8511838581593802) < 0

x_4 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.8511838581593802 and x_R = 1
x_4 = 0.8524515685451858
f(x_4) = f(0.8524515685451858) < 0

x_5 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.8524515685451858 and x_R = 1
x_5 = 0.8525888405206965
f(x_5) = f(0.8525888405206965) < 0

x_6 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.8525888405206965 and x_R = 1
x_6 = 0.8526036986750377
f(x_6) = f(0.8526036986750377) < 0

x_7 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.8526036986750377 and x_R = 1
x_7 = 0.8526053068321621
f(x_7) = f(0.8526053068321621) < 0

x_8 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.8526053068321621 and x_R = 1
x_8 = 0.8526054808885619

f(x_8) = f(0.8526054808885619) < 0

x_9 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.8526054808885619 and x_R = 1
x_9 = 0.8526054997272774
f(x_9) = f(0.8526054997272774) < 0

x_10 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.8526054997272774 and x_R = 1
x_10 = 0.8526055017662555
f(x_10) = f(0.8526055017662555) < 0

x_11 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.8526055017662555 and x_R = 1
x_11 = 0.852605501986941
f(x_11) = f(0.852605501986941) < 0

x_12 = (x_L*f(x_R)-x_R*f(x_L)) / (f(x_R) - f(x_L)), where x_L = 0.852605501986941 and x_R = 1
x_12 = 0.8526055020108264
f(x_12) = f(0.8526055020108264) < 0

It is the case that x_7, rounded to six decimal places = x_8, rounded to six decimal places = 0.852605 (which are also equal to the values of x_9 and x_10, each rounded to six decimal places), but it is also the case that x_11, rounded to six decimal places = x_12, rounded to six decimal places = 0.852606.

So, it appears that checking for two consecutive x_i to be equal, when rounded to six decimal places, is not a reliable way for the algorithm to exit with the correct value (as can be seen in my work above, which ends too early and finds the incorrect approximation), so what would be then?

For what it's worth, I also encounter the same exact problem when using the bisection method. Using the bisection and the Regula Falsi methods as I have shown above has always worked for me, until the problem of this thread. Doesn't each new x_i serve as a new endpoint for the interval containing the root, where the new interval is a smaller one, such that the problem I experienced above should not happen? For example, if some interval (alpha, beta) contains some root r, and it is the case that alpha, rounded to m decimal places = beta, rounded to m decimal places, shouldn't it always be the case that r, rounded to m decimal places is equal to both alpha, rounded to m decimal places and beta, rounded to m decimal places?

I've been stuck on this for VERY long, so any help would be GREATLY appreciated!

2. ## Re: What is wrong with my application of the Regula Falsi numerical method?

I frankly don't understand what you are complaining of. I don't see any difficulty in what you are doing. I will say that it looks as if you are rounding incorrectly: $\displaystyle x_7= 0.8526053068321621$, [tex]x_8= 0.8526054808885619[//tex], and all succeeding x terms, round to 0.852606, not 0852605.

3. ## Re: What is wrong with my application of the Regula Falsi numerical method?

If you are trying to get it accurate within 6 decimal places, once you get close, you can use trial and error. Try $f(0.852605), f(0.852606), f(0.852607), \ldots$. Eventually, you will start getting further away from your goal rather than closer two it. Once you have two terms round to the same value, it becomes a very easy spot to try testing rounded values.

4. ## Re: What is wrong with my application of the Regula Falsi numerical method?

Everyone:
Thanks for your responses.

HallsofIvy:
x_7 = 0.8526053068321621
x_8 = 0.8526054808885619

Basically, if I were to do this problem from scratch, even though it seems that the values seem to round to 0.852606 as of x_11, I will never reach that value, because I will have stopped at x_8 (since it will have rounded to the same thing as x_7, to six decimal places, that is, 0.852605), and that's the main issue I'm having.

In the case of this problem, it seems to me that the reason why I'm having that issue is that the actual root is bracketed between my latest x_i and 1. That is, the the actual root is within the interval [a_i, b_i] = [x_i, 1], but the right side of the interval always remains a 1. If the right side of the interval also approached the actual value of the root, and the two endpoints of the interval, rounded to six decimal places, were the same, then I'd get the correct value, but the way things are going, it seems like I'm only getting the left endpoint approaching the actual value of the root, and it's not too surprising that two consecutive values were then rounded to an incorrect value.

SlipEternal:
I'd like to master not just an algorithmic/step-by-step approach, in general, but specifically the Regula Falsi algorithm.

Everyone:
What am I doing wrong?

5. ## Re: What is wrong with my application of the Regula Falsi numerical method?

Originally Posted by s3a
Everyone:
What am I doing wrong?
You are not doing anything wrong. To determine accuracy of your answer, you can take the derivative of $f$ at $x_8$. Let $c$ be the actual zero of $f$. You are looking for $|c-x_8|<\dfrac{10^{-6}}{2}$ I think (it might be $10^{-12}$). Anyway, $f'(x_8) \approx \dfrac{0-f(x_8)}{c-x_8}$. So,

$\left|\dfrac{f(x_8)}{f'(x_8)}\right| \approx |c-x_8|$

This tells you about how close your answer is.

6. ## Re: What is wrong with my application of the Regula Falsi numerical method?

The derivative method is not correct. I just realized that to estimate error that way, you would need an infinite series.

### regula falsi method actual applications

Click on a term to search for related topics.