MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Gradient in FindMinimum

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

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

Assuming your function 

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?
  • Previous by thread: Gradient in FindMinimum
  • Next by thread: Fast (compiled) routine for element testing and replacement in large matrices?