Correction des exercices du chapitre XII

> restart;

XII.1

> with(linalg):

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

> A1:=matrix(4,4,[0,1,1,1,1,0,-1,-1,1,-1,0,-1,1,-1,-1,0]);

A1 := matrix([[0, 1, 1, 1], [1, 0, -1, -1], [1, -1,...

> A2:=matrix([[1,0,1,0],[0,0,0,0],[1,0,0,1],[0,1,0,0]]);

A2 := matrix([[1, 0, 1, 0], [0, 0, 0, 0], [1, 0, 0,...

> iA1:=inverse(A1);

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

> tA2:=transpose(A2);

tA2 := matrix([[1, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0...

> equal(transpose(tA2),A2);

true

> multiply(A1,iA1);

matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [...

> evalm(3*A1);

matrix([[0, 3, 3, 3], [3, 0, -3, -3], [3, -3, 0, -3...

> scalarmul(A1,3);

matrix([[0, 3, 3, 3], [3, 0, -3, -3], [3, -3, 0, -3...

> evalm(A1+A2);

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

> matadd(A1,A2);

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

> evalm(A1&*A2);

matrix([[1, 1, 0, 1], [0, -1, 1, -1], [1, -1, 1, 0]...

> multiply(A2,A1);

matrix([[1, 0, 1, 0], [0, 0, 0, 0], [1, 0, 0, 1], [...

>

> restart;

XII.2

> with(linalg):

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

> f:=[2*u-v+w,u-3*v+w,5*v-w];

f := [2*u-v+w, u-3*v+w, 5*v-w]

> AA:=genmatrix(f,[u,v,w]);

AA := matrix([[2, -1, 1], [1, -3, 1], [0, 5, -1]])

On obtient ainsi la matrice AA telle que y=f(x) <=> Y=AAX. Ce n'est pas la matrice recherchée~: on veut sa matrice transposée.

> A:=transpose(AA);

A := matrix([[2, 1, 0], [-1, -3, 5], [1, 1, -1]])

> X:=matrix(3,1,[x,y,z]);

X := matrix([[x], [y], [z]])

> Y:=multiply(A,X);

Y := matrix([[2*x+y], [-x-3*y+5*z], [x+y-z]])

> noyau:=kernel(A);

noyau := {vector([1, -2, -1])}

> image:=colspace(A);

image := {vector([0, 1, -1/5]), vector([1, 0, 2/5])...

> restart;

XII.3

> with(linalg):

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

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

A := matrix([[1, -1, 1], [5, 2, -1], [3, 4, lambda]...

> A1:=addrow(A,1,2,-5);

A1 := matrix([[1, -1, 1], [0, 7, -6], [3, 4, lambda...

> A2:=addrow(A1,1,3,-3);

A2 := matrix([[1, -1, 1], [0, 7, -6], [0, 7, -3+lam...

> A3:=addrow(A2,2,3,-1);

A3 := matrix([[1, -1, 1], [0, 7, -6], [0, 0, 3+lamb...

> gausselim(A);

matrix([[1, -1, 1], [0, 7, -6], [0, 0, 3+lambda]])

Le rang de A dépend de la valeur de lambda. Si lambda=-3, alors le rang est 2. Sinon il est 3.

> rank(A);

3

> det(A);

7*lambda+21

> restart;

XII.4

> with(linalg):

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

Définissons la fonction qui à (i,j) associe a(i,j)

> a:=proc(i::integer,j::integer)
if i=j then if i<5 then 1-(1/2)^(5-i)
else 1
fi;
else if i=j+1 then (1/2)^(5-j)
else 0
fi;
fi;
end;

a := proc (i::integer, j::integer) if i = j then if...
a := proc (i::integer, j::integer) if i = j then if...
a := proc (i::integer, j::integer) if i = j then if...
a := proc (i::integer, j::integer) if i = j then if...
a := proc (i::integer, j::integer) if i = j then if...

> A:=matrix(5,5);

A := array(1 .. 5,1 .. 5,[])

> for i to 5 do for j to 5 do A[i,j]:=a(i,j) od od:

> evalm(A);

matrix([[15/16, 0, 0, 0, 0], [1/16, 7/8, 0, 0, 0], ...

> A2:=matrix(5,5,a); # Avec une fonction d'initialisation.

A2 := matrix([[15/16, 0, 0, 0, 0], [1/16, 7/8, 0, 0...

> V:=matrix(5,1,0):V[1,1]:=1:'V'=evalm(V);

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

> B:=A:

> for k from 1 to 50 do print([k,multiply(B,V)[5,1]=evalf(multiply(B,V)[5,1])]); B:=B&*A od:

[1, 0 = 0.]

[2, 0 = 0.]

[3, 0 = 0.]

[4, 1/1024 = .9765625000e-3]

[5, 65/16384 = .3967285156e-2]

[6, 2555/262144 = .9746551514e-2]

[7, 78685/4194304 = .1875996590e-1]

[8, 2091171/67108864 = .3116087615e-1]

[9, 50334765/1073741824 = .4687790293e-1]

[10, 1128430435/17179869184 = .6568329612e-1]

[11, 23983373645/274877906944 = .8725100504e-1]

[12, 489070901891/4398046511104 = .1112018485]

[13, 9650133915565/70368744177664 = .1371366511]

[14, 185389978382115/1125899906842624 = .1646593780...

[15, 3483848843701005/18014398509481984 = .19339246...

[16, 64271413355689411/288230376151711744 = .222986...

[17, 1167329687819961965/4611686018427387904 = .253...

[18, 20920478424299626595/73786976294838206464 = .2...

[19, 370639419073924834765/1180591620717411303424 =...

[20, 6501153241250473129731/18889465931478580854784...

[21, 113040386235813291505965/302231454903657293676...

[22, 1950468378068212309907875/48357032784585166988...

[23, 33426689732500720903798925/7737125245533626718...

[24, 569412547871024336464758851/123794003928538027...

[25, 9647687521712786648438979565/19807040628566084...

[26, 162677214749950203358847369955/316912650057057...

[27, 2731179307991191947615471217485/50706024009129...

[28, 45675094672189040924381158672771/8112963841460...

[29, 761162710033217610534526183214765/129807421463...

[30, 12644104959323312790046111649356835/2076918743...

[31, 209429786812535782657402540936914445/332306998...

[32, 3459725314992993772798006785636727491/53169119...

[33, 57016214870130898172006165072859443565/8507059...

[34, 937559602667198363834141618608629212515/136112...

[35, 15385938901459649832289982135832559513805/2177...

[36, 252026662878041468262306265246395629739011/348...

[37, 4121278505447391674729497594938466457297965/55...

[38, 67288331440932686841805595248685491841080995/8...

[39, 1097042966641035869109466197084591019940039565...

[40, 1786209601236619512380833888076517640960068333...

[41, 2904761801988167397465097317357683654266368099...

[42, 4718440070728186750538732870797785755289572706...

[43, 7656550400474492441680861886328413501257731951...

[44, 1241219082103892355058156540213181027171464875...

[45, 2010366816224152760372136729275823270651414644...

[46, 3253435057682012443840109854993434190995094280...

[47, 5261081610280301427755672681723887385064890857...

[48, 8501547551429294439585921826317487458450853684...

[49, 1372881583167201393550844004020763408284692397...

[50, 2215647508809386185565777890977173923926035134...

> L:=[]:B:=A:
for k from 1 to 50 do L:=[op(L),[k,evalf(multiply(B,V)[5,1])]]:
B:=B&*A;
od:

> plot(L);

Une jolie courbe

> indice_mini:=proc()
local k,uk;
uk:=multiply(A,matrix(5,1,[1,0,0,0,0])):
for k while(uk[5,1]<0.99 and k<1000) do
uk:=multiply(A,uk);
od;
k;
end;

indice_mini := proc () local k, uk; uk := multiply(...
indice_mini := proc () local k, uk; uk := multiply(...
indice_mini := proc () local k, uk; uk := multiply(...
indice_mini := proc () local k, uk; uk := multiply(...
indice_mini := proc () local k, uk; uk := multiply(...
indice_mini := proc () local k, uk; uk := multiply(...

> indice_mini();

89

>