• To: mathgroup at smc.vnet.net
• Subject: [mg24006] Gradient in FindMininum
• From: "Johannes Ludsteck" <ludsteck at zew.de>
• Date: Tue, 20 Jun 2000 03:07:26 -0400 (EDT)
• Organization: Zentr. f. Europ. Wirtschaftsforsch
• Sender: owner-wri-mathgroup at wolfram.com

```Dear MathGroup Members,
Unfortunately I got no answer when I sent the question below last
week to the mathgroup mailing list. Since I think that the problem
is not a very special one but a general problem of the way how
Mathematica treats numerical integrals in the computation of
I want to minimize a complicated function which contains
numerical integrals. Since the function is too complicated for a
direct demonstration, I give a simple example which makes the
structure of the problem clear:

The (example) function to be minimized is:
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:

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: Re: Fast (compiled) routine for element testing and replacement in large matrices?
• Next by Date: Re: Newbie question: pairswise function application
• Previous by thread: Re: imposing side conditions on Solve