clear all; close all;
%------------------------ demo_IRQ -------------------------------
% This script returns the IRQ error, the exact integral end its
% approximation with IRQ method on [-5,5].
% 
% Functions called: gauss_jacobi_integration_I, weights, IRQ
%  ---------------------------------------------------------------
% Authors: 
%      Stefano De Marchi and Cinzia Bandiziol
%      Department of Pure and Applied Math.
%      University of Padova
%           
% Version: May 2015		
%  ----------------------------------------------------------------	
a=-5;
b=5;
d=3;
Err_vect=ones(16,1);
n=21;
%f=inline('abs(x)','x');
f=inline('1./(1+x.^(2))','x');
%f=inline('sin(x)','x');

[Int_exact]=gauss_jacobi_integration_I(2000,0,0,a,b,f);

x=linspace(a,b,n)';% equidistant nodes
y=feval(f,x);
w_fh=weights(d,x);
Int_IRQ=IRQ(w_fh,x,f);
Err=abs(Int_exact-Int_IRQ);

fprintf('Exact Integral: %f\nIRQ_Integral: %f\nIRQ_Error: %f\n',Int_exact,Int_IRQ,Err);