Systèmes linéaires et déterminants

> with(linalg):

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

Exercice 1

> mat1:=matrix(5,5,[[-2,1,3,1,-2],[-2,-2,1,3,1],[1,-2,-2,1,3],[3,1,-2,-2,1],[1,3,1,-2,-2]]);

mat1 := matrix([[-2, 1, 3, 1, -2], [-2, -2, 1, 3, 1...

> inverse(mat1);

matrix([[1, 1, -2, 3, -2], [-2, 1, 1, -2, 3], [3, -...

> det(mat1);

1

C'est ce qui explique le résultat si simple (sans fraction)...

Exercice 2

> matA:=matrix(3,3,[[1,1,m],[1,1,-1],[1,m,-1]]);

matA := matrix([[1, 1, m], [1, 1, -1], [1, m, -1]])...

> factor(det(matA));

(-1+m)*(m+1)

> solve({x+y+m*z=m,x+y-z=1,x+m*y-z=1},{x,y,z});

{x = 2*m/(m+1), z = (-1+m)/(m+1), y = 0}

En fait, c'est lorsque le système est de Cramer; il reste faire les cas particuliers.

> m:=1:solve({x+y+m*z=m,x+y-z=1,x+m*y-z=1},{x,y,z});

{y = y, z = 0, x = 1-y}

> m:=-1:solve({x+y+m*z=m,x+y-z=1,x+m*y-z=1},{x,y,z});

Cela signifie non pas que Maple ne trouve pas de solution, mais qu'il n'en existe pas. Maple sait en effet résoudre les systèmes linéaires...

Exercice 3

> ?colspace

The functions rowspace(A) and colspace(A) return a set of vectors that form a basis for the vector space spanned by the rows and columns of the matrix A, respectively. The vectors are returned in a canonical form with leading entries 1.

> mat31:=matrix(4,1,[[0],[1],[1],[0]]);
kernel(mat31),colspace(mat31);

mat31 := MATRIX([[0], [1], [1], [0]])

{}, {VECTOR([0, 1, 1, 0])}

> mat32:=matrix(1,4,[[0,1,1,0]]);
kernel(mat32),colspace(mat32);

mat32 := MATRIX([[0, 1, 1, 0]])

{VECTOR([1, 0, 0, 0]), VECTOR([0, -1, 1, 0]), VECTO...

> mat33:=matrix(3,4,[[0,1,2,0],[1,0,1,0],[0,1,2,0]]);
kernel(mat33);colspace(mat33);

mat33 := MATRIX([[0, 1, 2, 0], [1, 0, 1, 0], [0, 1,...

{VECTOR([0, 0, 0, 1]), VECTOR([1, 2, -1, 0])}

{VECTOR([0, 1, 0]), VECTOR([1, 0, 1])}

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

mat34 := MATRIX([[1, 2], [3, 4], [5, 6]])

{}

{VECTOR([0, 1, 2]), VECTOR([1, 0, -1])}

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

mat35 := MATRIX([[1, 2, 3], [4, 5, 6]])

> kernel(mat35);colspace(mat35);rowspace(mat35);

{VECTOR([1, -2, 1])}

{VECTOR([0, 1]), VECTOR([1, 0])}

{VECTOR([1, 0, -1]), VECTOR([0, 1, 2])}

Exercice 4

> mat41:=matrix(2,2,[[cos(theta),-sin(theta)],[sin(theta),cos(theta)]]);

mat41 := matrix([[cos(theta), -sin(theta)], [sin(th...

> kernel(mat41),colspace(mat41);

{}, {vector([1, 0]), vector([0, 1])}

> det(mat41);

cos(theta)^2+sin(theta)^2

> simplify(%);

1

> mat42:=matrix(3,3,[[1,1,0],[2,2,1],[1,0,-2]]);

mat42 := matrix([[1, 1, 0], [2, 2, 1], [1, 0, -2]])...

> kernel(mat42),colspace(mat42);

{}, {vector([0, 1, 0]), vector([0, 0, 1]), vector([...

> mat43:=matrix(3,3,[[1,1,0],[2,2,0],[1,0,-1]]);

mat43 := matrix([[1, 1, 0], [2, 2, 0], [1, 0, -1]])...

> kernel(mat43),colspace(mat43);

{vector([1, -1, 1])}, {vector([1, 2, 0]), vector([0...

> mat44:=matrix(4,4,[[1,1,2,0],[0,2,-1,1],[0,0,3,2],[0,0,0,-1]]);

mat44 := matrix([[1, 1, 2, 0], [0, 2, -1, 1], [0, 0...

> kernel(mat44),colspace(mat44);

{}, {vector([0, 0, 1, 0]), vector([0, 0, 0, 1]), ve...

Exercice 5

> mat_5 := matrix([[1, cos(t_1), cos(2*t_1)], [1, cos(t_2), cos(2*t_2)], [1, cos(t_3), cos(2*t_3)]]);

mat_5 := matrix([[1, cos(t_1), cos(2*t_1)], [1, cos...

> factor(det(mat_5));

cos(t_2)*cos(2*t_3)-cos(2*t_2)*cos(t_3)-cos(t_1)*co...
cos(t_2)*cos(2*t_3)-cos(2*t_2)*cos(t_3)-cos(t_1)*co...

Gloups ...

> combine(%,trig);

1/2*cos(-t_2+2*t_3)+1/2*cos(t_2+2*t_3)-1/2*cos(-2*t...
1/2*cos(-t_2+2*t_3)+1/2*cos(t_2+2*t_3)-1/2*cos(-2*t...
1/2*cos(-t_2+2*t_3)+1/2*cos(t_2+2*t_3)-1/2*cos(-2*t...

> expand(%);

2*cos(t_2)*cos(t_3)^2-2*cos(t_3)*cos(t_2)^2-2*cos(t...
2*cos(t_2)*cos(t_3)^2-2*cos(t_3)*cos(t_2)^2-2*cos(t...

> factor(%);

2*(cos(t_3)-cos(t_2))*(cos(t_1)-cos(t_2))*(cos(t_1)...

Sans les mains !

Exercice 7

> matA:=matrix(3,3,[[2*(a-1),2,-1],[2,2*a,2],[4*a,2*(2*a+1),2*a+1]]);

matA := matrix([[2*a-2, 2, -1], [2, 2*a, 2], [4*a, ...

> factor(det(matA));

4*a*(2*a-1)*(a-1)

> solve({2*(a-1)*x+2*y-z=2*(a+1),2*x+2*a*y+2*z=4*a^2+3,4*a*x+2*(2*a+1)*y+(2*a+1)*z=16*a^3-2*a^2-a+5},{x,y,z});

{x = 1/2*(34*a+19+16*a^2)/(2*a-1), y = -6*a-3, z = ...

Les cas dégénérés ne sont pas traités. Attention, pour a=0 ou a=1, le résultat précédent est non grotesque mais faux : regardez par exemple l'exemple suivant :

> solve(a*x=a,x);

1

Pour a=0, tous les réels sont pourtant solution...

> a:=0:solve({2*(a-1)*x+2*y-z=2*(a+1),2*x+2*a*y+2*z=4*a^2+3,4*a*x+2*(2*a+1)*y+(2*a+1)*z=16*a^3-2*a^2-a+5},{x,y,z});

{z = z, y = 5/2-1/2*z, x = 3/2-z}

> a:=1:solve({2*(a-1)*x+2*y-z=2*(a+1),2*x+2*a*y+2*z=4*a^2+3,4*a*x+2*(2*a+1)*y+(2*a+1)*z=16*a^3-2*a^2-a+5},{x,y,z});

{z = z, x = 3/2-3/2*z, y = 2+1/2*z}

> a:=1/2:solve({2*(a-1)*x+2*y-z=2*(a+1),2*x+2*a*y+2*z=4*a^2+3,4*a*x+2*(2*a+1)*y+(2*a+1)*z=16*a^3-2*a^2-a+5},{x,y,z});

Pas de solution...

Exercice 8

> ?vandermonde

The function vandermonde(L) returns the Vandermonde matrix formed from the elements of the list. This square matrix has as its (i,j)-th entry L[i]^(j-1).

> VDM:=vandermonde([1515,exp(-1),pi]);

VDM := matrix([[1, 1515, 2295225], [1, exp(-1), exp...

> VDM2:=vandermonde([lambda1,lambda2,lambda3,lambda4]);

VDM2 := matrix([[1, lambda1, lambda1^2, lambda1^3],...

> factor(det(VDM));

(-1515+exp(-1))*(-1515+pi)*(pi-exp(-1))

> factor(det(VDM2));

(-lambda1+lambda4)*(-lambda1+lambda2)*(lambda2-lamb...

Une petite idée de la formule générale ?

Exercice 9

> fun_9 :=(i,j) -> if j=i then (1+x) else 1 fi;

fun_9 := proc (i, j) options operator, arrow; if j ...

> mat_9 := n -> matrix(n,n,fun_9);

mat_9 := proc (n) options operator, arrow; matrix(n...

> mat_9(4);

matrix([[1+x, 1, 1, 1], [1, 1+x, 1, 1], [1, 1, 1+x,...

> seq(factor(det(mat_11(i))),i=2..6);

x*(2+x), x^2*(3+x), x^3*(4+x), x^4*(5+x), x^5*(6+x)...

La encore, une géniale intuition peut nous donner une petite idée du résultat...

Exercice 10

> fun_10:=(i,j) -> if j=i then if i=1 then cos(theta) else 2*cos(theta) fi elif abs(j-i)=1 then 1 else 0 fi;

fun_10 := proc (i, j) options operator, arrow; if j...
fun_10 := proc (i, j) options operator, arrow; if j...
fun_10 := proc (i, j) options operator, arrow; if j...
fun_10 := proc (i, j) options operator, arrow; if j...

> mat_10 := n-> matrix(n,n,fun_10);

mat_10 := proc (n) options operator, arrow; matrix(...

> mat_10(4);

matrix([[cos(theta), 1, 0, 0], [1, 2*cos(theta), 1,...

> seq(combine(det(mat_10(i)),trig),i=2..6);

cos(2*theta), cos(3*theta), cos(4*theta), cos(5*the...

Hum...

Exercice 11

> a:='a':

> fun_11 := (i,j) -> if j=i then a+b else if j=i+1 then b else if j=i-1 then a else 0 fi fi fi;

fun_11 := proc (i, j) options operator, arrow; if j...
fun_11 := proc (i, j) options operator, arrow; if j...
fun_11 := proc (i, j) options operator, arrow; if j...
fun_11 := proc (i, j) options operator, arrow; if j...

> mat_11:= n-> matrix(n,n,fun_11);

mat_11 := proc (n) options operator, arrow; matrix(...

> mat_11(4);

matrix([[a+b, b, 0, 0], [a, a+b, b, 0], [0, a, a+b,...

> seq(det(mat_11(i)),i=2..5);

a^2+b*a+b^2, a^3+b*a^2+a*b^2+b^3, a^4+b*a^3+a^2*b^2...

> det(mat_11(10));

a^10+a^9*b+a^8*b^2+a^7*b^3+a^6*b^4+a^5*b^5+b^6*a^4+...

> simplify((a^11-b^11)/(a-b));

a^10+a^9*b+a^8*b^2+a^7*b^3+a^6*b^4+a^5*b^5+b^6*a^4+...

Exercice 12

> mat12:=matrix(4,4,[[a,b,c,d],[b,a,d,c],[c,d,a,b],[d,c,b,a]]);

mat12 := matrix([[a, b, c, d], [b, a, d, c], [c, d,...

> factor(det(mat12));

(b+a+c+d)*(b+a-c-d)*(-b+a+c-d)*(-b+a-c+d)