The Bisection Method In R

Hello there. This page is on using R to find approximate roots with the bisection method.

You may want to refer to my page on The Bisection Method for more details.

 


Sections

What Is The Bisection Method? (Brief)

The Bisection Method In R

Some Examples

References

 


What Is The Bisection Method? (Brief)

The Bisection Method belongs to a class of numerical methods found in applied/computational mathematics. There are cases when the exact answer to a question cannot be found. Approximate solutions (with a small acceptable margin of error) are used instead.

 


The Bisection Method In R

In my R code, I define a few functions as examples. I have the functions as x^2 - 7, x^2 - 5 and e^x - 2.

 

 

In the bisection method function, I have the inputs as a, b from the interval [a, b], the tolerance (margin of error allowed) represented by tol and the function f. (I have f = funct_1 by default.)

The output from the bisection method would be the approximate solution to the function. This approximate solution would be off from the exact solution by less than the tolerance.

 


Some Examples

After defining the functions into R, function calls can be made. Here are some outputs from the bisection method.

 

 


References

  • http://www.dummies.com/programming/r/how-to-use-functions-as-arguments-in-r/
  • Tim Sauer – Numerical Analysis Second Edition