MATLAB Mathematics - SERC - Index of
MATLAB Mathematics - SERC - Index of MATLAB Mathematics - SERC - Index of
1 Matrices and Linear Algebra If A and B are square and the same size, then X = A\B is also that size: B = magic(3); X = A\B X = 19 -3 -1 -17 4 13 6 0 -6 It can be confirmed that A*X is exactly equal to B. Both of these examples have exact, integer solutions. This is because the coefficient matrix was chosen to be pascal(3), which has a determinant equal to one. A later section considers the effects of roundoff error inherent in more realistic computations. Singular Coefficient Matrix A square matrix A is singular if it does not have linearly independent columns. If A is singular, the solution to AX = B either does not exist, or is not unique. The backslash operator, A\B, issues a warning if A is nearly singular and raises an error condition if it detects exact singularity. If A is singular and AX = b has a solution, you can find a particular solution that is not unique, by typing P = pinv(A)*b P is a pseudoinverse of A. If AX = b does not have an exact solution, pinv(A) returns a least-squares solution. For example, A = [ 1 3 7 -1 4 4 1 10 18 ] is singular, as you can verify by typing det(A) ans = 0 1-16
Solving Linear Systems of Equations Note For information about using pinv to solve systems with rectangular coefficient matrices, see “Pseudoinverses” on page 1-23. Exact Solutions. For b =[5;2;12], the equation AX = b has an exact solution, given by pinv(A)*b ans = 0.3850 -0.1103 0.7066 You can verify that pinv(A)*b is an exact solution by typing A*pinv(A)*b ans = 5.0000 2.0000 12.0000 Least Squares Solutions. On the other hand, if b = [3;6;0], then AX = b does not have an exact solution. In this case, pinv(A)*b returns a least squares solution. If you type A*pinv(A)*b ans = -1.0000 4.0000 2.0000 you do not get back the original vector b. 1-17
- Page 1 and 2: MATLAB® The Language of Technical
- Page 3: Revision History June 2004 First pr
- Page 6 and 7: 2 Polynomials and Interpolation Pol
- Page 8 and 9: Introduction to Initial Value ODE P
- Page 10 and 11: vi Contents
- Page 12 and 13: 1 Matrices and Linear Algebra Funct
- Page 14 and 15: 1 Matrices and Linear Algebra Matri
- Page 16 and 17: 1 Matrices and Linear Algebra Addin
- Page 18 and 19: 1 Matrices and Linear Algebra If x
- Page 20 and 21: 1 Matrices and Linear Algebra y = v
- Page 22 and 23: 1 Matrices and Linear Algebra Vecto
- Page 24 and 25: 1 Matrices and Linear Algebra backs
- Page 28 and 29: 1 Matrices and Linear Algebra You c
- Page 30 and 31: 1 Matrices and Linear Algebra 0.9 0
- Page 32 and 33: 1 Matrices and Linear Algebra Inver
- Page 34 and 35: 1 Matrices and Linear Algebra X = p
- Page 36 and 37: 1 Matrices and Linear Algebra There
- Page 38 and 39: 1 Matrices and Linear Algebra The e
- Page 40 and 41: 1 Matrices and Linear Algebra The L
- Page 42 and 43: 1 Matrices and Linear Algebra In co
- Page 44 and 45: 1 Matrices and Linear Algebra Matri
- Page 46 and 47: 1 Matrices and Linear Algebra compu
- Page 48 and 49: 1 Matrices and Linear Algebra Eigen
- Page 50 and 51: 1 Matrices and Linear Algebra produ
- Page 52 and 53: 1 Matrices and Linear Algebra Singu
- Page 54 and 55: 1 Matrices and Linear Algebra 1-44
- Page 56 and 57: 2 Polynomials and Interpolation Pol
- Page 58 and 59: 2 Polynomials and Interpolation pol
- Page 60 and 61: 2 Polynomials and Interpolation Cal
- Page 62 and 63: 2 Polynomials and Interpolation whe
- Page 64 and 65: 2 Polynomials and Interpolation Int
- Page 66 and 67: 2 Polynomials and Interpolation int
- Page 68 and 69: 2 Polynomials and Interpolation 2 G
- Page 70 and 71: 2 Polynomials and Interpolation Int
- Page 72 and 73: 2 Polynomials and Interpolation for
- Page 74 and 75: 2 Polynomials and Interpolation Con
Solving Linear Systems <strong>of</strong> Equations<br />
Note For information about using pinv to solve systems with rectangular<br />
coefficient matrices, see “Pseudoinverses” on page 1-23.<br />
Exact Solutions. For b =[5;2;12], the equation AX = b has an exact solution,<br />
given by<br />
pinv(A)*b<br />
ans =<br />
0.3850<br />
-0.1103<br />
0.7066<br />
You can verify that pinv(A)*b is an exact solution by typing<br />
A*pinv(A)*b<br />
ans =<br />
5.0000<br />
2.0000<br />
12.0000<br />
Least Squares Solutions. On the other hand, if b = [3;6;0], then AX = b does not<br />
have an exact solution. In this case, pinv(A)*b returns a least squares solution.<br />
If you type<br />
A*pinv(A)*b<br />
ans =<br />
-1.0000<br />
4.0000<br />
2.0000<br />
you do not get back the original vector b.<br />
1-17