Results 1 to 6 of 6

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

  1. #1
    s3a
    s3a is offline
    Super Member
    Joined
    Nov 2008
    Posts
    602

    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!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor

    Joined
    Apr 2005
    Posts
    19,109
    Thanks
    2802

    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: x_7= 0.8526053068321621, [tex]x_8= 0.8526054808885619[//tex], and all succeeding x terms, round to 0.852606, not 0852605.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor
    Joined
    Nov 2010
    Posts
    2,531
    Thanks
    961

    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.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    s3a
    s3a is offline
    Super Member
    Joined
    Nov 2008
    Posts
    602

    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?
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor
    Joined
    Nov 2010
    Posts
    2,531
    Thanks
    961

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

    Quote Originally Posted by s3a View Post
    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.
    Last edited by SlipEternal; Jul 14th 2017 at 03:58 AM.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    MHF Contributor
    Joined
    Nov 2010
    Posts
    2,531
    Thanks
    961

    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.
    Last edited by SlipEternal; Jul 14th 2017 at 06:14 AM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. method of false position (Regula Falsi)
    Posted in the Discrete Math Forum
    Replies: 0
    Last Post: Apr 30th 2013, 12:49 AM
  2. Bisection and Regula Falsi Problems. Please solve.
    Posted in the Advanced Applied Math Forum
    Replies: 0
    Last Post: Mar 9th 2013, 07:32 PM
  3. Error-bound on Regula Falsi
    Posted in the Calculus Forum
    Replies: 4
    Last Post: Sep 6th 2010, 03:42 AM
  4. Replies: 3
    Last Post: Mar 6th 2010, 04:40 AM
  5. Replies: 3
    Last Post: Nov 3rd 2007, 01:43 PM

/mathhelpforum @mathhelpforum