04.05.2015 Views

3.7.8 Solving Linear Systems

3.7.8 Solving Linear Systems

3.7.8 Solving Linear Systems

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

532 3. Advanced Mathematics in Mathematica<br />

Particularly when you have large, sparse, matrices, <strong>Linear</strong>Solve is the most<br />

ecient method to use.<br />

If you have a square matrix m with a nonzero determinant, then you can always<br />

nd a unique solution to the matrix equation m:x = b for any b. If, however,<br />

the matrix m has determinant zero, then there can be no vector x which satises<br />

m:x = b for a particular b. This situation corresponds to the case in which the<br />

linear equations embodied in m are not independent.<br />

When m has determinant zero, it is nevertheless always possible to nd vectors<br />

x that satisfy m:x = 0. The set of vectors x satisfying this equation form the<br />

null space or kernel of the matrix m. Any ofthevectors can be expressed as a<br />

linear combination of a particular set of basis vectors, which can be obtained using<br />

NullSpace[m].<br />

Here is a simple matrix, corresponding to<br />

two identical linear equations.<br />

In[6]:= m = {{1, 2}, {1, 2}}<br />

Out[6]= {{1, 2}, {1, 2}}<br />

The matrix has determinant zero. In[7]:= Det[ m ]<br />

Out[7]= 0<br />

<strong>Linear</strong>Solve cannot nd a solution to the<br />

equation m:x = b in this case.<br />

In[8]:= <strong>Linear</strong>Solve[m, {a, b}]<br />

<strong>Linear</strong>Solve::nsl:<br />

<strong>Linear</strong> equation encountered which has no solution.<br />

Out[8]= <strong>Linear</strong>Solve[{{1, 2}, {1, 2}}, {a, b}]<br />

There is a single basis vector for the null<br />

space of m.<br />

In[9]:= NullSpace[ m]<br />

Out[9]= {{-2, 1}}<br />

Multiplying the basis vector for the null<br />

space by m gives the zero vector.<br />

Here is a simple symbolic matrix with<br />

determinant zero.<br />

The basis for the null space of m contains<br />

two vectors. Any linear combination of<br />

these vectors gives zero when multiplied by<br />

m.<br />

In[10]:= m . %[[1]]<br />

Out[10]= {0, 0}<br />

In[11]:= m = {{a, b, c}, {2 a, 2 b, 2 c}, {3 a, 3 b, 3 c}}<br />

Out[11]= {{a, b, c}, {2 a, 2 b, 2 c}, {3 a, 3 b, 3 c}}<br />

In[12]:= NullSpace[ m ]<br />

c<br />

b<br />

Out[12]= {{-(-), 0, 1}, {-(-), 1, 0}}<br />

a<br />

a<br />

An important feature of <strong>Linear</strong>Solve and NullSpace is that they work with<br />

rectangular, aswell as square, matrices.<br />

Web sample page from The Mathematica Book, First Edition, by Stephen Wolfram, published by Addison-Wesley Publishing<br />

Company (hardcover ISBN 0-201-19334-5; softcover ISBN 0-201-19330-2). To order Mathematica or this book contact Wolfram<br />

Research: info@wolfram.com; http://www.wolfram.com/; 1-800-441-6284.<br />

c 1988 Wolfram Research, Inc. Permission is hereby granted for web users to make one paper copy of this page for their<br />

personal use. Further reproduction, or any copying of machine-readable files (including this one) to any server computer, is strictly<br />

prohibited.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!