title: segmentation violation - stopping myself in Octave
body: <p>I have the following code in Octave to try to implement adaptive quadrature using Simpson's method:</p>
  
  <pre><code>function integral = adaptive2(f, a, b, TOL, count)
  max_count = 20;
  disp("hello world");
  disp(count);
  h = (b-a)/2;
  x_1 = a;
  x_2 = (b-a)/2;
  x_3 = b;
  
  w_0 = a;
  w_1 = (b-a)/4;
  w_2 = (b-a)/2;
  w_3 = 3*(b-a)/4;
  w_4 = b;
  
  
  initial_1 = (f(x_1) + 4*f(x_2) + f(x_3));
  i1 = (h/3) * initial_1;
  
  initial_2 = (f(w_0) + 4*f(w_1) + 2*f(w_2) + 4*f(w_3) + f(w_4));
  i2 = (h/6) * initial_2;
  disp(i1);
  disp(i2);
  if count == max_count
      integral = i2;
      return;
  endif
  if abs(i1 - i2) &lt; (10 * TOL)
      integral = i2;
      return;
  endif
  
  count = count + 1;
  disp(count);
  disp(TOL);
  integral = (adaptive2(f, a, (b+a)/2, TOL/2, count) + adaptive2(f, (b+a)/2,     b, TOL/2, count));
  return;
  </code></pre>
  
  <p>With the paramaters:</p>
  
  <pre><code>f = @(x) 1/sqrt(x)
  a = 10^-4
  b = 1
  TOL = 10^-6
  count = 0
  </code></pre>
  
  <p>And I get the following error:</p>
  
  <pre><code>panic segmentation violation - stopping myself 
  </code></pre>
  
  <p>What's occurring in this code that I need to fix? Is it an infinite loop? Are the recursion calls at the end improper?</p>