Download MuPAD from SciFace

MuPAD Pro Computing Essentials - Examples 

Example 13.3 Cramer's Rule

This is the example demonstrating how the Cramer's rule works.

  • export(linalg, nrows, ncols, delRow, delCol, det):

  • minor := proc(A, i, j)
       local B;
    begin
       B := delRow(A,i);
       B := delCol(B,j);
       return(hold(Det)(B))
    end:

  • Det := proc(A)

    begin
       r := 0;
       if (nrows(A) <> ncols(A)) then
          return("Wrong input matrix")
       else
          if nrows(A)=1 then
             return(A[1,1])
          else
             for j from 1 to ncols(A) do
                r:=r+(-1)^(1+j)*A[1,j]*minor(A,1,j)
             end;
          end;
       end;
       return(r)
    end:

  • B := Dom::Matrix(Dom::Integer)(
       [[3,2,5,4], [2,5,3,8], [1,2,3,0], [2,3,4,5]]
    ):

  • Det(B)

  • eval(%)

  • eval(%)

  • eval(%)

   28

 

TOP