Bisection Method for root finding

download Bisection Method for root finding

of 47

description

A numerical method of getting root of an equation is well described.

Transcript of Bisection Method for root finding

  • CS1201Introduction to Computer Programming II

    Rangeet Bhattacharyya

    January 14, 2014

  • Root nding: bisection

    y

    xx1x2

    x3x1x3x2x3

    x2

    I You have a function in blue andI two initial points bracketing theroot.

  • Root nding: bisection

    y

    xx1x2

    x3

    x1x3x2x3

    x2

    I Find the intersection of the linejoining the two points and zeroaxis.

    I Check the sign of f (x3) f (x1).

  • Root nding: bisection

    y

    x

    x1

    x2

    x3

    x1

    x3x2x3x2

    I Get the new bracketing interval.x1 x3

  • Root nding: bisection

    y

    x

    x1

    x2

    x3

    x1x3

    x2x3x2

    I Find the middle of the bracketinginterval and

    I check the sign of f (x3) f (x1).

  • Root nding: bisection

    y

    x

    x1x2

    x3

    x1

    x3

    x2

    x3x2

    I Get the new bracketing interval.x2 x3

  • Root nding: bisection

    y

    x

    x1x2

    x3

    x1

    x3

    x2x3

    x2

    I Find the middle of the bracketinginterval and

    I check the sign of f (x3) f (x1)

  • Root nding: bisection

    y

    x

    x1x2

    x3

    x1

    x3x2x3

    x2

    I Get the new bracketing interval.x1 x3

    I Stop when |f (xn )| < orwidth of bracket < orcountMaxIter

  • Root nding: regula falsi

    y

    xx1x2

    x3x1 x3x1x3x1

    I You have a function in blue andI two initial points bracketing theroot.

  • Root nding: regula falsi

    y

    xx1x2

    x3

    x1 x3x1x3x1

    I Find the intersection of the linejoining the two points and zeroaxis.

    I Check the sign of f (x1) f (x3).

  • Root nding: regula falsi

    y

    x

    x1

    x2

    x3

    x1

    x3x1x3x1

    I Get the new bracketing interval.x1 x3

  • Root nding: regula falsi

    y

    x

    x1

    x2

    x3

    x1 x3

    x1x3x1

    I Find the intersection andI check the sign of f (x1) f (x3).

  • Root nding: regula falsi

    y

    x

    x1

    x2

    x3x1 x3

    x1

    x3x1

    I Get the new bracketing interval.x1 x3

  • Root nding: regula falsi

    y

    x

    x1

    x2

    x3x1 x3

    x1x3

    x1

    I Find the intersection andI check the sign of f (x1) f (x3)

  • Root nding: regula falsi

    y

    x

    x1

    x2

    x3x1 x3x1x3

    x1

    I Get the new bracketing interval.x1 x3

    I Stop when |f (xn )| < orwidth of bracket < orcountMaxIter

  • Root nding: Secant Method

    y

    xx1x2

    x3x4x5x6

    I You have a function in blueand

    I two initial points.

  • Root nding: Secant Method

    y

    xx1x2x3

    x4x5x6

    I Find the intersection of theline joining the two points andzero axis.xn = xn1 yn1 xn2xn1yn2yn1

    I You got your next guess.

  • Root nding: Secant Method

    y

    xx1x2x3x4

    x5x6

    I Get the new guess.xn2 xn1xn1 xnxn = xn1 yn1 xn2xn1yn2yn1

  • Root nding: Secant Method

    y

    xx1x2x3x4x5

    x6

    I Get the new guess.xn2 xn1xn1 xnxn = xn1 yn1 xn2xn1yn2yn1

  • Root nding: Secant Method

    y

    xx1x2x3x4x5x6

    I Get the new guess.xn2 xn1xn1 xnxn = xn1 yn1 xn2xn1yn2yn1

    I Stop when |f (xn )| < or countMaxIter

  • Root nding: Newton Raphson

    y

    xx1

    x2x3x4x5

    I You have a function in blueand

    I one initial point.

  • Root nding: Newton Raphson

    y

    xx1x2

    x3x4x5

    I Find the intersection ofthe tangent at (x , f (x ))and zero axis.xn = xn1 f (xn1)f (x1)

    I You got your next guess.

  • Root nding: Newton Raphson

    y

    xx1x2x3

    x4x5

    I Get the new guess.xn1 xnxn = xn1 f (xn1)f (x1)

  • Root nding: Newton Raphson

    y

    xx1x2x3x4

    x5

    I Get the new guess.xn1 xnxn = xn1 f (xn1)f (x1)

  • Root nding: Newton Raphson

    y

    xx1x2x3x4x5

    I Get the new guess.xn1 xnxn = xn1 f (xn1)f (x1)

    I Stop when |f (xn )| < or countMaxIter

  • Iterative methods

    y

    x(x1, 0)

    (x1, x2)(x2, x2)

    (x2, x3)(x3, x3)

    (x3, x4)(x4, x4)

    I Start with y = x andy = f (x ).

    I Calculate xn = f (xn1).Find (xn , xn ).Let xn1 xn .

  • Iterative methods

    y

    x(x1, 0)

    (x1, x2)(x2, x2)

    (x2, x3)(x3, x3)

    (x3, x4)(x4, x4)

    I Start with y = x andy = f (x ).

    I Calculate xn = f (xn1).Find (xn , xn ).Let xn1 xn .

  • Iterative methods

    y

    x(x1, 0)

    (x1, x2)(x2, x2)

    (x2, x3)(x3, x3)

    (x3, x4)(x4, x4)

    I Start with y = x andy = f (x ).

    I Calculate xn = f (xn1).Find (xn , xn ).Let xn1 xn .

  • Iterative methods

    y

    x(x1, 0)

    (x1, x2)(x2, x2)

    (x2, x3)(x3, x3)

    (x3, x4)(x4, x4)

    I Start with y = x andy = f (x ).

    I Calculate xn = f (xn1).Find (xn , xn ).Let xn1 xn .

    I Stop when |xn xn1| < or countMaxIter

  • Summary: Root nding

    I Why nd roots numerically?I Most equations cant be solved numerically.I For polynomial functions there can be no general solutiona root for polynomials of degree 5 or more.

  • Summary: Root nding

    I Why nd roots numerically?

    I Most equations cant be solved numerically.I For polynomial functions there can be no general solutiona root for polynomials of degree 5 or more.

  • Summary: Root nding

    I Why nd roots numerically?I Most equations cant be solved numerically.

    I For polynomial functions there can be no general solutiona root for polynomials of degree 5 or more.

  • Summary: Root nding

    I Why nd roots numerically?I Most equations cant be solved numerically.I For polynomial functions there can be no general solutiona root for polynomials of degree 5 or more.

  • Merits and demerits of the methods

    I Graph plottingEasiest. Not accurate. Precision depends on plotter

    I BisectionEasier, always works (for good brackets). Can be slow

    I Regular FalsiAlways work (good bracket, no sharp bend). Can be slow

    I SecantFast. Need good guesses (no extrema)

    I Newton RaphsonFaster. Works for complex numbers May go into traps,need good guess

    I Iterative methodsEasy Convergence is not guaranteed.

  • Merits and demerits of the methods

    I Graph plottingEasiest. Not accurate. Precision depends on plotter

    I BisectionEasier, always works (for good brackets). Can be slow

    I Regular FalsiAlways work (good bracket, no sharp bend). Can be slow

    I SecantFast. Need good guesses (no extrema)

    I Newton RaphsonFaster. Works for complex numbers May go into traps,need good guess

    I Iterative methodsEasy Convergence is not guaranteed.

  • Merits and demerits of the methods

    I Graph plottingEasiest. Not accurate. Precision depends on plotter

    I BisectionEasier, always works (for good brackets). Can be slow

    I Regular FalsiAlways work (good bracket, no sharp bend). Can be slow

    I SecantFast. Need good guesses (no extrema)

    I Newton RaphsonFaster. Works for complex numbers May go into traps,need good guess

    I Iterative methodsEasy Convergence is not guaranteed.

  • Merits and demerits of the methods

    I Graph plottingEasiest. Not accurate. Precision depends on plotter

    I BisectionEasier, always works (for good brackets). Can be slow

    I Regular FalsiAlways work (good bracket, no sharp bend). Can be slow

    I SecantFast. Need good guesses (no extrema)

    I Newton RaphsonFaster. Works for complex numbers May go into traps,need good guess

    I Iterative methodsEasy Convergence is not guaranteed.

  • Merits and demerits of the methods

    I Graph plottingEasiest. Not accurate. Precision depends on plotter

    I BisectionEasier, always works (for good brackets). Can be slow

    I Regular FalsiAlways work (good bracket, no sharp bend). Can be slow

    I SecantFast. Need good guesses (no extrema)

    I Newton RaphsonFaster. Works for complex numbers May go into traps,need good guess

    I Iterative methodsEasy Convergence is not guaranteed.

  • Merits and demerits of the methods

    I Graph plottingEasiest. Not accurate. Precision depends on plotter

    I BisectionEasier, always works (for good brackets). Can be slow

    I Regular FalsiAlways work (good bracket, no sharp bend). Can be slow

    I SecantFast. Need good guesses (no extrema)

    I Newton RaphsonFaster. Works for complex numbers May go into traps,need good guess

    I Iterative methodsEasy Convergence is not guaranteed.

  • Merits and demerits of the methods

    I Graph plottingEasiest. Not accurate. Precision depends on plotter

    I BisectionEasier, always works (for good brackets). Can be slow

    I Regular FalsiAlways work (good bracket, no sharp bend). Can be slow

    I SecantFast. Need good guesses (no extrema)

    I Newton RaphsonFaster. Works for complex numbers May go into traps,need good guess

    I Iterative methodsEasy Convergence is not guaranteed.

  • Root nding: useful tips

    I Plotting helps. Visualization often help nd good brackets(or starting point).

    I For smooth functions usually Newton Raphson gives goodresult.

    I For functions with sharp bend or extrema within thebracket bisection may be better choice.

    I Always start by restricting the number of iterations tonite value.

    I Check for roots at the ends (of the bracket).I Check for good bracketing interval (for bisection andregula falsi).

    I Good luck!

  • Root nding: useful tips

    I Plotting helps. Visualization often help nd good brackets(or starting point).

    I For smooth functions usually Newton Raphson gives goodresult.

    I For functions with sharp bend or extrema within thebracket bisection may be better choice.

    I Always start by restricting the number of iterations tonite value.

    I Check for roots at the ends (of the bracket).I Check for good bracketing interval (for bisection andregula falsi).

    I Good luck!

  • Root nding: useful tips

    I Plotting helps. Visualization often help nd good brackets(or starting point).

    I For smooth functions usually Newton Raphson gives goodresult.

    I For functions with sharp bend or extrema within thebracket bisection may be better choice.

    I Always start by restricting the number of iterations tonite value.

    I Check for roots at the ends (of the bracket).I Check for good bracketing interval (for bisection andregula falsi).

    I Good luck!

  • Root nding: useful tips

    I Plotting helps. Visualization often help nd good brackets(or starting point).

    I For smooth functions usually Newton Raphson gives goodresult.

    I For functions with sharp bend or extrema within thebracket bisection may be better choice.

    I Always start by restricting the number of iterations tonite value.

    I Check for roots at the ends (of the bracket).I Check for good bracketing interval (for bisection andregula falsi).

    I Good luck!

  • Root nding: useful tips

    I Plotting helps. Visualization often help nd good brackets(or starting point).

    I For smooth functions usually Newton Raphson gives goodresult.

    I For functions with sharp bend or extrema within thebracket bisection may be better choice.

    I Always start by restricting the number of iterations tonite value.

    I Check for roots at the ends (of the bracket).

    I Check for good bracketing interval (for bisection andregula falsi).

    I Good luck!

  • Root nding: useful tips

    I Plotting helps. Visualization often help nd good brackets(or starting point).

    I For smooth functions usually Newton Raphson gives goodresult.

    I For functions with sharp bend or extrema within thebracket bisection may be better choice.

    I Always start by restricting the number of iterations tonite value.

    I Check for roots at the ends (of the bracket).I Check for good bracketing interval (for bisection andregula falsi).

    I Good luck!

  • Root nding: useful tips

    I Plotting helps. Visualization often help nd good brackets(or starting point).

    I For smooth functions usually Newton Raphson gives goodresult.

    I For functions with sharp bend or extrema within thebracket bisection may be better choice.

    I Always start by restricting the number of iterations tonite value.

    I Check for roots at the ends (of the bracket).I Check for good bracketing interval (for bisection andregula falsi).

    I Good luck!