PROBLEM SET Enz
note that B is obtained by interchanging the first two rows of A . Knowing that determine B-1. 2. Invert the triangular matrices 6. Invert the following matrices with any method 7. Invert the matrix by any method and comment on the reliability of the result. 8. The joint displacements u of the plane truss in Problem 14, Problem Set 2.2, are related to the applied joint forces p by is called the stiffness matrix of the truss. If Eq. a is inverted by multiplying each side by K-1, we obtain u K-1...
Nevilles Method
Newton's method of interpolation involves two steps computation of the coefficients, followed by evaluation of the polynomial. This works well if the interpolation is carried out repeatedly at different values of x using the same polynomial. If only one point is to be interpolated, a method that computes the interpolant in a single step, such as Neville's algorithm, is a better choice. Let Pk x, xi 1, , xi k denote the polynomial of degree k that passes through the k 1 data points x,, yi , xi...
newtonPoly
This module contains the two functions required for interpolation by Newton's method. Given the data point arrays xData and yData, the function coeffts returns the coefficient array a. After the coefficients are found, the interpolant Pn x can be evaluated at any value of x with the function evalPoly. Evaluates Newton's polynomial p at x. The coefficient vector a can be computed by the function 'coeffts'. Computes the coefficients of Newton's polynomial. n len xData - 1 Degree of polynomial p a...
r b Axq
s0 r0 lacking a previous search direction, choose the direction of steepest descent if rk 11 lt e exit loop e is the error tolerance It can be shown that the residual vectors r1, r2, r3, produced by the algorithm are mutually orthogonal, that is, ri r,- 0, i j. Now suppose that we have carried out enough iterations to have computed the whole set of n residual vectors. The residual resulting from the next iteration must be a null vector rn 1 0 , indicating that the solution has been obtained. It...
GaussSeidel Method
The equations Ax b are in scalar notation Extracting the term containing xi from the summation sign yields The last equation suggests the following iterative scheme
gaussSeidel
The function gaussSeidel is an implementation of the Gauss-Seidel method with relaxation. It automatically computes opt from Eq. 2.36 using k 10 and p 1. The user must provide the function iterEqs that computes the improved x from the iterative formulas in Eq. 2.35 - see Example 2.17. The function gaussSeidel returns the solution vector x, the number of iterations carried out, and the value of ffi gt opt used. ''' x,numIter,omega gaussSeidel iterEqs,x,tol 1.0e-9 Gauss-Seidel method for solving...
LUdecomp
This module contains the functions LUdecomp3 and LUsolve3 for the decomposition and solution phases of a tridiagonal matrix. In LUsolve3, the vector y writes over the constant vector b during forward substitution. Similarly, the solution vector x overwrites y in the back substitution process. In other words, b contains the solution upon exit from LUsolve3. LU decomposition of tridiagonal matrix c d e . On output c , d and e are the diagonals of the decomposed matrix. Solves c d e x b , where c...
LUdecomp 1
The function LUdecomp5 decomposes a symmetric, pentadiagonal matrix A of the form A f e d e f . The original vectors d, e, and f are destroyed and replaced by the vectors of the decomposed matrix. After decomposition, the solution of Ax b can be obtained by LUsolve5. During forward substitution, the original b is replaced by y. Similarly, y is written over by x in the back substitution phase, so that b contains the solution vector upon exitfrom LUsolve5. LU decomposition of symmetric...
conjGrad
The function conjGrad shown here implements the conjugate gradient algorithm. The maximum allowable number of iterations is set to n the number of unknowns . Note that conjGrad calls the function Av, which returns the product Av. This function must be supplied by the user see Example 2.18 . We must also supply the starting vector x0 and the constant right-hand-side vector b. The function returns the solution vector x and the number of iterations. ''' x, numIter conjGrad Av,x,b,tol 1.0e-9...
Conjugate Gradient Method
Consider the problem of finding the vector x that minimizes the scalar function where the matrix A is 5ymmetric and po5itive definite. Because f x is minimized when its gradient V f Ax - b is zero, we see that minimization is equivalent to solving Gradient methods accomplish the minimization by iteration, starting with an initial vector x0. Each iterative cycle k computes a refined solution The step length ak is chosen so that xk 1 minimizes xk 1 in the search direction sk. That is, xk 1 must...
Tridiagonal Coefficient Matrix
Consider the solution of Ax b by Doolittle's decomposition, where A is the n x n tridiagonal matrix As the notation implies, we are storing the nonzero elements of A in the vectors The resulting saving of storage can be significant. For example, a 100 x 100 tridiagonal matrix, containing 10,000 elements, can be stored in only 99 100 99 298 locations, which represents a compression ratio of about 33 1. Let us now apply LU decomposition to the coefficient matrix. We reduce row k by getting rid of...
Problem Set
1. By evaluating the determinant, classify the following matrices as singular, ill conditioned, or well conditioned. 2. Given the LU decomposition A LU, determine A and A . 3. Utilize the results of LU decomposition to solve Ax b, where bT 1 2J. 4. Use Gauss elimination to solve the equations Ax b, where 5. Solve the equations AX B by Gauss elimination, where 6. Solve the equations Ax b by Gauss elimination, where Hint reorder the equations before solving. 7. Find L and U so that using a...
[Uy
are solved by back substitution. This yields x1 7 - 4x2 - x3 7 - 4 1 - -2 5 Compute Choleski's decomposition of the matrix Solution First, we note that A is symmetric. Therefore, Choleski's decomposition is applicable, provided that the matrix is also positive definite. An a priori test for positive definiteness is not needed, since the decomposition algorithm contains its own test if the square root of a negative number is encountered, the matrix is not positive definite and the decomposition...