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!