Lecture 5 Single Variable Problems - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Lecture 5 Single Variable Problems

Description:

If so you may be able to create a custom algorithm for the problem. ... This must be guarded against. Basic Root Finding Techniques ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 36
Provided by: San59
Category:

less

Transcript and Presenter's Notes

Title: Lecture 5 Single Variable Problems


1
Lecture 5 - Single Variable Problems
  • CVEN 302
  • June 12, 2002

2
Lectures Goals
  • Introduction of Solving Equations of 1 Variable
  • Bisection Method
  • Linear interpolation Secant Method
  • Newtons Method
  • Mullers Method
  • Fixed Point Iteration

3
General Considerations
  • Is the function to be evaluated often?
  • If so you may be able to create a custom
    algorithm for the problem.
  • How much precision is needed?
  • Engineering calculations are often required for a
    few significant figures. A simple root finding
    procedure may be adequate.

4
General Considerations
  • How fast and robust must the method be?
  • If the root finding is embedded in another
    program that automatically changes the parameter
    f(x), it is important that the root finder is
    robust. A robust procedure is relatively immune
    to initial guess and it converges quickly without
    being overly sensitive to the behavior of the
    function.

5
General Considerations
  • Is the function a polynomial?
  • There are special procedures for finding roots of
    polynomials. These should be used instead of
    general procedures such as bisection, Newtons
    method or secant method.

6
Does the function have singularities?
Some root finding procedure will converge to a
singularity, as well as converge to a root. This
must be guarded against.
7
Basic Root Finding Techniques
The initial procedure is to find the roots of a
function. The main concept of each technique is
to bracket the root and do a series of iteration
until the method converges on a solution.
8
Root Finding Techniques
  • Bracket the roots
  • Determine the method
  • Iterate to find the solution

9
Convergence Criteria
  • The algorithm must decide on how close to the
    root the guess should be before stopping.
  • Two criteria can be applied in testing.
  • Magnitude by which estimate of root changes.
  • Magnitude by which the function will change.

10
Bisection Method
  • The method is known as the Bolzano method and can
    be called interval halving technique.
  • The method is simple and straight-forward.
  • Given a bracketed root, the method repeatedly
    halves the interval while continuing to bracket
    the root and it will converge on the solution.

11
Bisection Method (Algorithm)
  • Do while 0.5x1 - x2 gt tolerance value
  • Set x3 (x1 x2)/2
  • IF f(x3) of opposite sign of f(x1)
  • Set x2 x3
  • ELSE
  • Set x1 x3
  • ENDIF
  • END loop

12
Bisection Method
DemoBisect the example program does a simple
bisection for a cubic polynomial equation.
13
Bisection Method
  • Example Problem
  • f(x) a5 x5 a4 x4 a3 x3 a2 x2 a1 x a0
  • Let the function
  • a0 -2, a1 -3, a2 4, a3 1, a4 0, a5
    1
  • f(x) x5 x3 4x2 - 3x - 2

14
Bisection Method
  • There are 3 roots
  • (a) -2 lt x lt -1
  • (b) -1 lt x lt 0
  • (c) 0.5 lt x lt1.5

15
Bisection Method
  • x1 f(x1) x2 f(x2) d
    x3 f(x3)
  • -2.0000 -20.000 -1.0000 3.00000 1.0000
    -1.5000 0.53125
  • -2.0000 -20.000 -1.5000 0.53125 0.5000
    -1.7500 -6.27246
  • -1.7500 -6.2725 -1.5000 0.53125 0.2500
    -1.6250 -2.18448
  • -1.6250 -2.1848 -1.5000 0.53125 0.1250
    -1.5625 -0.67480
  • -1.5625 -0.6748 -1.5000 0.53125 0.0625
    -1.53125 -0.03612
  • etc. etc. etc. etc. etc.
    etc. etc.

16
Linear Interpolation
  • The bisection method is not very efficient. We
    would like to converge to the root at a faster
    rate with a different algorithm.
  • One of these method is linear interpolation
    method or the method of false position (Latinized
    version Regula Falsi )

17
Method of Linear InterpolationRegula Falsi
  • Do while x2 - x1 gt tolerance value 1
  • or f(x3)gt
    tolerance value 2
  • Set x3 x2 - f(x2)(x2 - x1)/(f(x2)-f(x1))
  • IF f(x3) of opposite sign of f(x1)
  • Set x2 x3
  • ELSE
  • Set x1 x3
  • ENDIF
  • END loop

18
Regula Flasi or Linear Interpolation
The program uses the slope of the two points to
find the intersection. However, the upper bound
is kept constant. The program uses a similar
triangle to estimate the location of the root.
19
Linear Interpolation
  • Same example problem
  • f(x) x5 x3 4x2 - 3x - 2
  • roots are between (-1.7,-1.3), (-1,0), (0.5,1.5)

