* ======================================================================= * File: matrix 002.SPS . * Date: 24-Oct-2003 . * Author: Bruce Weaver, weaverb@mcmaster.ca . * Notes: Use matrix language to solve system of simultaneous linear equations . * ======================================================================= . * The following example is taken from Appendix A of "Mathematical Statistics * with Applications" (2nd Ed.) by Mendenhll, Scheaffer, & Wackerly ISBN 0-8710-410-3). * The 3 equations in the system of equations are: * 2(v1) + v3 = 4. * v1 - v2 + 2(v3) = 2. * v1 = 1. * Matrix A is used to represent the coefficients by which v1, v2, and v3 are multiplied. * Matrix G is used to hold the results of the 3 equations (i.e., 4, 2, and 1). matrix. compute a = {2, 0, 1; 1, -1, 2; 1, 0, 0}. compute g = {4; 2; 1}. compute v = inv(a)*g. print a /title = 'Matrix A'. print inv(a) /title = 'Inverse of A'. print v /title = 'Matrix V'. print /title = 'So v1 = 1, v2 = 3, and v3 = 2.'. end matrix. * ======================================================================= .