title: Basic questions about scilab
body: <p>I am taking a numeric calculus class and we are not required to know any scilab programming except the very basic, which is taught through a booklet, since the class is mostly theoretical. I was reading the booklet and found this scilab code meant to find a root of a function through bissection method. 
  The problem is, I can't find a way to make it work. I tried to call it with <code>bissecao(x,-1,1,0.1,40)</code> however it didn't work.
  The error I got was: </p>
  
  <pre><code>at line     3 of function bissecao ( E:\Downloads\bisseccao3.sce line 3 )
  
  Invalid index.
  </code></pre>
  
  <p>As I highly doubt that the code itself isn't working, and I tried to search for anything I could spot that seemed wrong, to no avail, I guess I am probably calling it wrong, somehow. </p>
  
  <p>The code is the following:</p>
  
  <pre><code>function p = bissecao(f, a, b, TOL, N)
  i = 1
  fa = f(a)
  while (i &lt;= N)
    //iteraction of the bissection
    p = a + (b-a)/2
    fp = f(p)
    //stop condition
    if ((fp == 0) | ((b-a)/2 &lt; TOL)) then
      return p
      end
    //bissects the interval
    i = i+1
    if (fa * fp &gt; 0) then
      a = p
      fa = fp
      else
      b = p
      end
    end
  error ('Max number iter. exceded!')
  endfunction
  </code></pre>
  
  <p>Where f is a function(I guess), a and b are the limits of the interval in which we will be iterating, TOL is the tolerance at which the program terminates close to a zero, and N is the maximum number of iteractions.</p>
  
  <p>Any help on how to make this run is greatly appreciated.</p>