Introduction to Unconstrained Optimization - Scilab
Introduction to Unconstrained Optimization - Scilab
Introduction to Unconstrained Optimization - Scilab
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
derivative<br />
numerical derivatives of a function.<br />
Manages arbitrary step size.<br />
Provides order 1, 2 or 4 finite difference formula.<br />
Computes Jacobian and Hessian matrices.<br />
Manages additionnal arguments of the function <strong>to</strong> derivate.<br />
Produces various shapes of the output matrices.<br />
Manages orthogonal basis change Q.<br />
Figure 2: The derivative function.<br />
when we develop an objective function and is derivatives. In order <strong>to</strong> help ourselves,<br />
we can use the function values which were given previously. In the following session,<br />
we check that our implementation of Rosenbrock’s function satisfies f(x 0 ) = 24.2<br />
and f(x ⋆ ) = 0.<br />
-->x0 = [ -1.2 1.0] ’<br />
x0 =<br />
- 1.2<br />
1.<br />
-->f0 = rosenbrock ( x0 )<br />
f0 =<br />
24.2<br />
--> xopt = [1.0 1.0] ’<br />
xopt =<br />
1.<br />
1.<br />
--> fopt = rosenbrock ( xopt )<br />
fopt =<br />
0.<br />
Notice that we define the initial and final points x0 and xopt as column vec<strong>to</strong>rs<br />
(as opposed <strong>to</strong> row vec<strong>to</strong>rs). Indeed, this is the natural orientation for <strong>Scilab</strong>, since<br />
this is in that order that <strong>Scilab</strong> s<strong>to</strong>res the values internally (because <strong>Scilab</strong> was<br />
primarily developped so that it can access <strong>to</strong> the Fortran routines of Lapack). Hence,<br />
we will be consistently use that particular orientation in this document. In practice,<br />
this allows <strong>to</strong> avoid orientation problems and related bugs.<br />
We must now check that the derivatives are correctly implemented in our rosenbrock<br />
function. To do so, we may use a symbolic computation system, such as Maple<br />
[10], Mathematica [11] or Maxima [1]. An effective way of computing a symbolic<br />
derivative is <strong>to</strong> use the web <strong>to</strong>ol Wolfram Alpha [12], which can be convenient in<br />
simple cases.<br />
Another form of cross-checking can be done by computing numerical derivatives<br />
and checking against the derivatives computed by the rosenbrock function. <strong>Scilab</strong><br />
provides one function for that purpose, the derivative function, which is presented<br />
in figure 2. For most practical uses, the derivative function is extremely versatile,<br />
and this is why we will use it thoughout this document.<br />
In the following session, we check our exact derivatives against the numerical<br />
derivatives produced by the derivative function. We can see that the results are<br />
very close <strong>to</strong> each other, in terms of relative error.<br />
8