title: Scilab round-off error
body: <p>I cannot solve a problem in Scilab because it get stucked because of round-off errors. I get the message </p>
  
  <pre><code>!--error 9999 
  Error: Round-off error detected, the requested tolerance (or default) cannot be achieved. Try using bigger tolerances.
  at line       2 of function scalpol called by :  
  at line       7 of function gram_schmidt_pol called by :  
  gram_schmidt_pol(a,-1/2,-1/2)
  </code></pre>
  
  <p>It's a Gram Schmidt process with the integral of the product of two functions and a weight as the scalar product, between -1 and 1.
  <code>gram_schmidt_pol</code> is the process specially designed for polynome, and <code>scalpol</code> is the scalar product described for polynome.</p>
  
  <p>The <code>a</code> and <code>b</code> are parameters for the weigth, which is <code>(1+x)^a*(1-x)^b</code></p>
  
  <p>The entry is a matrix representing a set of vectors, it works well with the matrix <code>[[1;2;3],[4;5;6],[7;8;9]]</code>, but it fails with the above message error on matrix <code>eye(2,2)</code>, in addition to this, I need to do it on eye(9,9) !</p>
  
  <p>I have looked for a "tolerance setting" in the menus, there is some in <code>General-&gt;Preferences-&gt;Xcos-&gt;Simulation</code> but I believe this is not for what I wan't, I have tried low settings (high tolerance) in it and it hasn't change anything.</p>
  
  <p>So how can I solve this rounf-off problem ?</p>
  
  <p>Feel free to tell me my message lacks of clearness.
  Thank you.</p>
  
  <p><em>Edit</em>: Code of the functions :</p>
  
  <pre><code>// function that evaluate a polynomial (vector of coefficients) in x
  function [y] = pol(p, x) 
      y = 0
      for i=1:length(p)
          y = y + p(i)*x^(i-1)
      end
  endfunction
  
  // weight function evaluated in x, parametrized by a and b
  // (poids = weight in french)
  function [y] = poids(x, a, b)
      y = (1-x)^a*(1+x)^b
  endfunction
  
  // scalpol compute scalar product between polynomial p1 and p2
  // using integrate, the weight and the pol functions.
  function [s] = scalpol(p1, p2, a, b)
      s = integrate('poids(x,a, b)*pol(p1,x)*pol(p2,x)', 'x', -1, 1)
  endfunction
  
  // norm associated to scalpol
  function [y] = normscalpol(f, a, b)
      y = sqrt(scalpol(f, f, a, b))
  endfunction
  
  // finally the gram schmidt process on a family of polynome
  // represented by a matrix
  function [o] = gram_schmidt_pol(m, a, b)
      [n,p] = size(m)
      o(1:n) = m(1:n,1)/(normscalpol(m(1:n,1), a, b))
      for k = 2:p
          s =0 
          for i = 1:(k-1)
              s = s + (scalpol(o(1:n,i), m(1:n,k), a, b) / scalpol(o(1:n,i),o(1:n,i), a, b) .* o(1:n,i))
          end
          o(1:n,k) = m(1:n,k) - s
          o(1:n,k) = o(1:n,k) ./ normscalpol(o(1:n,k), a, b)
      end
  endfunction
  </code></pre>