title: Getting more details from optim function from R
body: <p>I'm not very familiar with the optim function, and I wanted to get these informations from its results: a) how many iterations were needed for achieving the result? and b) to plot the sequence of partial solutions, that is, the solution obtained in the end of each iteration.</p>
  
  <p>My code until now looks like this:</p>
  
  <pre><code>  f1 &lt;- function(x) {
    x1 &lt;- x[1]
    x2 &lt;- x[2]
    x1^2 + 3*x2^2
  }
  
  res &lt;- optim(c(1,1), f1, method="CG")
  </code></pre>
  
  <p>How can I improve it to get further information?</p>
  
  <p>Thanks in advance</p>