title: Maximum Function Count Exceeded
body: <p>trying to use the following code to evaluate a triple integral which is a function of q,u. getting the error,</p>
  
  <pre><code>Warning: Maximum function count exceeded; singularity likely. 
  In quad at 107
  In test1&gt;Inner at 12
  In test1&gt;@(x)Inner(x) at 5
  In quad at 76
  In test1 at 5
  </code></pre>
  
  <p>Does anyone know what's wrong with this code?</p>
  
  <pre><code>function [r] = test1(q,u)
  b = u;
  r = zeros(1);
  for i = 1 : length(q);
      r(i) = quad(@(x)Inner(x),-2,q);
  end;
  
  
  function [w] = Inner(k)
  w = zeros(1);
  for i = 1 : length(k);
      w(i) = quad(@(n)InnerIntegral(n).*unifpdf(k(i)-n,-1,1),0,k(i)-1,k(i)+1);
  end;
  
  
  
  function [y] = InnerIntegral(n)
  y = zeros(1);
  for i = 1 : length(n);
      y(i) = quad(@(m)unifpdf(n(i)-m, -b, b).*unifpdf(m,-b,b), n(i)-b,n(i)+b);
  end;
  end
  end
  end
  </code></pre>