• To: mathgroup at smc.vnet.net
• Subject: [mg24144] Re: Gradient in FindMinimum
• From: Robert Knapp <rknapp at wolfram.com>
• Date: Wed, 28 Jun 2000 02:11:59 -0400 (EDT)
• Organization: Wolfram Research, Inc.
• References: <8icaf9\$99c@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Johannes Ludsteck wrote:
>
> 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.
>

You can specify a function for the Gradient using the Gradient option to
FindMinimum.

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

is not too special, and you can differentiate inside the integral, you
could use

Another way to do it is using finite differences.  Right now this
requires that you define a function to give to the Gradient option which
approximates is using finite differences.  We are working on code which
will make this automatic in a future version of Mathematica.

Rob Knapp
Wolfram Research, Inc.

```

• Prev by Date: Re: How to operate on strictly numerical functions ?
• Next by Date: Re: Conditionals with multiple tests?