Download presentation
Presentation is loading. Please wait.
Published byRosamond Hubbard Modified over 9 years ago
1
Lecture 6 - Single Variable Problems & Systems of Equations CVEN 302 June 14, 2002
2
Lecture’s Goals Introduction of Solving Equations of 1 Variable –Newton’s Method –Muller’s Method –Fixed Point Iteration
3
Lecture’s Goals Introduction to Systems of Equations Discuss how to solve systems –Gaussian Elimination –Gaussian Elimination with Pivoting –Tridiagonal Solver Problems with the technique Examples
4
Newton’s Method Do while |x 2 - x 1 | >= tolerance value 1 or |f(x 2 )|>= tolerance value 2 or f’(x 1 ) ~= 0 Set x 2 = x 1 - f(x 1 )/f’(x 1 ) Set x 1 = x 2 ; END loop
5
Newton’s Method Same example problem f(x) = x 5 + x 3 + 4x 2 - 3x - 2 and f’(x) = 5x 4 + 3x 2 + 8x - 3 roots are between (-1.7,-1.3), (-1,0), & (0.5,1.5)
6
Newton’s Method x 1 f(x 1 ) f’(x 1 ) f(x 1 )/f’(x 1 ) x 2 -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.
7
Muller’s Method Muller’s 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.
8
Muller’s Method Do while |x 2 - x 1 | >= tolerance value 1 or |f(x 3 )| >= tolerance value 2 c1 = (f(x 2 )-f(x 1 ))/(x 2 - x 1 ) c2 = (f(x 3 )-f(x 2 ))/(x 3 - x 2 ) d1 = (c2-c1)/(x 3 - x 1 ) s = c2 + d1 *(x 3 - x 2 ) x 4 = x 3 - 2*f(x 3 )/ [s + sign(s)*sqrt( s^2 -4*f(x 3 )*d1] Set x 1 = x 2 ; Set x 2 = x 3 ; Set x 3 = x 4 ; END loop
9
Muller’s Method This method uses a Newton form of an interpolating polynomials.
10
Example Problem f(x) = x 5 + x 3 + 4x 2 - 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
11
Muller’s Method x 1 f(x 1 ) x 2 f(x 2 ) x 3 f(x 3 ) c 1 c 2 d 1 s 1 x 4 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.
12
Fixed-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) = a 3 x 3 + a 2 x 2 + a 1 x + a 0 = 0 g(x) = - [( a 3 /a 1 ) x 3 + (a 2 /a 1 ) x 2 + (a 0 /a 1 ) ]
13
Fixed-Point Iteration Method Problem is that the method only converge for a small range. | g’(x) | < 0.5
14
Fixed-Point Iteration Method Rewrite f(x) -> g(x) IF | g’(x) |< 0.5 Do while |x k+1 - x k | >= tolerance value x k+1 = g(x k ); k = k+1; END loop ENDIF
15
Fixed Point Iteration From the book: f(x) = 5x 3 -10x + 3 g(x) = 0.5x 3 + 0.3 g’(x) = 1.5x 2 for 0.1<x<0.5 | g’(x)| < 0.5
16
Fixed 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)
17
Systems of Equations
18
Simple 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.
19
Simple 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.
20
Simple Oscillator The equations can be written from the free body diagrams. The matrix and vectors can be obtained from the equations.
21
Simple 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.
22
Simple 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.
23
Simple 3-D Frame The frame is represented as a matrix with 3 unknowns. The forces are normalized with respect to the applied force, F.
24
Basic Principles The general description of a set of linear equations in the matrix form: [A]{x} = {b} –[A] ( m x n ) matrix –{x} ( n x 1 ) vector –{b} (m x 1 ) vector
25
Description of the linear set of equations Write the equations in natural form Identify unknowns and order them Isolate unknowns Write equations in matrix form
26
Types of Matrix Formulation ( m x n ) Array If m = n The solution of [A]{x} ={b} with n unknowns and m equations If m > n The system is overdetermined system (Least Square Problems) If m < n The system is underdetermined system (Optimization Problems)
27
Matrix Representation
28
Consistency [A]{x} = {b} The problem is consistent, if a solution exists for the problem. The problem is inconsistent, if there is no solution for the problem.
29
Rank of Matrix 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) < n and system is consistent, A has an infinite number of solutions Rank of a matrix is the number of linearly independent column vectors in the matrix. For n x n matrix, A:
30
Matrix 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 [A]{x} ={b} exist and is unique.
31
Matrix 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
32
Gaussian Elimination Gaussian elimination is a fundamental procedure for solving “linear” sets of equation general it is applied to a square matrix.
33
Gaussian 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.
34
Gaussian Elimination Algorithm [A]{x} ={b} Augment the n x n coefficient matrix with the vector of right hand sides to form a n x (n+1) Interchange rows if necessary to make the value a 11 with the largest magnitude of any coefficient in the first row Create zero in 2 nd through n th row in first row by subtracting a i1 / a 11 times first row from i th row
35
Gaussian 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 j th row from the i th row so as to create zeros in all positions of j th column below the diagonal at conclusion of this step the system is upper triangular Solve for n from n th equation x n = a n,n+1 / a nn Solve for x n-1, x n-2,...x 1 from the (n-1) th through the first x i =(a i,n+1 - j =i+1,n a j1 x j ) / a ii
36
Example 1 X 1 + 3X 2 = 5 2X 1 + 4X 2 = 6
37
Example 2 -3X 1 + 2X 2 - X 3 = -1 6X 1 - 6X 2 + 7X 3 = -7 3X 1 - 4X 2 + 4X 3 = -6
38
Computer 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.
39
Test the Program Example 1 Example 2 New Matrix 2X 1 + 4X 2 - 2 X 3 - 2 X 4 = - 4 1X 1 + 2X 2 + 4X 3 - 3 X 4 = 5 - 3X 1 - 3X 2 + 8X 3 - 2X 4 = 7 - X 1 + X 2 + 6X 3 - 3X 4 = 7
40
Problem 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.
41
Computer 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}
42
Question? 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?
43
Question? What happens with the following example? 0.0001X 1 + 0.5 X 2 = 0.5 0.4000X 1 - 0.3 X 2 = 0.1 What happens is the second equation becomes: 0.4000X 1 - 2000 X 2 = -2000
44
Gaussian Elimination If the diagonal is not dominate the problem can have round off error and truncation errors. The scaling will result in problems
45
Summary Newton’s - need to know f(x) and f’(x) and an initial guess. Muller’s method -need to know the f(x) and 3 values. Fixed Point method looking at a point a iterate.
46
Summary 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
47
Homework Check the Homework webpage
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.