• To: mathgroup at smc.vnet.net
• Subject: [mg23905] Gradient in FindMinimum
• From: "Johannes Ludsteck" <ludsteck at zew.de>
• Date: Fri, 16 Jun 2000 00:56:47 -0400 (EDT)
• Organization: Zentr. f. Europ. Wirtschaftsforsch
• Sender: owner-wri-mathgroup at wolfram.com

```Dear MathGroup Members,
I want to minimize a complicated function which contains
numerical integrals. Since the function is really complicated, I give
a simple example which captures the structure of the problem:

f[x_] := NIntegrate[g[t], {t, -Infinity, x}]

(g is a known function; however symbolical integration is
impossible).

When I request numerical minimization of this function by typing

FindMinimum[f[x],{x,1}]

Mathematica gives me the following error message:

FindMinimum::fmgl: Gradient {Indeterminate} is not a length 1
list of real numbers at {x} = {1.}.

Appearently, Mathematica is not able to find the gradient
symbolically. A simple solution would be to define f using Integrate
(without prefix N) and to wrap it with N[ ]:

f[x_]:= N[  Integrate[g[t], {t,-Infinity, x}] ]

However, since the function contains some hundred terms,
evaluation of the function takes several minutes. (Mathematica then
tries to find the integral symbolically before applying the numerical
integration procedure.) This makes optimization impracticable.
(the function I want to optimize has about 40 variables!).

Are there any suggestions how to avoid computation of the gradient
manually? (minimization algorithms which don't use the gradient
are impracticable.)
I.e. how can I tell Mathematica to use the first definition

f[x_] := NIntegrate[g[t], {t, -Infinity, x}]

for evaluation of the function and the second

f[x_]:= N[ Integrate[g[t], {t,-Infinity, x}] ]

for the computation of the gradient.

Thank you

P.S If you want to reproduce the error message, you can use a
simple definition, for example

f[x_]:= x^2 + NIntegrate[ Exp[-t^2], {t, -Infinity, x} ].

Johannes Ludsteck
Centre for European Economic Research (ZEW)
Department of Labour Economics,
Human Resources and Social Policy
Phone (+49)(0)621/1235-157
Fax (+49)(0)621/1235-225

P.O.Box 103443
D-68034 Mannheim
GERMANY

Email: ludsteck at zew.de

```

• Prev by Date: RE: rounding off numbers
• Next by Date: Fast (compiled) routine for element testing and replacement in large matrices?