title: Maximizing a function in Matlab (use of fsolve and derivatives)
body: <p>I would like to find the values for vector <code>p</code> (i.e <code>p(1),p(2),p(3),...</code>) which maximizes the function <code>A(p)</code>.  </p>
  
  <p>I am using MATLAB to do that and I found <code>fsolve</code> which I thought it could help me. So I made function <code>A</code>: </p>
  
  <pre><code>function A = myfun(p)
  
      R  = 0.1; 
      u1 = 500;
      u2 = 400;
      u3 = 300;
  
      A = ( (p(1)+p(2)+p(3)) * (1/u1+1/u2+1/u3)) * ...
          (1 + R*(p(1)^2+p(2)^2+p(3)^2) * (1/u1+1/u2+1/u3) );
  </code></pre>
  
  <p>And then I need to solve a system of equations which will be:</p>
  
  <pre><code>diff(A,p(1))==0
  
  diff(A,p(2))==0
  
  diff(A,p(3))==0
  </code></pre>
  
  <p>where the resulting <code>p</code> vector will be the solution to my problem. </p>
  
  <p>How could <code>fsolve</code> solve this system of equations (<code>p0=[1 1 1]</code>) ?</p>