Re: Inverse of Interpolating Function?

*To*: mathgroup at smc.vnet.net*Subject*: [mg120407] Re: Inverse of Interpolating Function?*From*: Daniel Lichtblau <danl at wolfram.com>*Date*: Thu, 21 Jul 2011 21:06:11 -0400 (EDT)*References*: <201107201031.GAA24058@smc.vnet.net>

On 07/20/2011 05:31 AM, gonzorascal wrote: > Hello All, > > I am working with an Interpolating Function of an oscillating solution (time series) to a differential equation. I am trying to find the period and pulse width of the oscillation. To do this I would like to have an inverse of my function y[t] (so I would have t[y]). I realize this function would be multivalued (that's what I want to find the period). I am not having success using Mathematica's InverseFunction[] or Reduce[] commands. Does anyone have any experience or suggestions with this sort of thing (either finding Inverse Interpolating Functions or another method for period and pulse width)? Thank you. > > -GR > Here is an approach that might be suitable, at least if you can sample from a fairly large number of periods. (1) Sample your function in equal intervals. (2) Take the Fourier transform. (3) Find the largest frequency, not counting the first (DC) component. (4) ue that to estimate the period. Here is an example. We'll use a reference function that is a simple sinusoid. y[t] /. First[ DSolve[{y''[t] == -2*y[t], y[0] == 0, y'[0] == 1}, y[t], t]] Out[1500]= Sin[Sqrt[2] t]/Sqrt[2] The period is Sqrt[2]*Pi, or around 4.44288 We will now obtain this as an InterpolatingFunction from NDSolve, add a DC component, sample at intervals, and add some random noise. soln = y[t] /. First[NDSolve[{y''[t] == -2*y[t], y[0] == 0, y'[0] == 1}, y[t], {t, 0, 150}]] separation = .1; vals = Table[soln + 3, {t, 0., 150., separation}]; vals = vals + RandomReal[{-.1, .1}, Length[vals]]; ft = Abs[Fourier[vals]]; mainfreq = Position[Rest[ft], Max[Rest[ft]]][[1, 1]] Out[1563]= 34 Here is the period estimate. In[1564]:= N[Length[vals]/mainfreq]*separation Out[1564]= 4.41471 So this agrees with the period of the unperturbed signal to 2+ decimal places. A related approach may be found at Documentation Center > Fourier > Applications > Frequency Identification Daniel Lichtblau Wolfram Research

**References**:**Inverse of Interpolating Function?***From:*gonzorascal <djw22@duke.edu>