Espaces euclidiens

> restart;

> with(linalg):

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

Exercice 1

> int((cos(t)-(a*t+b))^2,t=0..Pi);

a*b*Pi^2+1/2*Pi+4*a+1/3*a^2*Pi^3+b^2*Pi

Une première version brutale... Maple utilise une méthode que vous comprendrez un peu plus tard (fin d'année)

> minimize(%);

-48*1/(Pi^3)+1/2*Pi

Reprenons cela dans l'esprit des espaces euclidiens...

> scal:=(f,g)->int(f*g,t=0..Pi):

Attention, f et g ne sont pas des fonctions mais des expressions en t

> solve({scal(cos(t)-a0*t-b0,1)=0,scal(cos(t)-a0*t-b0,t)=0});

{a0 = -24*1/(Pi^3), b0 = 12*1/(Pi^2)}

> a0;

a0

> assign(%%);

> a0;

-24*1/(Pi^3)

> int((cos(t)-(a0*t+b0))^2,t=0..Pi);

1/2*(-96+Pi^4)/Pi^3

> expand(%);

-48*1/(Pi^3)+1/2*Pi

OK

> ortho_norm:=proc(e,scal)
local n,f,i,k:
n:=nops(e):f:=e:
for k to n do
for i to k-1 do
f[k]:=evalm(f[k]-scal(e[k],f[i])*f[i]);
od; f[k]:=evalm(f[k]/sqrt(scal(f[k],f[k]))) od:
RETURN(f) end:

Exercice 2

> f1:=vector([1,1,1]):f2:=vector([1,-1,1]):f3:=vector([1,0,0]):

> with(linalg):

> dotprod(f1,f2),dotprod(f1,f3),dotprod(f2,f3);

1, 1, 1

> n:=ortho_norm([f1,f2,f3],dotprod);

n := [vector([1/3*sqrt(3), 1/3*sqrt(3), 1/3*sqrt(3)...

> matrix([seq([seq(dotprod(n[i],n[j]),j=1..3)],i=1..3)]);

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

Exercice 3

> P:=ortho_norm([1,X,X^2,X^3,X^4,X^5],(P,Q)->int(P*Q,X=-1..1));

P := [1/2*sqrt(2), 1/2*X*sqrt(6), 3/4*(X^2-1/3)*sqr...

> Q:=k->expand(diff((X^2-1)^k,X$k));

Q := proc (k) options operator, arrow; expand(diff(...

> seq(Q(i),i=1..5);

2*X, 12*X^2-4, 120*X^3-72*X, 1680*X^4-1440*X^2+144,...

> plot({Q(1),Q(2),Q(3),Q(4)},X=-1..1);

[Maple Plot]

> plot({Q(1),Q(2)},X=-1..1,-10..10);

[Maple Plot]

> plot({Q(6),Q(7)},X=-1..1);

[Maple Plot]

> plot({Q(6),Q(7)},X=-1..1,-50000..50000);

[Maple Plot]

> matrix([seq([seq(int(Q(i)*Q(j),X=-1..1),j=1..3)],i=1..3)]);

matrix([[8/3, 0, 0], [0, 128/5, 0], [0, 0, 4608/7]]...

> for i from 1 to 5 do print(quo(Q(i),P[i+1],X),rem(Q(i),P[i+1],X)) od;

2/3*sqrt(6), 0

8/5*sqrt(10), 0

48/7*sqrt(14), 0

128*sqrt(2), 0

3840/11*sqrt(22), 0

> seq(sqrt(int(Q(i)*Q(i),X=-1..1)),i=1..5);

2/3*sqrt(6), 8/5*sqrt(10), 48/7*sqrt(14), 128*sqrt(...

Tout va bien...

Exercice 5

> g1:=vector([1,1,1,1]):g2:=vector([1,2,3,4]):v:=vector([w,x,y,z]):

(g1,g2) est par définition une base de l'ortohogonal de F

> solve({dotprod(v-a*g1-b*g2,g1)=0,dotprod(v-a*g1-b*g2,g2)=0},{a,b});

{a = w-1/2*z+1/2*x, b = -3/10*w-1/10*x+1/10*y+3/10*...

> assign(%):

> evalm(v-2*a*g1-2*b*g2);

vector([-2/5*w+2/5*z-4/5*x-1/5*y, -4/5*w-1/5*z+2/5*...

> ?genmatrix

The function genmatrix generates the coefficient matrix from the linear system of equations eqns in the unknowns vars. If the optional third argument ``flag'' is present, the ``right-hand side'' vector will be included as the last column of the matrix. Otherwise an optional third argument will be assigned the ``right-hand side'' vector.

> genmatrix(convert(%,list),[w,x,y,z]);

matrix([[-2/5, -4/5, -1/5, 2/5], [-4/5, 2/5, -2/5, ...

> trace(%);

0

Normal...

Exercice 6

> f0:=vector([1,-2,1]):v:=vector([x,y,z]):

> solve(dotprod(v-a*f0,f0)=0,{a});

{a = 1/6*x-1/3*y+1/6*z}

> assign(%):

> evalm(v-2*a*f0);

vector([2/3*x+2/3*y-1/3*z, -1/3*y+2/3*x+2/3*z, 2/3*...

> genmatrix(convert(%,list),[x,y,z]);

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

> trace(%);

1

OK...

Exercice 7

> f0:=vector([1,0,1,0]):v:=vector([w,x,y,z]):

f0 dirige l'orthogonal de H

> solve(dotprod(v-a*f0,f0)=0,{a});

{a = 1/2*w+1/2*y}

> assign(%):

> evalm(2*a*f0-v);

vector([y, -x, w, -z])

> genmatrix(convert(%,list),[w,x,y,z]);

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

> trace(%);

-2