Solving Linear Systems with Maple

The Maple session below shows how you use the addrow and swaprow commands in Maple to step through the Gaussian Elimination algorithm. Note: two of the addrow steps are shown. The rest of the steps are iterations of these and are ommitted to save space.


> with(linalg);
Warning: new definition for   norm
Warning: new definition for   trace


[BlockDiagonal, GramSchmidt, JordanBlock, Wronskian, add, addcol, addrow, adj,

    adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix,

    charmat, charpoly, col, coldim, colspace, colspan, companion, concat, cond,

    copyinto, crossprod, curl, definite, delcols, delrows, det, diag, diverge,

    dotprod, eigenvals, eigenvects, entermatrix, equal, exponential, extend,

    ffgausselim, fibonacci, frobenius, gausselim, gaussjord, genmatrix, grad,

    hadamard, hermite, hessian, hilbert, htranspose, ihermite, indexfunc,

    innerprod, intbasis, inverse, ismith, iszero, jacobian, jordan, kernel,

    laplacian, leastsqrs, linsolve, matrix, minor, minpoly, mulcol, mulrow,

    multiply, norm, normalize, nullspace, orthog, permanent, pivot, potential,

    randmatrix, randvector, rank, ratform, row, rowdim, rowspace, rowspan,

    rref, scalarmul, singularvals, smith, stack, submatrix, subvector,

    sumbasis, swapcol, swaprow, sylvester, toeplitz, trace, transpose,

    vandermonde, vecpotent, vectdim, vector]
--------------------------------------------------------------------------------
> A:=matrix(4,5,[1,1,0,1,2,2,1,-1,1,1,-1,2,3,-1,4,3,-1,-1,2,-3]);

                                [  1   1   0   1   2 ]
                                [                    ]
                                [  2   1  -1   1   1 ]
                           A := [                    ]
                                [ -1   2   3  -1   4 ]
                                [                    ]
                                [  3  -1  -1   2  -3 ]
> A1:=addrow(A,1,2,-A[2,1]/A[1,1]);

                                [  1   1   0   1   2 ]
                                [                    ]
                                [  0  -1  -1  -1  -3 ]
                          A1 := [                    ]
                                [ -1   2   3  -1   4 ]
                                [                    ]
                                [  3  -1  -1   2  -3 ]
--------------------------------------------------------------------------------
> A1:=addrow(A1,1,4,-A1[4,1]/A1[1,1]);

                                 [ 1   1   0   1   2 ]
                                 [                   ]
                                 [ 0  -1  -1  -1  -3 ]
                           A1 := [                   ]
                                 [ 0   3   3   0   6 ]
                                 [                   ]
                                 [ 0  -4  -1  -1  -9 ]
--------------------------------------------------------------------------------
> A2:=addrow(A2,2,4,-A1[4,2]/A1[2,2]);

                                 [ 1   1   0   1   2 ]
                                 [                   ]
                                 [ 0  -1  -1  -1  -3 ]
                           A2 := [                   ]
                                 [ 0   0   0  -3  -3 ]
                                 [                   ]
                                 [ 0   0   3   3   3 ]
--------------------------------------------------------------------------------
> A3:=swaprow(A2,3,4);

                                 [ 1   1   0   1   2 ]
                                 [                   ]
                                 [ 0  -1  -1  -1  -3 ]
                           A3 := [                   ]
                                 [ 0   0   3   3   3 ]
                                 [                   ]
                                 [ 0   0   0  -3  -3 ]
--------------------------------------------------------------------------------
> backsub(A3);

                                 [ -1, 2, 0, 1 ]
--------------------------------------------------------------------------------
>