20
Regula Falsi Method
  • x1 f(x1) x2
    f(x2) x2-x1 f(x2)-f(x1) x3
    f(x3)
  • -1.7000 -4.4516 -1.3000 2.75007 0.4000
    7.2016 -1.45275 1.2635
  • -1.7000 -4.4516 -1.4528 1.2635 0.2472
    5.7143 -1.50743 0.40265
  • -1.7000 -4.4516 -1.5074 0.40265 0.1926
    4.8547 -1.52339 0.11307
  • -1.7000 -4.4516 -1.5234 0.11293 0.1766
    4.5645 -1.52777 0.03052
  • etc. etc. etc. etc.
    etc. etc. etc.
    etc.

21
Secant Method
  • The algorithm is similar to the linear
    interpolation method but it oscillates from one
    side to the next.
  • The method converges quickly with well behaved
    functions.

22
Secant Method
  • Do while x2 - x1 gt tolerance value 1
  • or f(x3)gt
    tolerance value 2
  • Set x3 x2 - f(x2)(x2 - x1)/(f(x2)-f(x1))
  • Set x1 x2
  • Set x2 x3
  • END loop

23
Comparison between Linear Interpolation and
Secant Method
The secant can be faster method, because it does
not have a large slope at the root.
24
Problems with the Secant Method
  • The convergence condition is
  • x3 x2 - f(x2)
  • (x2-x1)/(f(x2)-f(x1))
  • It is tempting to rewrite the
  • convergence condition.
  • x3 (f(x2)x1-f(x1) x2 )
  • /(f(x2)-f(x1))

25
Problems with the Secant Method
  • This method can be
  • catastrophic if the points
  • are near a point where the
  • first derivative is zero.
  • Example SecantProb
  • Try for the interval (1,3)

26
Secant Method
  • The Secant method is the same as the linear
    interpolation method, but you do not do a
    comparison between /- values and do the
    substitution.
  • Problem if the points are on opposite ends of a
    peak or trough.

27
Secant Method
  • x1 f(x1) x2 f(x2)
    x2-x1 f(x2)-f(x1) x3 f(x3)
  • -1.7000 -4.4516 -1.3000 2.7501 0.4000
    7.2016 -1.45275 1.2635
  • -1.4528 1.2635 -1.7000 -4.4516 -0.2472
    -5.7143 -1.50743 0.40265
  • -1.5074 0.4031 -1.4528 1.2635 0.0546
    0.8596 -1.53300 -0.07000
  • -1.5330 -0.0700 -1.5074 0.4031 0.0256
    0.4731 -1.52921 -0.00297
  • etc. etc. etc. etc. etc.
    etc. etc. etc.

28
Newtons Method
  • This method is one of the most widely used
    methods to solve equations also known as the
    Newton-Raphson.
  • The idea for the method comes from a Taylor
    series expansion, where you know the function and
    its first derivative.
  • f(xk1) f(xk) (xk1 - xk)f (xk) ...

29
Newtons Method
  • The goal of the calculations is to find a f(x)0,
    so set f(xk1) 0 and rearrange the equation.
    f (xk) is the first derivative of f(x).

30
Newton-Raphson Method
  • The method uses the
  • slope of the line to
  • project to the x axis and
  • find the root. The
  • method converges on the
  • solution quickly.

31
Newtons Method
  • Do while x2 - x1 gt tolerance value 1
  • or f(x2)gt tolerance
    value 2
  • or f(x1) 0
  • Set x2 x1 - f(x1)/f(x1)
  • Set x1 x2
  • END loop

32
Newtons Method
  • Same example problem
  • f(x) x5 x3 4x2 - 3x - 2
  • and
  • f(x) 5x4 3x2 8x - 3
  • roots are between (-1.7,-1.3), (-1,0), (0.5,1.5)

33
Newtons Method
  • x1 f(x1) f(x1) f(x1)/f(x1)
    x2
  • -2.0000 -20.0000 73.0000 -0.27397
    -1.7260
  • -1.7260 -5.3656 36.5037 -0.14699
    -1.5790
  • -1.5790 -1.0423 22.9290 -0.04546
    -1.5335
  • -1.5335 -0.0797 19.4275 -0.00410
    -1.5294
  • -1.5294 -0.0005 19.1381 -0.00003
    -1.5294
  • etc. etc. etc.
    etc. etc.

34
Summary
  • Bisection - need to know f(x) and two bounds.
  • Regula Flasi (linear interpolation) - need to
    know the function and two bounds.
  • Secant - need to know f(x) and two bounds.
  • Newtons - need to know f(x) and f(x) and an
    initial guess.

35
Homework
  • Check the Homework webpage
Write a Comment
User Comments (0)
About PowerShow.com