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);
Une première version brutale... Maple utilise une méthode que vous comprendrez un peu plus tard (fin d'année)
> minimize(%);
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;
> assign(%%);
> a0;
> int((cos(t)-(a0*t+b0))^2,t=0..Pi);
> expand(%);
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);
> n:=ortho_norm([f1,f2,f3],dotprod);
> matrix([seq([seq(dotprod(n[i],n[j]),j=1..3)],i=1..3)]);
Exercice 3
> P:=ortho_norm([1,X,X^2,X^3,X^4,X^5],(P,Q)->int(P*Q,X=-1..1));
> Q:=k->expand(diff((X^2-1)^k,X$k));
> seq(Q(i),i=1..5);
> plot({Q(1),Q(2),Q(3),Q(4)},X=-1..1);
> plot({Q(1),Q(2)},X=-1..1,-10..10);
> plot({Q(6),Q(7)},X=-1..1);
> plot({Q(6),Q(7)},X=-1..1,-50000..50000);
> matrix([seq([seq(int(Q(i)*Q(j),X=-1..1),j=1..3)],i=1..3)]);
> for i from 1 to 5 do print(quo(Q(i),P[i+1],X),rem(Q(i),P[i+1],X)) od;
> seq(sqrt(int(Q(i)*Q(i),X=-1..1)),i=1..5);
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});
> assign(%):
> evalm(v-2*a*g1-2*b*g2);
> ?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]);
> trace(%);
Normal...
Exercice 6
> f0:=vector([1,-2,1]):v:=vector([x,y,z]):
> solve(dotprod(v-a*f0,f0)=0,{a});
> assign(%):
> evalm(v-2*a*f0);
> genmatrix(convert(%,list),[x,y,z]);
> trace(%);
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});
> assign(%):
> evalm(2*a*f0-v);
> genmatrix(convert(%,list),[w,x,y,z]);
> trace(%);