cmss Using numerical approximations of the first differential

Sometimes, the minimized function is differentiable, but actually writing down its differential is more work than one would like. Numerical differentiation offers a solution which is less efficient in terms of computation cost, but easy to implement. The "ndiff" option of minimize() uses numerical differentiation to execute exactly the same algorithm as in the previous example. However, because numerical approximation of the differentia is used, the outpud may differ slightly :

[x, v, n] = minimize ("foo", x0, "ndiff")
wich yields :

x =

  1.00000 1.00000 1.00000

v = -3 

n =

  78 6

Note that each time the differential is numerically approximated, foo() is called 6 times (twice per input element), so that foo() is evaluated a total of (78+6*6=) 114 times in this example.



Søren Hauberg 2008-04-29