Search code examples
rounding-error

Round-off error detected, the requested tolerance (or default) cannot be achieved. Try using bigger tolerances in SCILAB


I am using integrate command but the scilab is showing me round off error detected and saying me to use high tolerance value which i have no clue.

a=4
b1=1
b2=3
N=6
v=-50
for n=1:N
    h(n,n)=n^2+(v/a)*integrate('1-cos(2*n*%pi*(r/a))','r',b1,b2)
    for m=n+1:N
        h(m,n)=(v/a)*integrate('(cos((m-n)*%pi*(r/a))-cos((m+n)*%pi*(r/a)))','r',b1,b2)
        h(n,m)=h(m,n)
    end
end

[al,bl,R]=spec(h,s);
el=al./bl;
e=R;
[el,k]=gsort(el)
disp(h);
disp(el)

Solution

  • The default absolute tolerance of integrate may be too stringent in some cases. Below I changed it to 1e-13 in last argument of integrate at line 9 of your script, which now runs fine (I also added the definition of matrix s which I supposed to be the identity matrix, like in your previous message):

    a=4
    b1=1
    b2=3
    N=6
    v=-50
    for n=1:N
        h(n,n)=n^2+(v/a)*integrate('1-cos(2*n*%pi*(r/a))','r',b1,b2)
        for m=n+1:N
            h(m,n)=(v/a)*integrate('(cos((m-n)*%pi*(r/a))-cos((m+n)*%pi*(r/a)))','r',b1,b2,1e-13)
            h(n,m)=h(m,n)
        end
    end
    
    s=eye(N,N);
    [al,bl,R]=spec(h,s);
    el=al./bl;
    e=R;
    [el,k]=gsort(el)
    disp(h);
    disp(el)