% inte06.m
% fd, 04 octobre 2008, 04 mars 2025  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
printf("calcul d une troisieme integrale singuliere\n");
function  A=ff(x);   A = 1/sqrt(x+x**4+x**6) ;   endfunction 
function  A=gg(x);   A = 1/sqrt(x) - .5 * sqrt(x)* x**2 ;   endfunction 
function  A=g1(x);   A = ff(x) - gg(x) ;   endfunction 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear  ; format long



n = 100 ; dx = 1 / n ; 

xmin = 10**(-2.5) ; 
for j=1:n  ; 
yy(j) = j*xmin ; uu(j) = ff(yy(j)) ; 
vv(j) = -2 * (ff(yy(j)) - gg(yy(j))) / ( sqrt(yy(j)) * yy(j)**4)  ; 
ww(j) = -2*g1 (yy(j))  / ( sqrt(yy(j)) * yy(j)**4)  ;  end 

% plot ( yy , uu  , '*b;;' ,  yy , vv , '@r;;' ) ;  pause
% plot ( yy , vv , '@r;;' ) ;  pause
  plot ( yy , ww , '@r;fonction d erreur;' ) ;
title ('composante reguliere d une fonction singuliere') ; 
print('06-graphe-fonction-ecart', '-djpg','-S891,630'); 


jjmax = 4
for jj = 1:jjmax 						 

if jj==1 ; n = 10 , end 
if jj==2 ; n = 100 , end 
if jj==3 ; n = 1000 , end 
if jj==4 ; n = 10000 , end 

%%% n = 500  ,
dx = 1 / n ; 

xx = zeros(n+1,1) ;
for j=1:n+1 ;  xx(j) = (j-1) * dx  ; end 


 
%                                                    trapezes  
zi4 = 2 - 1/7   ; 
zi4 = zi4 + dx * ( g1(xx(n+1))  )  / 2    ; 
for j=2:n ;  
zi4 = zi4 + dx * g1(xx(j)) ; % zi4  
end  
%                                                     Simpson 
zi5 = 2 - 1/7   ; 
zi5 = zi5 +  dx * ( g1(xx(n+1)) ) / 6    ; 
for j=2:n ;   zi5 = zi5 + dx * g1(xx(j)) / 3 ; end  
for j=1:n ;   
xxx = (xx(j)+xx(j+1))/2 ; 
zi5 = zi5 + 2 * dx * g1(xxx) / 3 ; end  


printf("trapezes "); zi4   
printf("Simpson  "); zi5

end 





