Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Alternative LU Factorization Method

To get the matrix U, just use row operations until an upper


triangular matrix is formed.
To get L, start with the identity matrix and use the following
rules:
Any row operations that involves adding a multiple of
one row to another, for example, Ri+ kRj, put the value
k in the ith row, jth column of the identity matrix.
Any row operations that involves getting a leading entry
on the main diagonal, for example, kRi, put the value 1/k
in the position of the identity matrix where the leading
one occurs.
CE 26 Lecture 9 Solutions to Set of Linear Equations

Example:

CE 26 Lecture 9 Solutions to Set of Linear Equations

Example:

CE 26 Lecture 9 Solutions to Set of Linear Equations

Example:

CE 26 Lecture 9 Solutions to Set of Linear Equations

Example:

CE 26 Lecture 9 Solutions to Set of Linear Equations

Notes:
1. Row swapping is not allowed. If you swap rows, then
an LU decomposition will not exist.
2. It is not necessary to get leading ones on the main
diagonal when using Gaussian Elimination. In some
matrices, however, it is recommended to get leading
ones to use nice row operations.
3. When using Gaussian Elimination to find such an LU
decomposition, record all row operations involved. The
row operations will help find the lower triangular matrix
using the identity matrix.
4. An LU decomposition is not unique. There can be more
than one such LU decomposition for a matrix.
CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Analytical and Computational Methods in Civil Engineering I


2nd Semester A.Y. 2014-2015
Lecture 10 Solutions to Nonlinear Equations
in One Variable
Elvin B. Cruz
Lecturer II
Institute of Civil Engineering

Overview:
I.

Introduction

II. Numerical Methods


Fixed-Point Iteration
Newtons Method
Secant Method

III. Bracketing (Inclusion) Methods

Bisection Method

Pegasus Method

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Introduction
x is a zero (or root) of a function f(x) if
f(x) = 0
In solving for the roots of nonlinear equations, some
formula were already established earlier (quadratic
equation, cubic equation, etc.)
However, the roots of most nonlinear equations may also
be obtained conveniently using numerical algorithms.

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Introduction
General Steps in Solving Nonlinear Equations iteratively:

Commonly-used Convergence Criteria:


1. |f(xk)|max< : - tolerance
2. maximum number of iterations
3. |xk - xk-1 |max< : - tolerance

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Fixed Point Iteration


We need to find the solution for the nonlinear function
f(x) =0
We can transform the above equation algebraically into
the form
x=g(x)
We choose an xo and compute x1 = g(xo), x2 = g(x1) and
generally,
xn+1= g(xn)

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Fixed Point Iteration Example


Solve for the roots of the function
f(x) = x2-3x+1
Using the quadratic formula, we know that the
solutions are
R1=2.618034 and R2=0.381966
Rearranging f(x) to isolate an x to the left side of
the equation will yield the following:
1

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Fixed Point Iteration Example

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Newtons Method (Newton-Raphson)

Each iteration requires an evaluation of f and f


It is assumed that f will never be equal to zero for all
iterations
May not work if initial value of x is very far from the solution
It does not necessarily converge to the solution closest to the
starting point

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Newtons Method Example

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Newtons Method Example

Solve for the roots of the


function
f(x) = x2-3x+1

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Newtons Method Example

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Secant Method
In cases when the computation of f is computationally expensive,
f is replaced (approximated) by the expression

hence, the formula given by the secant method is

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Secant Method

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Secant Method Example

Solve for the roots of the


function
f(x) = x2-3x+1

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Secant Method Example

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Bisection Method
If f(l)*f(u)<0, and f is a continuous function between
l and u, then we can find at least one root by repeated
interval bisection

Algorithm:
While |u-l|< tolerance or N< max no. of iterations:
1. Xk = (l+u)/2
2. Evaluate f(Xk)
3. If f(Xk )=0, a solution is found
If f(l)*f(x)<0; u=Xk, else

l=Xk

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Bisection Method

Solve for the roots of the


function
f(x) = x2-3x+1

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Pegasus Method
If f is continuous on the closed interval [a,b] and if
f(a)f(b)<0, then f has at least one zero in [a,b].
The Pegasus method calculates a root of the equation by
repeated minimization of the root inclusion interval.
It always converges if initially f(a)f(b)<0.

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Pegasus Method

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Pegasus Method

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

Pegasus Method Example

CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

End of Presentation
It's hard enough to find an error in your code when you're
looking for it; it's even harder when you've assumed your
code is error-free.
- Steve McConnel
Reference :
Umali, Jun. ES 21 First Exam Notes. 2000
CE 26 Lecture 10 Solutions to Nonlinear Equations in One Variable

You might also like