Title: Lecture 6 Single Variable Problems
1Lecture 6 - Single Variable Problems Systems
of Equations
2Lectures Goals
- Introduction of Solving Equations of 1 Variable
- Newtons Method
- Mullers Method
- Fixed Point Iteration
3Lectures Goals
- Introduction to Systems of Equations
- Discuss how to solve systems
- Gaussian Elimination
- Gaussian Elimination with Pivoting
- Tridiagonal Solver
- Problems with the technique
- Examples
4Newtons 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
5Newtons 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)
6Newtons 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.
7Mullers Method
- Mullers method is an interpolation method that
uses quadratic interpolation rather than linear.
- A second degree polynomial is used to fit three
points in the vicinity of the root.
8Mullers Method
- Do while x2 - x1 gt tolerance value 1
- or f(x3) gt
tolerance value 2 - c1 (f(x2)-f(x1))/(x2 - x1)
- c2 (f(x3)-f(x2))/(x3 - x2)
- d1 (c2-c1)/(x3 - x1)
- s c2 d1 (x3 - x2)
- x4 x3 - 2f(x3)/
- s sign(s)sqrt( s2
-4f(x3)d1 - Set x1 x2
- Set x2 x3
- Set x3 x4
- END loop
9Mullers Method
This method uses a Newton form of an
interpolating polynomials.
10Example Problem
- f(x) x5 x3 4x2 - 3x - 2
- The roots are around (-2,-1),(-1,0) and (0,1)
- Look at (1,0) choice three points, 1.5, 0.5, 0.25
11Mullers Method
- x1 f(x1) x2 f(x2) x3
f(x3) c1 c2 d1
s1 x4 - 1.5000 13.4688 0.2500 -2.4834 0.5000 -2.3438
12.7617 0.5586 12.2031 3.6094 0.8145 - 0.2500 -2.4834 0.5000 -2.3438 0.8145 -0.8900
0.5586 4.6205 7.1938 6.8839 0.9300 - 0.5000 -2.3438 0.8145 -0.8900 0.9300 0.1698
4.6205 9.1854 10.6157 10.4101 0.9134 - 0.8145 -0.8900 0.9300 0.1698 0.9134 -0.0049
9.1854 10.5319 13.6309 10.3057 0.9139 - etc. etc. etc. etc. etc. etc.
etc. etc. etc. etc. etc.
12Fixed-Point Iteration Method
- The method uses an iterative scheme to find the
root. - The equation is rewritten to obtain new equation
in terms of x. - f(x) a3 x3 a2 x2 a1 x a0 0
- g(x) - ( a3/a1 ) x3 (a2 /a1) x2 (a0 /a1)
13Fixed-Point Iteration Method
- Problem is that the method only converge for a
small range. - g(x) lt 0.5
14Fixed-Point Iteration Method
- Rewrite f(x) -gt g(x)
- IF g(x) lt 0.5
- Do while xk1 - xk gt tolerance
- value
- xk1 g(xk)
- k k1
- END loop
- ENDIF
15Fixed Point Iteration
- From the book
- f(x) 5x3 -10x 3
- g(x) 0.5x3 0.3
- g(x) 1.5x2
- for 0.1ltxlt0.5
- g(x) lt 0.5
16Fixed Point Iteration Method
- The program demoFixedPoint test the convergence
of the point. - The program is limited to small range of values
- demoFixed(0.1,0.0,0.5)
17Systems of Equations
18Simple Linear Oscillator
- The spring-mass system can
- be described with a series of
- equations to model the
- physical behavior. The
- displacement of the masses
- are given as u, k represents
- the stiffness of the springs
- and M represents the mass of
- each member.
19Simple Linear Oscillator
- The free body diagrams of
- components of the spring
- mass system can be
- represented. Using the
- equilibrium equations, the
- static behavior of the model
- can be determined.
20Simple Oscillator
- The equations can be written from the free body
diagrams. - The matrix and vectors can be obtained from the
equations.
21Simple 3-D frame
- A force is applied to the apex
- of a simple 3-D frame. We
- would like to determine the
- forces in each of the
- members of the frame. With
- a FBD, the static equilibrium
- equations can be derived.
22Simple 3-D Frame
- The set of 3 equilibrium equations and 3 unknowns
can be - obtained from the FBD of the frame. Place the
equations in a - matrix format.
23Simple 3-D Frame
- The frame is represented as a matrix with 3
unknowns. The - forces are normalized with respect to the applied
force, F.
24Basic Principles
- The general description of a set of linear
equations in the matrix form - Ax b
- A ( m x n ) matrix
- x ( n x 1 ) vector
- b (m x 1 ) vector
25Description of the linear set of equations
- Write the equations in natural form
- Identify unknowns and order them
- Isolate unknowns
- Write equations in matrix form
26Types of Matrix Formulation
- ( m x n ) Array
- If m n The solution of Ax b with
- n unknowns and m equations
- If m gt n The system is overdetermined system
- (Least Square Problems)
- If m lt n The system is underdetermined system
- (Optimization Problems)
27Matrix Representation
28Consistency
- Ax b
- The problem is consistent, if a solution exists
for the problem. - The problem is inconsistent, if there is no
solution for the problem.
29Rank of Matrix
Rank of a matrix is the number of linearly
independent column vectors in the matrix. For n
x n matrix, A
- If rank(A) n and is consistent, A has an unique
solution exists - If rank(A) n and is inconsistent, A has no
solution exists - If rank(A) lt n and system is consistent, A has an
infinite number of solutions
30Matrix
- For an n x n system, rank(A) n automatically
guarantees - that the system is consistent.
- The columns of A are linearly independent
- The rows of A are linearly independent
- rank(A) n
- det(A) 0
- A-1 exists
- The solution to Ax b exist and is unique.
31Matrix Definition
- Consider
- y -2.0 x 6
- y 0.5 x 1
- 2 unknowns x , y and
- rank is 2
- Consider
- y -2 x 6
- y -2 x 5
- 2 unknowns x , y and rank is 1 and is
inconsistent -
32Gaussian Elimination
- Gaussian elimination is a fundamental
- procedure for solving linear sets of
- equation general it is applied to a square
- matrix.
33Gaussian Elimination
- There are two phases to the solving technique
- Elimination --- use row operations to convert the
matrix into an upper diagonal matrix. (The
elimination phase, which takes the the most
effort and most susceptible to corruption by
round off) - Back substitution -- Solve x using a back
substitution.
34Gaussian Elimination Algorithm
- Ax b
- Augment the n x n coefficient matrix with the
vector of right hand sides to form a n x (n1) - Interchange rows if necessary to make the value
a11 with the largest magnitude of any coefficient
in the first row - Create zero in 2nd through nth row in first row
by subtracting ai1 / a11 times first row from ith
row
35Gaussian Elimination Algorithm
- Repeat (2) (3) for second through the (n-1)th
rows, putting the largest magnitude coefficient
in the diagonal by interchanging rows (consider
only row j to n ) and then subtract times the
jth row from the ith row so as to create zeros in
all positions of jth column below the diagonal at
conclusion of this step the system is upper
triangular - Solve for n from nth equation xn an,n1 / ann
- Solve for xn-1 , xn-2 , ...x1 from the (n-1)th
through the first xi (ai,n1 - Sji1,n aj1
xj ) / aii
36Example 1
37Example 2
- -3X1 2X2 - X3 -1
- 6X1 - 6X2 7X3 -7
- 3X1 - 4X2 4X3 -6
38Computer Program
- The program GEdemo(A,b) does the Gaussian
- elimination for a square matrix (nxn). It does
- not do any pivoting and works for only one
- b vector.
39Test the Program
- Example 1
- Example 2
- New Matrix
- 2X1 4X2 - 2 X3 - 2 X4 - 4
- 1X1 2X2 4X3 - 3 X4 5
- - 3X1 - 3X2 8X3 - 2X4 7
- - X1 X2 6X3 - 3X4
7
40Problem with Gaussian Elimination
- The problem can occur when a zero appears in the
diagonal and makes a simple Gaussian elimination
impossible. - Pivoting changes the matrix so that it will
become diagonally dominate and reduce the
round-off and truncation errors in the solving
the matrix.
41Computer Program
- GEPivotdemo(A,b) is a program, which will do a
Gaussian elimination on matrix A with pivoting
technique to make matrix diagonally dominate. - The program is modification to handle a single
value of b
42Question?
- How would you modify the programs to handle
multiple inputs? - What is diagonal matrix, upper triangular matrix,
and lower triangular matrix? - Can you do a column exchange and how would you
handle the problem if it works?
43Question?
- What happens with the following example?
- 0.0001X1 0.5 X2 0.5
- 0.4000X1 - 0.3 X2 0.1
- What happens is the second equation becomes
0.4000X1 - 2000 X2 -2000
44Gaussian Elimination
- If the diagonal is not dominate the problem can
have round off error and truncation errors. - The scaling will result in problems
45Summary
- Newtons - need to know f(x) and f(x) and an
initial guess. - Mullers method -need to know the f(x) and 3
values. - Fixed Point method looking at a point a iterate.
46Summary
- Matrix properties consistency, rank, diagonally
dominate, upper triangular, lower triangular - Gaussian elimination is a method to solve for a
set of linear equations - Non-pivoting problems
- Setting up the system of linear equations to
avoid problems
47Homework
- Check the Homework webpage