Re: envelope of an oscillatory InterpolatingFunction

*To*: mathgroup at smc.vnet.net*Subject*: [mg49826] Re: envelope of an oscillatory InterpolatingFunction*From*: "Stergios J. Papadakis" <stergios.papadakis at jhuapl.edu>*Date*: Tue, 3 Aug 2004 01:10:58 -0400 (EDT)*Organization*: Johns Hopkins University Applied Physics Lab, Laurel, MD, USA*References*: <cefh67$bs5$1@smc.vnet.net> <cejske$crk$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Paul Abbott wrote: > > Needs["Utilities`FilterOptions`"] > > RootsInRange[fn_, {x_, xmin_, xmax_}, opts___] := > Module[{p, pts, x, f = Function[x, Evaluate[fn]]}, > p = Plot[f[x], {x, xmin, xmax}, Compiled -> False, > Evaluate[FilterOptions[Plot, opts]]]; > pts = Cases[First[p], Line[{x__}] -> x, Infinity]; > pts = Map[First, Select[Split[pts, > Sign[Last[#2]]==-Sign[Last[#1]]&],Length[#1]==2& ],{2}]; > (FindRoot[f[x] == 0, {x, Sequence @@ ##1}, > Evaluate[FilterOptions[ FindRoot, opts]]]&) /@ pts] > > Compute the (absolute) values of the extrema of the > InterpolatingFunction: > > {x, Abs[y[x]]} /. RootsInRange[Evaluate[y'[x] /. nsol],{x,0,50}] /. nsol > Thanks very much! Your RootsInRange is much better than my loop using NMaximize. I do have one final detail to ask about. RootsInRange returns results of the form (where t is my variable): {t$9472 -> 3.3268729370875564`*^-7} Is there a good way to get rid of the $9472, which seems to be some sort of counter. I admit I don't understand the last bit of the RootsInRange function. Right now I am manually getting rid of the $9472 by typing it in. ti = t$9472 optenv = {ti, Last[Abs[opticalz[ti]]]} /. optenvroots, where optenvroots is the result from RootsInRange. Thanks again, Stergios