Re: Problems to find the local extrema of an InterpolatingFunction

• To: mathgroup at smc.vnet.net
• Subject: [mg87918] Re: [mg87876] Problems to find the local extrema of an InterpolatingFunction
• From: Curtis Osterhoudt <cfo at lanl.gov>
• Date: Sat, 19 Apr 2008 23:52:52 -0400 (EDT)
• Organization: LANL
• References: <200804190734.DAA09779@smc.vnet.net>

```My recommendation is to get Ted Ersek's RootSearch package:
http://library.wolfram.com/infocenter/MathSource/4482/ , then use the

In[1]:= Needs["Ersek`RootSearch`"]

In[2]:= interpChirp =
Interpolation[({#1, Cos[14*#1^2]} & ) /@ Range[-3, 3, 0.01]]

Out[2]= InterpolatingFunction[]

In[3]:= Information["RootSearch", LongForm -> False]

RootSearch[lhs==rhs,{x,xmin,xmax}] tries to find all numerical \
solutions
to the equation (lhs==rhs) with values of x between xmin and xmax.

In[4]:= extremaChirpXCoords =
x /. RootSearch[D[interpChirp[x], x] == 0,
{x, -1.5, 3}]

Out[4]= {-1.4980975190701675, -1.4210097731164544, \
-1.3399599968757765,
-1.253270595111517, -1.1602567136610211, -1.0593077704612488,
-0.9474492610932443, -0.8204437093590906, -0.6699513826802013,
-0.47370362211238165, -0.004342581524651825, 0.00434258152465195,
0.47370362211238176, 0.6699513826802013, 0.8204437093590906,
0.9474492610932445, 1.0593077704612488, 1.160256713661021,
1.253270595111517, 1.3399599968757765, 1.4210097731164542,
1.4980975190701675, 1.5709720363954214, 1.6408167527739237,
1.7081100377259189, 1.77232629554058, 1.8346443273739474,
1.8948220414420387, 1.9530325395646555, 2.064834351176493,
2.1187158019428436, 2.170525249075549, 2.2216511458569324,
2.2715727275276505, 2.320364713016632, 2.3688300115369434,
2.4154912450988784, 2.4611399058587113, 2.5067974734662237,
2.550625271059587, 2.5945599123892618, 2.6377710949526834,
2.7208407543330613, 2.7618276779035154, 2.8021763434663263,
2.84189467724394, 2.8810163395212918, 2.958738929626501,
2.996047283696872}

In[5]:= extremaChirpYCoords = interpChirp[extremaChirpXCoords]

Out[5]= {0.9995783376727462, -0.9997913995697288, 0.9999851022756102, \

-0.9996907441468013, 0.9999722045939012, -0.9999572984982811,
0.9999164611721563, -0.9999891795306132, 0.9999994140183288,
-0.9999936451427361, 1.0000005058258696, 1.0000005058258696,
-0.999993645142736, 0.9999994140183288, -0.9999891795306133,
0.9999164611721564, -0.9999572984982811, 0.9999722045939011,
-0.9996907441468013, 0.9999851022756102, -0.9997913995697286,
0.9995783376727462, -0.9996970548912986, 0.9996880319837047,
-0.9992890387882577, 0.9990115892238276, -0.9984100861603418,
0.9981875824885136, -0.9982748925101684, -0.9974550471242827,
0.9987552561687699, -0.9992978970579964, 0.9981128527753262,
-0.998012320054932, 0.9992740115186692, -0.998176511269883,
0.9953339150930023, -0.9978553098199383, 0.9952867875140399,
-0.9984119813872546, 0.9937952104558903, -0.9954141530293343,
-0.9974161404829311, 0.9951318944149817, -0.9941722992470973,
0.9944011576893499, -0.9962360609385842, -0.9951865800641378,
1.0138341847377665}

In[6]:= Show[
ListPlot[Transpose[{extremaChirpXCoords, extremaChirpYCoords}]],
Plot[interpChirp[x], {x, -3, 3}]]

Hope that helps!
C.O.

On Saturday 19 April 2008 01:34:08 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.

--
==========================================================
Curtis Osterhoudt
cfo at remove_this.lanl.and_this.gov
PGP Key ID: 0x4DCA2A10
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
==========================================================

```

• Prev by Date: Re: Re: A kernel, multiple notebooks, and Global?
• Next by Date: Re: Mathematica syntax
• 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