title: Matlab function gradient for fminunc
body: <pre><code>f = @(w) sum(log(1 + exp(-t .* (phis * w'))))/size(phis, 1) + coef * w*w';
  options = optimset('Display', 'notify', 'MaxFunEvals', 2e+6, 'MaxIter', 2e+6);
  w = fminunc(f, ones(1, size(phis, 2)), options);
  </code></pre>
  
  <ul>
  <li><strong>phis</strong> size is NxN+1</li>
  <li><strong>t</strong> size is Nx1</li>
  <li><strong>coef</strong> is const</li>
  </ul>
  
  <p>I'm trying to minimize function <em>f</em>, firstly I was using <strong>fminsearch</strong> but it works long time, that's why now I use <strong>fminunc</strong>, but there is one problem: I need function gradient for acceleration. Can you help me please construct gradient for function <em>f</em>, coz I always get this warning:</p>
  
  <pre><code>Warning: Gradient must be provided for trust-region algorithm;
    using line-search algorithm instead.
  </code></pre>