Re: Problems to find the local extrema of an InterpolatingFunction

• To: mathgroup at smc.vnet.net
• Subject: [mg87927] Re: Problems to find the local extrema of an InterpolatingFunction
• From: Szabolcs Horvát <szhorvat at gmail.com>
• Date: Sat, 19 Apr 2008 23:54:30 -0400 (EDT)
• Organization: University of Bergen
• References: <fuc7qh\$a0q\$1@smc.vnet.net>

```Modeler wrote:
> Hi,
>
> does anyone know how to find all the local extrema of an InterpolatingFunction in a specified interval? The only
> thing that seems to work is Findroot, but it only finds a single root each time. Other rootfinding commands do not seem to work. Thanks for your help.
>

I would feel uncomfortable using FindMinimum on InterpolatingFunction
objects because (when constructed with Interpolation) the derivative of
an InterpolatingFunction is usually not continuous.

f = Interpolation[{1, 3, 7, 4, 2}]
Plot[{f[x], f'[x]}, {x, 1, 5}]

If the InterpolatingFunction was returned by NDSolve, or the values of
the derivative were supplied to Interpolation, then the derivative will
be usually continuous.

If you have the raw data points, I would suggest working with them
directly, or at least using them to find the two data points that
surround the extremum, and using the FindMinimum[f, {x, x0, xmin, xmax}]
syntax to search for the mimimum in a restricted region.

Here's a tutorial on extracting data points from InterpolatingFunctions
returned by NDSolve:

tutorial/NDSolvePackages#120436095
http://reference.wolfram.com/mathematica/tutorial/NDSolvePackages.html

And some simple ways for finding zero crossings or local minima in
discrete data:

data = Table[Sin[x], {x, 0, 5, .2}]

Select[Partition[data, 2, 1], NonPositive[Times @@ #] &]

minPoint[{a_, b_, c_}] := b <= a && b <= c

Select[Partition[data, 3, 1], minPoint]

Ways to construct numerical derivatives from discrete data:

Differences[data]

ListConvolve[{1, -1}, data]

ListConvolve[{1, 0, -1}, data]/2

This should be enough to get you started.

```

• Prev by Date: Fw: Re: DifferenitalD vs CapitalDifferenitalD
• Next by Date: Polygon cutter
• Previous by thread: Re: Problems to find the local extrema of an InterpolatingFunction
• Next by thread: Re: Problems to find the local extrema of an InterpolatingFunction