Root of a Function

Created


1-D Root Finding

We want to find the location which f(x) = 0. Difficult cases:

  • Tangent points are difficult to find
  • Signularity: brackets don't surround the root.
  • Pathological case: infinite number of roots, e.g., sin(1x)sin(\frac{1}{x})

Bisection

The bisection method is a variation of the incremental search method in which the interval is always divided in half.

  • If the function changes signs over an interval, the function value at the midpoint is evaluated.
  • The location of the root is determined as lying within the subinterval where the sign change occurs
  • The absolute error is reduced by a factor of 2 for each iteration.

Newton's Method

Approximates real zeros by using tangent lines to approximate the graph of the function near its x-intercepts.

  • If f(a) and f(b) differ in sign, then, by the Intermediate Value Theorem, f must have at least one zero in the interval (a, b)
  • Choose x = x_1 to start estimate the zero.
  • Based on the assumption that the graph of f and the tangent line at (x_1, f(x_1)) both cross the x-axis at about the same point. Create the equation of the tangent line:
  • y=f′(x1)(x−x1)+f(x1)y = f'(x_{1})(x-x_{1})+f(x_{1})
  • We let y = 0 and solve for x. This becomes your new estimate.

The newton's method fails to converge if f(xn)=0f(x_{n}) = 0

Optimization

Optimization is finding the "best" value of a function f(x), which can be the best minimum. The numver of "turning points" of a function depend on the order of the function, which can be a minima, maxima, or inflection points.

The minima or maxima is the zero derivative, so you can apply newton's method on the derivative of the function.

The algorithm is as follows:

  • Initialize x0x_{0}
  • On the Kth iteration: approximate f'(x) by the tangent at x_k
  • Find the location x_intersect wher ethe tangent goes to zero. Set the new x to the new x intersect.
  • Iterate

fzero function.

MATLAB's fzero functino provides the best qualities of both bracketing methods and open methods. Using an intial guess: x = fzero(function, x0) or [x,fx] = fzero(function, x0)

  • function is a function handle to the function being evaluated.
  • x0 is the initial guess
  • x is the location of the root
  • fx is the fuction evaluated at that root.

Use an initial bracket where x0 and x1 are guesses that must bracket a sign change: x = fzero(function, [x0],[x1])

Set options using the comand optimset. Then, use it when running fzero E.g., [x,fx] = fzero(@(x) x^10-1, 0.5, options)

Polynomials

roots determines all the roots of a polynomial, including imaginary and complex ones.

x = roots(c) where x is a column vector containing all the roots and c is a row vector contaiing the polynomial coefficients.

If the roots are given , the poly function can be used to determine polynomial coefficients. b = poly([0.5 -1]) finds f(x) where f(x) for x=0.5 and x=-1.

polyval function evaluates the polynomial at one or more points. If a were the coefficients of the polynomial, polyval(a,1) calculates f(1).