clear all
close all
a=-pi/3;b=pi/4;nq=100;

q=ep00.mesh1D(a,b,nq)'; % x vecteur colonne

K=ep00.Rigidite(q);
%%%%%%%%%%%%%%
% Test 1
u=@(x) cos(x); v=@(x) 1+0*x;
Iex=0; % integrale exacte 
U=u(q);V=v(q);
I=dot(K*U,V);
fprintf('Test 1 [u=%s,v=%s]: erreur : %.5e\n',char(u),char(v),abs(I-Iex))
%%%%%%%%%%%%%%
% Test 2
u=@(x) 2*x-3; v=@(x) x+3/5; %sage: var('x');u(x)=2*x-3;v(x)=x+3/5;integrate(diff(u(x),x)*diff(v(x),x),(x,-pi/3,pi/4))
Iex=7/6*pi;
U=u(q);V=v(q);
I=dot(K*U,V);
fprintf('Test 2 [u=%s,v=%s]: erreur : %.5e\n',char(u),char(v),abs(I-Iex))
%%%%%%%%%%%%%%
% Test 3
u=@(x) 5*x.^2-7*x-3; v=@(x) x.^2+3/5; %sage: var('x');u(x)=5*x**2-7*x-3;v(x)=x**2+3/5;integrate(diff(u(x),x)*diff(v(x),x),(x,-pi/3,pi/4))
Iex=455/1296*pi^3 + 49/144*pi^2;
U=u(q);V=v(q);
I=dot(K*U,V);
fprintf('Test 3 [u=%s,v=%s]: erreur : %.5e\n',char(u),char(v),abs(I-Iex))
%%%%%%%%%%%%%%
% Test 4
u=@(x) cos(x); v=@(x) sin(x); %sage: var('x');u(x)=cos(x);v(x)=sin(x);integrate(diff(u(x),x)*diff(v(x),x),(x,-pi/3,pi/4))
Iex=1/8; % integrale exacte de u'*v'
U=u(q);V=v(q);
I=dot(K*U,V);
fprintf('Test 4 [u=%s,v=%s]: erreur : %.5e\n',char(u),char(v),abs(I-Iex))
%%%%%%%%%%%%%%
