# Linear Algebra/Topic: Computer Algebra Systems/Solutions
## Solutions

Answers for this Topic use Maple as the computer algebra system. In particular, all of these were tested on Maple V running under MS-DOS NT version 4.0. (On all of them, the preliminary command to load the linear algebra package along with Maple's responses to the Enter key, have been omitted.) Other systems have similar commands.
Other answers will be added for Wolfram Mathematica 13.0
{{TextBox|1=

### Problem 1

Use the computer to solve the two problems that opened this chapter.
* This is the Statics problem.
    ${\begin{array}{rl}40h+15c&=100\\25c&=50+50h\end{array}}$
* This is the Chemistry problem.
    ${\begin{array}{rl}7h&=7j\\8h+1i&=5j+2k\\1i&=3j\\3i&=6j+1k\end{array}}$

### Answer

* The commands > A:=array( [[40,15], [-50,25]] ); > u:=array([100,50]); > linsolve(A,u); yield the answer $[1,4]$. Mathematica answereqns = {40 h + 15 c == 100, 25 c == 50 + 50 h}; {b, m} = CoefficientArrays[eqns, {c, h}] LinearSolve[m, -b] {c, h} /. Solve[eqns, {c, h}] returns a vector of {1,4} for {c,h}.
* Here there is a free variable: > A:=array( [[7,0,-7,0], [8,1,-5,2], [0,1,-3,0], [0,3,-6,-1]] ); > u:=array([0,0,0,0]); > linsolve(A,u); prompts the reply $[\_t_{1},3\_t_{1},\_t_{1},3\_t_{1}]$. Mathematica code:eqns = {7 h == 7 j, 8 h + i == 5 j + 2 k, 1 i == 3 j, 3 i == 6 j + 1 k}; {b, m} = CoefficientArrays[eqns, {h, i, j, k}] LinearSolve[m, -b] {h, i, j, k} /. Solve[eqns, {h, i, j, k}] returns {0,0,0,0} for LinearSolve and $\{\{h,3h,3h,3h\}\}$ for the last line
}} {{TextBox|1=

### Problem 2

Use the computer to solve these systems from the first subsection, or conclude "many solutions" or "no solutions".
* ${\begin{array}{*{2}{rc}r}2x&+&2y&=&5\\x&-&4y&=&0\end{array}}$
* ${\begin{array}{*{2}{rc}r}-x&+&y&=&1\\x&+&y&=&2\end{array}}$
* ${\begin{array}{*{3}{rc}r}x&-&3y&+&z&=&1\\x&+&y&+&2z&=&14\end{array}}$
* ${\begin{array}{*{2}{rc}r}-x&-&y&=&1\\-3x&-&3y&=&2\end{array}}$
* ${\begin{array}{*{3}{rc}r}&&4y&+&z&=&20\\2x&-&2y&+&z&=&0\\x&&&+&z&=&5\\x&+&y&-&z&=&10\end{array}}$
* ${\begin{array}{*{4}{rc}r}2x&&&+&z&+&w&=&5\\&&y&&&-&w&=&-1\\3x&&&-&z&-&w&=&0\\4x&+&y&+&2z&+&w&=&9\end{array}}$

### Maple Answer

These are easy to type in. For instance, the first
> A:=array( [[2,2], [1,-4]] ); > u:=array([5,0]); > linsolve(A,u);
gives the expected answer of $[2,1/2]$. The others are entered similarly.
* The answer is $x=2$ and $y=1/2$.
* The answer is $x=1/2$ and $y=3/2$.
* This system has infinitely many solutions. In the first subsection, with $z$ as a parameter, we got $x=(43-7z)/4$ and $y=(13-z)/4$. Maple responds with $[-12+7\_t_{1},\_t_{1},13-4\_t_{1}]$, for some reason preferring $y$ as a parameter.
* There is no solution to this system. When the array $A$ and vector $u$ are given to Maple and it is asked to linsolve(A,u), it returns no result at all, that is, it responds with no solutions.
* The solutions is $(x,y,z)=(5,5,0)$.
* There are many solutions. Maple gives $[1,-1+\_t_{1},3-\_t_{1},\_t_{1}]$.
Mathematica Answer:
applying this function for RowReduce in MatrixForm to ${\begin{pmatrix}-1&1&1\\1&1&2\end{pmatrix}}$ yields ${\begin{pmatrix}1&0&1/2\\0&1&3/2\end{pmatrix}}$.

### Problem 3

Use the computer to solve these systems from the second subsection.
* ${\begin{array}{*{2}{rc}r}3x&+&6y&=&18\\x&+&2y&=&6\end{array}}$
* ${\begin{array}{*{2}{rc}r}x&+&y&=&1\\x&-&y&=&-1\end{array}}$
* ${\begin{array}{*{3}{rc}r}x_{1}&&&+&x_{3}&=&4\\x_{1}&-&x_{2}&+&2x_{3}&=&5\\4x_{1}&-&x_{2}&+&5x_{3}&=&17\end{array}}$
* ${\begin{array}{*{3}{rc}r}2a&+&b&-&c&=&2\\2a&&&+&c&=&3\\a&-&b&&&=&0\end{array}}$
* ${\begin{array}{*{4}{rc}r}x&+&2y&-&z&&&=&3\\2x&+&y&&&+&w&=&4\\x&-&y&+&z&+&w&=&1\end{array}}$
* ${\begin{array}{*{4}{rc}r}x&&&+&z&+&w&=&4\\2x&+&y&&&-&w&=&2\\3x&+&y&+&z&&&=&7\end{array}}$

### Answer

As with the prior question, entering these is easy.
* This system has infinitely many solutions. In the second subsection we gave the solution set as and Maple responds with $[6-2\_t_{1},\_t_{1}]$.
    $\{{\begin{pmatrix}6\\0\end{pmatrix}}+{\begin{pmatrix}-2\\1\end{pmatrix}}y\,{\big |}\,y\in \mathbb {R} \}$
* The solution set has only one member and Maple has no trouble finding it $[0,1]$.
    $\{{\begin{pmatrix}0\\1\end{pmatrix}}\}$
* This system's solution set is infinite and Maple gives $[\_t_{1},-\_t_{1}+3,-\_t_{1}+4]$.
    $\{{\begin{pmatrix}4\\-1\\0\end{pmatrix}}+{\begin{pmatrix}-1\\1\\1\end{pmatrix}}x_{3}\,{\big |}\,x_{3}\in \mathbb {R} \}$
* There is a unique solution and Maple gives $[1,1,1]$.
    $\{{\begin{pmatrix}1\\1\\1\end{pmatrix}}\}$
* This system has infinitely many solutions; in the second subsection we described the solution set with two parameters as does Maple $[3-2\_t_{1}+\_t_{2},\_t_{1},\_t_{2},-2+3\_t_{1}-2\_t_{2}]$.
    $\{{\begin{pmatrix}5/3\\2/3\\0\\0\end{pmatrix}}+{\begin{pmatrix}-1/3\\2/3\\1\\0\end{pmatrix}}z+{\begin{pmatrix}-2/3\\1/3\\0\\1\end{pmatrix}}w\,{\big |}\,z,w\in \mathbb {R} \}$
* The solution set is empty and Maple replies to the linsolve(A,u) command with no returned solutions.
{{TextBox|1=

### Problem 4

What does the computer give for the solution of the general $2\!\times \!2$ system?
    ${\begin{array}{*{2}{rc}r}ax&+&cy&=&p\\bx&+&dy&=&q\end{array}}$

### Answer

In response to this prompting
> A:=array( [[a,c], [b,d]] ); > u:=array([p,q]); > linsolve(A,u);
Maple thought for perhaps twenty seconds and gave this reply.
    ${\bigl-{\frac {-d\,p+q\,c}{-b\,c+a\,d}},{\frac {-b\,p+a\,q}{-b\,c+a\,d}}{\bigr ]}$
    Mathematica Solution
    RowReduce[( { {a, c, p}, {b, d, q} } )] // MatrixForm returns ${\begin{pmatrix}1&0&{\frac {dp-cq}{-bc+ad}}\\0&1&{\frac {bp-aq}{bc-ad}}\end{pmatrix}}$ in about 2 milliseconds.