intg roundoff error with a trivial integral
Reported by Thuy Nguyen
bug.txt (1.33 KB, text/plain)
The code file to produce the bug
BUG DESCRIPTION:
----------------
The function intg encounters a round off error even with high tolerance setting to integrate just sin(x)
ERROR LOG:
----------
intg: Error: Round-off error detected
HOW TO REPRODUCE THE BUG:
-------------------------
The code is:
//******************* PARAMETERS:
npts=100; fdt=2*%pi;
quad=0*ones(npts)'; dt=fdt/npts;
ea=1.0d-5; er=1.0d-3; //errors tolerances.
clf()
//************************************* intg ************
disp('******** SCILAB function intg ********')
numf=null()
function val=numf(t)
val=sin(t);
endfunction
for i=1:npts-1
t=i*dt; quad(i)=intg(0,t,numf,ea,er);
end
plot(quad,'k')
disp(['intg @ npts-1: ',string(quad(npts-1))])
disp(strcat(['we are off 2*pi by ',string(2*%pi-t),' rad']))
disp('=> OK, doing one more step will give the message:')
disp('intg: Error: Round-off error... And yet the setting is:')
//********** NOW troubles with one more step
disp(['Version',' SCILAB 6.0.1';'ea= ',string(ea);'er= ',string(er)])
input("Note the HIGH tolerance. Enter 0 to proceed ")
d=intg(0,npts*dt,numf);
//************************************* NO MORE
OTHER INFORMATION:
------------------
The output:
--> exec('C:\serif\docs\scilab\temp.sce', -1)
******** SCILAB function intg ********
!intg @ npts-1: 0.0019733 !
we are off 2*pi by 0.0628319 rad
=> OK, doing one more step will give the message:
intg: Error: Round-off error... And yet the setting is:
!Version SCILAB 6.0.1 !
! !
!ea= 0.00001 !
! !
!er= 0.001 !
Note the HIGH tolerance. Enter 0 to proceed
at line 36 of executed file C:\serif\docs\scilab\temp.sce
intg: Error: Round-off error detected, the requested tolerance (or default) cannot be achieved. Try using bigger tolerances.