Linear Algebra/Topic: Computer Algebra Systems
From Wikibooks, the open-content textbooks collection
The linear systems in this chapter are small enough that their solution by hand is easy. But large systems are easiest, and safest, to do on a computer. There are special purpose programs such as LINPACK for this job. Another popular tool is a general purpose computer algebra system, including both commercial packages such as Maple, Mathematica, or MATLAB, or free packages such as SciLab, MuPAD, or Octave.
For example, in the Topic on Networks, we need to solve this.
It can be done by hand, but it would take a while and be error-prone. Using a computer is better.
We illustrate by solving that system under Maple (for another system, a user's manual would obviously detail the exact syntax needed). The array of coefficients can be entered in this way
> A:=array( [[1,-1,-1,0,0,0,0],
[0,1,0,-1,0,-1,0],
[0,0,1,0,-1,1,0],
[0,0,0,1,1,0,-1],
[0,5,0,10,0,0,0],
[0,0,2,0,4,0,0],
[0,5,-1,0,0,10,0]] );
(putting the rows on separate lines is not necessary, but is done for clarity). The vector of constants is entered similarly.
> u:=array( [0,0,0,0,10,10,0] );
Then the system is solved, like magic.
> linsolve(A,u);
7 2 5 2 5 7
[ -, -, -, -, -, 0, - ]
3 3 3 3 3 3
Systems with infinitely many solutions are solved in the same way— the computer simply returns a parametrization.
[edit] Exercises
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.
- Problem 1
Use the computer to solve the two problems that opened this chapter.
- This is the Statics problem.
- This is the Chemistry problem.
- Answer
- The commands
> A:=array( [[40,15],
[-50,25]] );
> u:=array([100,50]);
> linsolve(A,u);
yield the answer [1,4]. - 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 [_t1,3_t1,_t1,3_t1].
- Problem 2
Use the computer to solve these systems from the first subsection, or conclude "many solutions" or "no solutions".
- 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_t1,_t1,13 − 4_t1], 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 + _t1,3 − _t1,_t1].
- Problem 3
Use the computer to solve these systems from the second subsection.
- 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
- The solution set has only one member
- This system's solution set is infinite
- There is a unique solution
- This system has infinitely many solutions; in the second subsection we described the solution set with two parameters
- The solution set is empty and Maple replies to the linsolve(A,u) command with no returned solutions.
- Problem 4
What does the computer give for the solution of the general
system?
- 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]](http://upload.wikimedia.org/math/e/e/3/ee353609c5eff7c1ce8103fa6847df70.png)