So I'm being given a task by my lecturer to write a program that uses the False Position Method to find the approximation of a function's root within an interval $ \space [a,b] \space $.

We are given the following equations to use:

The equation of the line passing through $\space f(a) \space$, the $\space x \space$ axis and $\space f(b) \space$:

$$y = {{x(f(b) - f(a)) - af(b) + bf(a)}\over {b-a}}$$

The value of $\space x \space$ when it crosses the $\space x \space$ axis (when $\space y=0 \space$):

$$x_{0} = b - {{b-a}\over f(b)-f(a)}f(b)$$

The only problem is, we are only given the value $\space x_0 \space$ to use as an estimate of the root.

We have to use that estimate to find some formula/formulae such that NO MATTER WHAT FUNCTION WE USE (as long as it has real roots), it will always give use appropriate values of $\space a \space$ and $\space b \space$.

How do I do this?

I hope I'm making sense.

  • 1
    $\begingroup$ Try $x_0,x_0+1$ maybe? $\endgroup$ – copper.hat May 10 '17 at 20:34

You can try with the interval $(x-h,x+h)$, starting with $h=1$ and $h=h/2$ each iteration. If $r\in(x-h,x+h)$ is the root and $f^\prime(r)\neq 0$ then it should converge. This can fail if $r$ is a multiple root, so you can stop if $h\leq\epsilon$ (for some $\epsilon$) and can try some steps of $h=h+1$.

If $f$ is like a black box, you must take extra care of exceptions, like tangential roots, discontinuinities, and asymptotes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.