[SOLVED] CS Forward Error, Backward Error, Condition Number and Numerical Linear Algebr

$25

File Name: CS_Forward_Error,_Backward_Error,_Condition_Number_and_Numerical_Linear_Algebr.zip
File Size: 734.76 KB

5/5 - (1 vote)

Forward Error, Backward Error, Condition Number and Numerical Linear Algebra
In this lab you will be exploring forward and backward error and condition number. You will also be exploring numerical linear algebra commands for using matrices in Matlab.
First we suggest that you make sure you do the exercises
1.3 /1ab, 3ab Computer Problems / 1, 5

Copyright By Assignmentchef assignmentchef

To define a matrix in Matlab we use square brackets and inside the brackets we place each element of a row separated by commas or spaces (commas recommended) and each row separated by a semi-colon. For example, the matrix:
can be defined in Matlab using
A=12 0 7 (1)
0 4 4 0 3 3
A = [9, 0, 26; 12, 0, -7; 0, 4, 4; 0, -3, -3];
To pick out the element in the i-th row and j-th column we use normal parentheses (curved brackets) and the indices separated by a comma. For example
should give you back the element in the 2nd row and 3rd column, or -7 in this case (try it). You can also pull out parts of a matrix by using a sequence of numbers. For example,
extracts the second column, rows two through 4 (try it). If you give the colon by itself, you will extract the entire row or column, for example
extracts the entire 2nd row (try it). For more examples and a video demonstration try looking at:
https://www.mathworks.com/videos/row-and-column-indexing-97492.html
Some other useful commands are ways to find out the size of a matrix or vector. The Matlab command
[n, m] = size(A)

gives us the row and column dimensions of the matrix A. In Matlab, all objects are matrices, even if they print like scalars or vectors. Thus in Matlab is pi=3.14159 , but even so, size(pi)=[1,1], showing that it is stored as a 1 O 1 matrix. Similarly, a row vector is defined by [1,2,3,4] and has size [1, 4], while a column vector is defined by [1; 2; 3; 4] and has size [4, 1].
Matrices can also be constructed by putting blocks together (partitioned matrices). Given
u=[1,2,3,4]; v=[5,6,7,8]; w=[0,-1,-2,-3];
see what happens when you enter
A1=[u,v,w]; A2=[u;v;w]; A3=[u, v, w];
A very important, command is norm. In this lab, you will be comparing very large vectors and matrices. If you have two vectors with 7000 entries, you do not, do not, and again do not print all 7000 entries to compare them. You take the norm.
The Hilbert MONSTER: Execute the commands for Texts Example 2.12 concerning n n Hilbert matrices H for n = 6 and 10. Use Matlabs most powerful solver to solve Hx = b where b = H[1, , 1]T which has the obvious exact solution x = [1, , 1]T . You should also find the relative forward error and relative backward error and compare their ratio to the condition number.
Generate the 6 6 and find its condition number in the norm: n=6; H = hilb(n)
cond(H,inf)
The condition number is huge (approximately of order 10p and indicates approximately that p digits will be lost in the approximate solution. What is p for this value of n? Now check the approximate solution, to see how many digits were lost in the computation:
b=H*ones(n,1);
xa=H $texttt{textbackslash}$ b
Note that Hb is Matlabs quirky way of writing H1 b, that is represents a (backwards) division. Check the relative forward error:
norm(xa ones(n,1), Inf)/norm(ones(n,1), Inf)
and also compute the relative backward error. Now repeat these commands for n = 10. How big does n have to be for the to destroy all digits of accuracy even the for the best solvers?

Translate the following equations into matrix form, Ax = b:
21 x2 +33 +44 = 9
x123+74 = 11 (2)
31 32 +x3 +54 = 8 21 +x2 +43 +44 = 10
Find the PA=LU decomposition of A using Matlabs lu command
[L, U, P] = lu(A)
Also try using the backslash operator, by finding the inverse of the matrix with the inv function. You can build bigger matrices by using the random matrix command
You might try also problems from the AssignedProblems list: 2.3 /1ab, 3a, 5ae, 7 Computer Problems / 1ab, 3, 5

CS: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS Forward Error, Backward Error, Condition Number and Numerical Linear Algebr
$25