Systems of Linear Equations -- "linsolve" Command

>

One of the major reasons for introducing matrices is to solve large systems of linear equations. These are systems of the form

Ax = b ,

where, for a system of m equations with n unknowns, A is a given m by n matrix of coefficients, x=[ [Maple Math] , [Maple Math] ,..., [Maple Math] ], is a vector of unknowns, b=[ [Maple Math] ,..., [Maple Math] ] a vector of the right-hand sides. Maple has a special command for solving such systems. Unlike Matlab , Maple can handle systems with parameters. To solve a linear system Ax=b, we use syntax linsolve(A,b); .

Example 1. Suppose we want to solve the system

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math] .

That is, the system

Bx=p

whose matrix of coefficients is the matrix B defined above, the vector of right-hand sides is p= [1,2,3,4]. Maple can easily do it for us. Recall the definition of B and define p:

> evalm(B);

> p:=vector([1,2,3,4]);

>

Now we can solve the system with the command linsolve . Let's label the vector of solutions by sol .

> sol:=linsolve(B,p);

>

Maple displays the solution as a vector [Maple Math] . The system has a unique solution. This is not surprising if we look at the ranks of the matrix B and the augmented matrix Baup=[B,p]:

> Baup:=augment(B,p); rank(B); rank(Baup);

>

Both ranks are the same and equal to the number of unknowns. We can check that Bx=p by matrix multiplication:

> evalm(B&*sol);

>

Example 2. If a system has infinitely many solutions, Maple expresses the first few unknowns in terms of others, which can be considered as parameters. By default, the unknowns that can be taken arbitrary are denoted as [Maple Math] .. etc.. Let's solve the system

Cx = r ,

where C is the matrix defined in the first section and r=[1,2].

> evalm(C);

> r:=vector([1,2]);

>

The system Cx=p is underdetermined: there are fewer equations than unknowns. The system may have no solutions or infinitely many solutions. Let's check with the command linsolve .

> linsolve(C,r);

>

As we see, three unknowns can be taken as arbitrary, t_1, t_2, t_3 and the remaining variable expressed in their terms. This is because the rank of the matrix C, as well as the augmented matrix [C,r] is 1 and the number of unknowns 4.

>

Example 3. If a system has no solutions, Maple returns no answer. For example:

> w:=vector([1,1]);

> linsolve(C,w);

>

No output, as the system Cx=d has no solutions. Indeed, the rank od C and the corresponding augmented matrix [C,d] are not equal.

>

Example 4. Maple can solve systems with parameters. Let's solve the system

Ax=h ,

where h=[1,2,3,4], and A is the matrix defined in the first section:

> evalm(A); h:=vector([1,2,3,4]);

> sol1:=linsolve(A,h);

>

Again, we have to evaluate the output of the latter command critically. We know that the above 4 by 4 system has a unique solution if and only if det(A) is not 0. Recall that

> det(A);

>

We see det(A)=0 only for a=b=0. In this case, the system clearly has no solutions. In all remaining cases, the system has a unique solution and Maple provides a formula for it.

>