% inter5.m
% fd, iacs, juin, 08 juillet, 04, 26  septembre  2004, 08 janvier 2006
% fd, 29 juin 2026
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
clear , format long
   
printf("inter5 ; interpolation de Hermite  \n"); 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

printf("\n");

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% title ('Cnam Paris. Travaux pratiques Iacs.') ;
xlabel (' inter2. Interpolation entre des donnees discretes  ') ;
%  interpolation affine
u0=zeros( 2, 1) ; u0(1)=0;  u0(2)=1; 
x =zeros(2 , 1) ; x(1)=0;  x(2)=1; 
% gset yrange[-0.5:1.6] ; gset xrange[-0.1: 1.1] ; hold off ;

hold off ; 
plot(x,u0(:,1),"*;;",x,u0(:,1),"b;;") ;
axis ( [ -.05 , 1.05 , -.5 , 1.6 ]) ;
title ('interpolation affine') ;
print('05-a-diverses-interpolations-de-hermite', '-djpg','-S891,630')  
pause (.5) 

%
d0=zeros(2,1) ; 
d0(1)=-2;  d0(2)=1; 
%  seconde grille plus fine
nn=22 ; dy=1/nn ; 
[chnn,msg] = sprintf ('Interpolation cubique. Nombre de points pour l affichage : %3i',nn);
titx = [chnn] ; 
xx =zeros(nn+1,1); yy=zeros(nn+1,1);
uu1 =zeros(nn+1,1); uu2 =zeros(nn+1,1); uu3 =zeros(nn+1,1); uu4 =zeros(nn+1,1);
for i=1:nn+1;
xx(i) = (i-1) * dy ;  
uu1(i) = (1+2*xx(i))*(xx(i)-1)*(xx(i)-1) ; 
uu2(i) = (3-2*xx(i))*xx(i)*xx(i)  ;  
uu3(i) =  xx(i)*(xx(i)-1)*(xx(i)-1)  ; 
uu4(i) =  xx(i)*xx(i)*(xx(i)-1)  ;  end ; 
%   variation des pentes aux extremites
d0=zeros(2, 1) ; 
for j=1:4 ;  
if j<=1 ;    d0(1)=2;  d0(2)=2; end ;
if j>=2 ;   d0(1)=-2;  d0(2)=1; end ; 
if j>=3 ;   d0(1)=0;  d0(2)=7; end ; 
if j>=4 ;   d0(1)=7;  d0(2)=0; end ; 
for i=1:nn+1;
yy(i)=u0(1)*uu1(i) + u0(2)*uu2(i) +  d0(1)*uu3(i) + d0(2)*uu4(i) ; end;
%xlabel ( titx ) ;


hold on
% plot(x,u1,"*;donnees;",xx,uu1,"b;interpolation par spline cubique;", \
%     x,u2,"o;;",xx,uu2,"g;;", x,u3,"+;;",xx,uu3,"r;;", x,u4,"x;;",xx,uu4,"c;;")

  if (j==1) ; plot(xx,yy,"r;;") ;
title ('premiere possibilite pour les derivees aux extremites') ;
print('05-b-diverses-interpolations-de-hermite', '-djpg','-S891,630')  
pause (.5) ; end 

if (j==2) ; plot(xx,yy,"g;;") ;
title ('seconde possibilite pour les derivees aux extremites') ;
print('05-c-diverses-interpolations-de-hermite', '-djpg','-S891,630')  
pause (.5) ; end 

if (j==3) ; plot(xx,yy,"c;;") ;
title ('troisieme possibilite pour les derivees aux extremites') ;
print('05-d-diverses-interpolations-de-hermite', '-djpg','-S891,630')  
pause (.5) ; end 

if (j==4) ; plot(xx,yy,"b;;") ;
title ('et ainsi de suite...') ;
print('05-e-diverses-interpolations-de-hermite', '-djpg','-S891,630')  
end

end 




