Root Finding

Introduction

This module provides functions for finding the roots of univariate functions.

API

NumericalMethods.Roots.bisectMethod
bisect(f, xlow, xhigh; tol=1.0e-6, maxiter=30, verbose=false, kwargs...)

Find the root of f in the interval [xlow, xhigh] using the bisection method.

Such a method will not work in multiple dimensions.

Arguments

  • f::Function: The function to find the root of.
  • xlow::Real: The lower bound of the interval.
  • xhigh::Real: The upper bound of the interval.
  • tol::Real=1.0e-6: The tolerance for the root.
  • maxiter::Integer=30: The maximum number of iterations to perform.
  • kwargs...: Additional keyword arguments to pass to f.

Returns

  • xroot::Real: The root of f.
  • fxroot::Real: The value of f at the root.
  • xlow::Real: The lower bound of the root interval.
  • xhigh::Real: The upper bound of the root interval.
  • niter::Integer: The number of iterations performed.
source
NumericalMethods.Roots.brentMethod
brent(f::Function, x_0, x_1; tol=1e-6, max_iter=1000, kwargs...)

Use Brent's method to find the root of a function f.

Arguments

  • f::Function: The function to find the root of.
  • x_0::Real: The first guess.
  • x_1::Real: The second guess.
  • rtol::Real=1e-6: The tolerance for the root.
  • ftol::Real=1e-6: The tolerance for the function value.
  • max_iter::Integer=1000: The maximum number of iterations to perform.
  • kwargs...: Additional keyword arguments to pass to f.

Returns

  • xroot: The root of f.
  • fxroot: The value of f at the root.
  • iter: The number of iterations performed.
source
NumericalMethods.Roots.newtonMethod
newton(f, x_0; tol=1e-6, max_iter=1000, kwargs...)

Use Newton's method to find the root of a multivariate function f: R^n → R.

Arguments

  • f::Function: The function to find the root of.
  • x_0: The first guess.
  • tol=1e-6: The tolerance for the root.
  • max_iter=1000: The maximum number of iterations to perform.
  • kwargs...: Additional keyword arguments to pass to f.

Returns

  • xroot: The root of f.
  • fxroot: The value of f at the root.
  • iter: The number of iterations performed.
source
NumericalMethods.Roots.newtonMethod
newton(f, x_0; tol=1e-6, max_iter=1000, kwargs...)

Use Newton's method to find the root of a function f: R → R.

Arguments

  • f::Function: The function to find the root of.
  • x_0::Real: The first guess.
  • tol=1e-6: The tolerance for the root.
  • max_iter=1000: The maximum number of iterations to perform.
  • kwargs...: Additional keyword arguments to pass to f.

Returns

  • xroot: The root of f.
  • fxroot: The value of f at the root.
  • iter: The number of iterations performed.
source
NumericalMethods.Roots.secantMethod
secant(f, x_0, x_1; tol=1e-6, max_iter=1000, kwargs...)

Use the secant method to find the root of a function f.

Arguments

  • f::Function: The function to find the root of.
  • x_0::Real: The first guess.
  • x_1::Real: The second guess.
  • tol::Real=1e-6: The tolerance for the root.
  • max_iter::Integer=1000: The maximum number of iterations to perform.
  • kwargs...: Additional keyword arguments to pass to f.

Returns

  • xroot: The root of f.
  • fxroot: The value of f at the root.
  • iter: The number of iterations performed.
source