Systems of linear equations and Gauss elimination method
In this worksheet you will see some example of how to write and solve linear systems with the Maple package.
Example 1 . We solve the following system of linear equations:
| > | solve({3*x+y-z=1,2*x+5*y+2*z=3},{x,y,z}); |
Let us try another example:
| > | solve({x+y=1,2*x+2*y=3},{x,y}); |
It looks like Maple does not want to solve it. Does that mean anything? It is a simple system: we can see that the two equations have proportional coefficients, however, the right hand side of the equations are not proportional with the same constant, so the system is inconsistent. Let's see what we get if we use the elimnation mehod. We will use matrix notation this time.
| > | with(LinearAlgebra); |
| > | A:=<<1,2>|<1,2>>;# the coefficient matrix |
| > | b:=<<1,3>>;# the right hand side of the equations |
| > | ReducedRowEchelonForm(<A|b>); |
Now, if we look at the reduced row echaon form of the augmented matrix (<A|b>) we see that the second row corresponds to an equation of the form
which is impossible, so the system is inconsistent.
Example 2 . Here is another matrix representing the coefficients of a linear system. Write the system corresponding to it and solve the system corresponding to the augmented matrix <A1|b1>.
| > | A1:=<<3,1>|<1,5>|<-1,1>>; |
| > | b1:=<1,3>; |
| > | ReducedRowEchelonForm(<A1|b1>); |
Example 3 . This example is showing another way of definig matrices in Maple. However, this format is not appropriate for defininig the augmented matrix.
| > | A2:=Matrix([[2,1,0,3],[-1,0,2,4],[4,-2,7,0]]); |
| > | b2:=Matrix([[1],[2],[1]]); |
| > | ReducedRowEchelonForm(A2); |
Same matrix as above defined as in Examples 1 and 2.
| > | A3:=<<2,-1,4>|<1,0,-2>|<0,2,7>|<3,4,0>>; |
| > | b3:=<<1,2,1>>; |
| > | ReducedRowEchelonForm(<A3|b3>); |
Example 4 . Let us look at an exercise 8(d) section 1.2 (Anton&Rorres). We define te matrix as before:
| > | A4:=<<0,1,3,-2,1>|<10,4,2,-8,-6>|<-4,-1,1,2,3>|<1,1,2,-2,0>>; |
| > | b4:=<1,2,5,-4,1>; |
| > | ReducedRowEchelonForm(<A4|b4>); |
If we want the solution to the above system we need to call a Maple package:
| > | with(linalg); |
Warning, the name GramSchmidt has been rebound
Warning, the protected names norm and trace have been redefined and unprotected
| > | linsolve(A4,b4); |