> with(linalg);

Warning, the previous binding of the name GramSchmidt has been removed and it now has an assigned value

Warning, the protected names norm and trace have been redefined and unprotected

[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, cold...[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, cold...[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, cold...[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, cold...[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, cold...[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, cold...[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, cold...[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, cold...

L'utilisation du package "linalg" va nous permettre de d'utiliser des outils d'algèbre linéaire en Maple.

Dans les quelques lignes qui suivent, on montre comment utiliser certaines d'entre-elles. Regarder ces opérations (et l'aide en ligne si elles ne vous semblent pas très claires). Vous pouvez aussi vous familiariser avec d'autres fonctions Maple listées après l'instruction précédente "with(linalg)".

> A:=matrix(3,2,[1,2,3,4,5,6]);

A := matrix([[1, 2], [3, 4], [5, 6]])

> B:=array(1..2,1..3,[[1,2,3],[3,4,6]]);

B := matrix([[1, 2, 3], [3, 4, 6]])

> A[3,2];

6

> type(B,matrix); B[1,1];

true

1

> rowdim(B);coldim(B);

2

3

> C1:=col(A,2); C2:=row(A,2);

C1 := vector([2, 4, 6])

C2 := vector([3, 4])

> type(C1,matrix);type(C1,matrix);

false

false

> C1:=convert(C1,matrix);

> C2:=transpose(convert(C2,matrix));

C1 := matrix([[2], [4], [6]])

C2 := matrix([[3, 4]])

> type(C2,matrix);

true

> v:=vector([0,1]);

v := vector([0, 1])

> multiply(A,v);

vector([2, 4, 6])

> A:=randmatrix(2, 2);

A := matrix([[-85, -55], [-37, -35]])

> B:=inverse(A);

B := matrix([[(-7)/188, 11/188], [37/940, (-17)/188]])

> multiply(A,B);

matrix([[1, 0], [0, 1]])

> alea:=proc() evalf(rand(10^6)()*10^(-4)); end;

alea := proc () evalf(1/10000*rand(1000000)()) end proc

>

> A:=randmatrix(3,3,entries = alea);

A := matrix([[71.89760000, 83.05380000, 22.20850000], [12.17680000, 61.39210000, 3.740900000], [95.26550000, 48.71630000, 49.04570000]])

> B:=inverse(A);

B := matrix([[0.4243193391e-1, -0.4487305254e-1, -0.1579106838e-1], [-0.3612639953e-2, 0.2115861266e-1, 0.2200111963e-4], [-0.7883066098e-1, 0.6614411589e-1, 0.5103958579e-1]])

> multiply(A,B);

matrix([[1.000000001, 0., 0.], [-0.2e-9, 1.000000001, 0.], [-0.1e-8, 0., 1.000000001]])

>

> A:=randmatrix(4,4);

A := matrix([[-8, -93, 92, 43], [-62, 77, 66, 54], [-5, 99, -61, -50], [-12, -18, 31, -26]])

> minor(A,3,3);

matrix([[-8, -93, 43], [-62, 77, 54], [-12, -18, -26]])

> delrows(A,1..1);

matrix([[-62, 77, 66, 54], [-5, 99, -61, -50], [-12, -18, 31, -26]])

> delcols(A,2..3);

matrix([[-8, 43], [-62, 54], [-5, -50], [-12, -26]])

> swapcol(A,1,2);

matrix([[-93, -8, 92, 43], [77, -62, 66, 54], [99, -5, -61, -50], [-18, -12, 31, -26]])

> swaprow(A,3,4);

matrix([[-8, -93, 92, 43], [-62, 77, 66, 54], [-12, -18, 31, -26], [-5, 99, -61, -50]])

> A:=matrix(3,3,[1,2,3,4,5,6,7,8,9]);

A := matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

> addrow(A,1,2,1);

matrix([[1, 2, 3], [5, 7, 9], [7, 8, 9]])

> addrow(A,1,2,-2);

matrix([[1, 2, 3], [2, 1, 0], [7, 8, 9]])

> addcol(A,1,3,-2);

matrix([[1, 2, 1], [4, 5, -2], [7, 8, -5]])

> mulrow(A,2,-1);

matrix([[1, 2, 3], [-4, -5, -6], [7, 8, 9]])

> mulcol(A,1,1/100);

matrix([[1/100, 2, 3], [1/25, 5, 6], [7/100, 8, 9]])

>

> Pivoter := proc(A, i, j)
  local k, B, n;

  n := rowdim(A);

  B:=A;

  for k from 1 to n do

      if k <> i then B:=addrow(B,i,k,-A[k,j]/A[i,j]);

      end if;

  end do;

  return evalm(B);

end proc;

Pivoter := proc (A, i, j) local k, B, n; n := rowdim(A); B := A; for k to n do if k <> i then B := addrow(B, i, k, -A[k, j]/A[i, j]) end if end do; return evalm(B) end proc

> with(LinearAlgebra);
Pivoter2 := proc(A, i, j)

  local k, B, n;

  n := RowDimension(A);

  B:=A;

  for k from 1 to n do

      if k <> i then B:=RowOperation(B,[k,i],-B[k,j]/B[i,j]);

      end if;

  end do;

  return B;

end proc;

[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...[&x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSp...

Pivoter2 := proc (A, i, j) local k, B, n; n := LinearAlgebra:-RowDimension(A); B := A; for k to n do if k <> i then B := LinearAlgebra:-RowOperation(B, [k, i], -B[k, j]/B[i, j]) end if end do; return ...Pivoter2 := proc (A, i, j) local k, B, n; n := LinearAlgebra:-RowDimension(A); B := A; for k to n do if k <> i then B := LinearAlgebra:-RowOperation(B, [k, i], -B[k, j]/B[i, j]) end if end do; return ...Pivoter2 := proc (A, i, j) local k, B, n; n := LinearAlgebra:-RowDimension(A); B := A; for k to n do if k <> i then B := LinearAlgebra:-RowOperation(B, [k, i], -B[k, j]/B[i, j]) end if end do; return ...Pivoter2 := proc (A, i, j) local k, B, n; n := LinearAlgebra:-RowDimension(A); B := A; for k to n do if k <> i then B := LinearAlgebra:-RowOperation(B, [k, i], -B[k, j]/B[i, j]) end if end do; return ...Pivoter2 := proc (A, i, j) local k, B, n; n := LinearAlgebra:-RowDimension(A); B := A; for k to n do if k <> i then B := LinearAlgebra:-RowOperation(B, [k, i], -B[k, j]/B[i, j]) end if end do; return ...Pivoter2 := proc (A, i, j) local k, B, n; n := LinearAlgebra:-RowDimension(A); B := A; for k to n do if k <> i then B := LinearAlgebra:-RowOperation(B, [k, i], -B[k, j]/B[i, j]) end if end do; return ...Pivoter2 := proc (A, i, j) local k, B, n; n := LinearAlgebra:-RowDimension(A); B := A; for k to n do if k <> i then B := LinearAlgebra:-RowOperation(B, [k, i], -B[k, j]/B[i, j]) end if end do; return ...

> A:=Matrix([[1,2,3],[4,5,6],[7,8,9]]);
B:=Pivoter2(A,1,1);

A := Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

B := Matrix([[1, 2, 3], [0, -3, -6], [0, -6, -12]])

> B:=Pivoter2(B,2,2);

B := Matrix([[1, 0, -1], [0, -3, -6], [0, 0, 0]])

> PivotGauss2 := proc(A)
 local i, j, k, l, B, p;

 B:=A;

 k:=RowDimension(B);

 l:=ColumnDimension(B);

 i:=1;j:=1;

 while (j<=l) and (i<=k) do

 p:=i;

 while (p<=k) and B[p,j]=0 do p:=p+1; od;

 if p<=k then

if p<>i then B:=RowOperation(B,[i,p]);

fi;

  B:=Pivoter2(B,i,j);

  i:=i+1;

 fi;

 j:=j+1;

 od;

return B;

end;

PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...PivotGauss2 := proc (A) local i, j, k, l, B, p; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; while j <= l and i <= k do p := i; while p <= k and...

>

> A:=Matrix([[1,2,3],[4,5,6],[7,8,9]]);

A := Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

> PivotGauss2(A);

Matrix([[1, 0, -1], [0, -3, -6], [0, 0, 0]])

> A:=Matrix([[1,0,3],[1,0,0],[0,1,0]]);

A := Matrix([[1, 0, 3], [1, 0, 0], [0, 1, 0]])

> PivotGauss2(A);

Matrix([[1, 0, 0], [0, 1, 0], [0, 0, -3]])

> A:=Matrix([[1,2,3,0,1,0],[1,1,0,2,1,4],[0,1,0,2,0,1]]);

A := Matrix([[1, 2, 3, 0, 1, 0], [1, 1, 0, 2, 1, 4], [0, 1, 0, 2, 0, 1]])

> PivotGauss2(A);

Matrix([[1, 0, 0, 0, 1, 3], [0, -1, 0, -2, 0, -1], [0, 0, -3, 4, 0, 5]])

> A:=Matrix([[1,2,3],[0,1,0],[1,1,0],[2,1,4],[0,1,0],[2,0,1]]);

A := Matrix([[1, 2, 3], [0, 1, 0], [1, 1, 0], [2, 1, 4], [0, 1, 0], [2, 0, 1]])

> PivotGauss2(A);

Matrix([[1, 0, 0], [0, 1, 0], [0, 0, -3], [0, 0, 0], [0, 0, 0], [0, 0, 0]])

> A:=Matrix([[0,0,1],[0,1,0],[1,0,0]]);

A := Matrix([[0, 0, 1], [0, 1, 0], [1, 0, 0]])

> PivotGauss2(A);

Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]])

> Deter := proc(A)
 local i, j, k, l, B, p, signe, dete;

 B:=A;

 k:=RowDimension(B);

 l:=ColumnDimension(B);

 i:=1;j:=1;signe:=1;

 while (j<=l) and (i<=k) do

 p:=i;

 while (p<=k) and B[p,j]=0 do p:=p+1; od;

 if p<=k then

if p<>i then B:=RowOperation(B,[i,p]);signe:=(-1)*signe;

fi;

  B:=Pivoter2(B,i,j);

 fi;

 dete:=dete*B[i,i];

 i:=i+1;j:=j+1;

 od;

dete:=signe*dete;

return dete;

end;

Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...Deter := proc (A) local i, j, k, l, B, p, signe, dete; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); i := 1; j := 1; signe := 1; while j <= l and i <= k do p := ...

> A:=RandomMatrix(4,4); Deter(A); det(A);

A := Matrix([[-16, -17, -41, 45], [-50, 29, 7, -81], [77, -44, -87, 56], [89, 91, -35, 58]])

52971372*dete

52971372

> A:=Matrix([[1,0,3],[1,0,0],[0,0,1]]);Deter(A);

A := Matrix([[1, 0, 3], [1, 0, 0], [0, 0, 1]])

0

> Ident:=IdentityMatrix(4,4);

Ident := Matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])

> Pivoter3 := proc(A,B, i, j)
  local k, C, D,n,coeff;

  n := RowDimension(A);

  C:=A;D:=B;

  coeff:=1/C[i,j];

  C:=RowOperation(C,i,coeff); D:=RowOperation(D,i,coeff);

  for k from 1 to n do

      if k <> i then

coeff:=-C[k,j];

C:=RowOperation(C,[k,i],coeff);

D:=RowOperation(D,[k,i],coeff);

      end if;

  end do;

  return C,D;

end proc;

Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...Pivoter3 := proc (A, B, i, j) local k, C, D, n, coeff; n := LinearAlgebra:-RowDimension(A); C := A; D := B; coeff := 1/C[i, j]; C := LinearAlgebra:-RowOperation(C, i, coeff); D := LinearAlgebra:-RowOp...

> Inversion := proc(A)
 local i, j, k, l, B, p, Idty;

 B:=A;

 k:=RowDimension(B);

 l:=ColumnDimension(B);

 if k<>l then printf("La matrice n'est pas carrée"); return fi;

 if Deter(A)=0 then printf("La matrice n'est pas inversible"); return fi;

 Idty:=ScalarMatrix(1,k,k);

 i:=1;j:=1;

 while (j<=l) and (i<=k) do

 p:=i;

 while (p<=k) and B[p,j]=0 do p:=p+1; od;

 if p<=k then

if p<>i then

B:=RowOperation(B,[i,p]);

Idty:=RowOperation(Idty,[i,p]);

fi;

  B,Idty:=Pivoter3(B,Idty,i,j);

 fi;

 i:=i+1;j:=j+1;

 od;

return B,Idty;

end;

Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(Inversion := proc (A) local i, j, k, l, B, p, Idty; B := A; k := LinearAlgebra:-RowDimension(B); l := LinearAlgebra:-ColumnDimension(B); if k <> l then printf(

> A:=RandomMatrix(4,4); Inversion(A); inverse(A);

A := Matrix([[62, -15, 54, -95], [-52, -52, -51, 21], [94, 46, 35, -23], [85, 70, 18, -36]])

Matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]), Matrix([[(-79)/130046, 10579/780276, 6121/260092, (-2155)/390138], [(-9305)/2080736, (-146599)/12484416, (-79069)/4161472, 106681/6242...

matrix([[(-79)/130046, 10579/780276, 6121/260092, (-2155)/390138], [(-9305)/2080736, (-146599)/12484416, (-79069)/4161472, 106681/6242208], [2641/2080736, (-277937)/12484416, 15957/4161472, (-117265)/...

> A:=Matrix([[1,0,3],[1,0,0],[0,0,1]]);Inversion(A); inverse(A);

A := Matrix([[1, 0, 3], [1, 0, 0], [0, 0, 1]])

La matrice n'est pas inversible

Error, (in inverse) singular matrix

>

Déterminant par la méthode des mineurs.

> DetMineur := proc(A)
local somme, i, k, n, m;

n := RowDimension(A);

m := ColumnDimension(A);

if n <> m then printf("La matrice n'est pas carrée"); return; fi;

 if n = 1 then return A[1, 1]; end if;

 somme := 0;

    for k to n do

       somme := somme + (-1)^(1+k) * A[k,1]*DetMineur(Minor(A, k, 1,output='matrix'));

    end do;

return somme;

end proc;

DetMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(DetMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(DetMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(DetMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(DetMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(DetMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(DetMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(DetMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(DetMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(DetMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(

> A:=Matrix([[0,0,1],[0,1,0],[1,0,0]]);DetMineur(A);det(A);

A := Matrix([[0, 0, 1], [0, 1, 0], [1, 0, 0]])

-1

-1

> A:=RandomMatrix(4,4);DetMineur(A);det(A);

A := Matrix([[7, 67, 88, -85], [71, -65, 40, 85], [18, -52, 50, 14], [59, -87, -69, -12]])

70016004

70016004

> A:=Matrix([[2,3,0],[0,1,0],[1,0,0]]);DetMineur(A);det(A);

A := Matrix([[2, 3, 0], [0, 1, 0], [1, 0, 0]])

0

0

>

Calcul du Permanent d'une matrice

> PermMineur := proc(A)
local somme, i, k, n, m;

n := RowDimension(A);

m := ColumnDimension(A);

if n <> m then printf("La matrice n'est pas carrée"); return; fi;

 if n = 1 then return A[1, 1]; end if;

 somme := 0;

    for k to n do

       somme := somme + A[k,1]*PermMineur(Minor(A, k, 1,output='matrix'));

    end do;

return somme;

end proc;

PermMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(PermMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(PermMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(PermMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(PermMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(PermMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(PermMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(PermMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(PermMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(PermMineur := proc (A) local somme, i, k, n, m; n := LinearAlgebra:-RowDimension(A); m := LinearAlgebra:-ColumnDimension(A); if n <> m then printf(

> A:=RandomMatrix(4,4);PermMineur(A);Permanent(A);

A := Matrix([[52, 98, -15, -42], [-12, -83, 43, 34], [48, 15, -42, 0], [39, 9, -64, -62]])

-70302120

-70302120

>

Comparaison de performance

> A:=RandomMatrix(4,4);time(PermMineur(A));time(Permanent(A));time(DetMineur(A));time(det(A));

A := Matrix([[-98, 53, -73, 70], [-64, -15, 87, 94], [-51, 42, -1, 17], [49, -48, 26, -53]])

0.29e-1

0.

0.30e-1

0.

> A:=RandomMatrix(8,8);time(PermMineur(A));time(Permanent(A));time(DetMineur(A));time(det(A));

A := Matrix([[73, 82, -19, -97, -89, 20, -20, 14], [-54, 56, -79, -76, -73, 34, -52, -95], [5, 36, 48, -88, -37, 17, -92, -70], [17, 46, 74, -12, -87, 4, 65, -13], [82, 24, -91, -94, 45, 9, 94, 30], [...

35.360

0.20e-1

36.140

0.

> A:=RandomMatrix(10,10):time(Permanent(A));time(det(A));

.141

0.9e-2

> A:=RandomMatrix(15,15):time(Permanent(A));time(det(A));

8.391

0.40e-1

>