10
NUMERICAL SOLUTIONS: Solved Examples By Mahmoud SAYED AHMED Ph.D. Candidate Department of Civil Engineering, Ryerson University Toronto, Ontario 2013 Table of Contents Part I: Numerical Solution for Single Variable............................................................................................... 2 1.1. Newton-Raphson Method ............................................................................................................ 2 1.2. Secant Methods ............................................................................................................................ 4 Part Two: Numerical Solutions for Multiple Variables ................................................................................. 6 2.1. Generalized Newton-Raphson Method for Two Variables ........................................................... 6 2.2. Multi-dimensional case for Newton-Raphson Method ................................................................ 9 Appendix: Matrix ........................................................................................................................................ 10

Numerical Methods MSA Libre

Embed Size (px)

DESCRIPTION

Numerical Methods

Citation preview

  • NUMERICAL SOLUTIONS:

    Solved Examples

    By

    Mahmoud SAYED AHMED

    Ph.D. Candidate

    Department of Civil Engineering, Ryerson University

    Toronto, Ontario 2013

    Table of Contents Part I: Numerical Solution for Single Variable............................................................................................... 2

    1.1. Newton-Raphson Method ............................................................................................................ 2

    1.2. Secant Methods ............................................................................................................................ 4

    Part Two: Numerical Solutions for Multiple Variables ................................................................................. 6

    2.1. Generalized Newton-Raphson Method for Two Variables ........................................................... 6

    2.2. Multi-dimensional case for Newton-Raphson Method ................................................................ 9

    Appendix: Matrix ........................................................................................................................................ 10

  • Sayed-Ahmed, M. Ryerson University Jan. 2013

    2

    Part I: Numerical Solution for Single Variable

    1.1. Newton-Raphson Method

    The Newton-Raphson method (NRM) is powerful numerical method based on the simple idea of linear

    approximation. NRM is usually home in on a root with devastating efficiency. It starts with initial guess,

    where the NRM is usually very good if , and horrible if the guess are not close.

    Question: Find the value of if using Newton-Raphson Method for three iterations? Answer: Start with guess value of The function equation should equal to zero; So the function equation; NRM:

    The first iteration

    then The absolute error, | | | |

    The second iteration

    then The absolute error, | | | |

    The third iteration

    then The absolute error, | | | |

  • Sayed-Ahmed, M. Ryerson University Jan. 2013

    3

    Summary

    Table 1: Newton-Raphson Method iteration results to three decimal places

    Iteration Value of x Absolute error Exact Solution

    1 2.741 9.45%

    2 2.715 0.96% 2.714417617

    3 2.714 0.009%

    Figure 1: High initial solution

    Important notes

    At any time otherwise the process of iteration will not continue

    0

    10

    20

    30

    40

    50

    60

    70

    2.72.82.933.13.23.33.4

    Err

    or,

    %

    Solution

  • Sayed-Ahmed, M. Ryerson University Jan. 2013

    4

    1.2. Secant Methods

    Question: Find the value of if using Secant Method for three iterations, where and ?

    Answer: then

    The first iteration, ( ) The absolute error

    | | | | | | The second iteration, and

    ( ) The absolute error

    | | | | | | The third iteration, and

    ( ) The absolute error

    | | | | | | The fourth iteration, and

    ( ) The absolute error

    | | | | | | The fifth iteration, and

    ( ) The absolute error

    | | | | | |

  • Sayed-Ahmed, M. Ryerson University Jan. 2013

    5

    Summary

    Table 2: Secant Method iteration results to three decimal places

    Iteration Value of x Absolute error Exact Solution

    1 3.353 63.92%

    2 3.059 9.691% 2.714417617

    3 2.906 5.26%

    4 2.823 2.94%

    5 2.7765 1.675%

    Figure 2: High initial solution

    0

    10

    20

    30

    40

    50

    60

    70

    2.72.82.933.13.23.33.4

    Err

    or,

    %

    Solution

  • Sayed-Ahmed, M. Ryerson University Jan. 2013

    6

    Part Two: Numerical Solutions for Multiple Variables

    2.1. Generalized Newton-Raphson Method for Two Variables

    Question

    For acceptable error less than 0.2, find the value of and

    Solution

    Where

    [ ] Use Jacobian

    [ ] [ ] The matrix notation

    [ ]{ } { } [ ]{ } OR

    { } { } [ ] { }

    [ ] [ ] [ ] Iteration;

    The arbitrarily guess [ ] This scalar parameter which is adjusted to either less than 1 or more than 1 (=1 is the

    original Newton Method) to force for convergence.

    [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] Evaluate the function

    [ ] [ ] [ [ ] ]

  • Sayed-Ahmed, M. Ryerson University Jan. 2013

    7

    [ ] [ ] [ = [ ] [ ] ] [ ] [ ] [ ]

    Evaluate the function

    Iteration; [ ] [ ] [ ] [ ]

    Evaluate the function

    ( ) [ ] The iteration stops when results reached to specified tolerance of error | |

    otherwise the process of iteration will continue.

  • Sayed-Ahmed, M. Ryerson University Jan. 2013

    8

    Summary

    Table 3: Generalized Newton-Raphson Method

    Iteration Parameters Value Error, | |

    0 1 1 100% 100%

    1 2.1 1.3 52.38% 23.08%

    2 1.8284 1.2122 14.85% 7.24%

    Where the absolute error

    | | | |

    Figure 3: Graphical depiction of the solution of two simultaneous nonlinear equation

    -6

    -5

    -4

    -3

    -2

    -1

    0

    1

    2

    3

    1 2 3

    So

    luti

    on

    Iteration

    f(x1)

    f(x2)

  • Sayed-Ahmed, M. Ryerson University Jan. 2013

    9

    2.2. Multi-dimensional case for Newton-Raphson Method

    Talyor Series of m functions with n variables:

    where

    = J (Jacobian)

    with m = n

    Set

    Advantages and Disadvantages:

    The method is very expensive - It needs the function evaluation and then the derivative evaluation. If the tangent is parallel or nearly parallel to the x-axis, then the method does not converge. Usually Newton method is expected to converge only near the solution. The advantage of the method is its order of convergence is quadratic. Convergence rate is one of the fastest when it does converges

    .

    Source: (http://epoch.uwaterloo.ca/~ponnu/syde312/open_methods/page3.htm#example)

  • Sayed-Ahmed, M. Ryerson University Jan. 2013

    10

    Appendix: Matrix Inverse of Matrix

    For 2 x 2 matrices

    [ ] the inverse can be found using this formula [ ] [ ]

    Multiplication of Matrix

    for m x n matrix size and for n x p matrix size where for the order of m x p. Where is summed over all values of and the uses the Einsten summation

    conventions.

    Example: Square matrix and column vector

    and The matrix product

    ( )