# Finding the maximum amplitide quantitatively using interpolation

I have the following table

data = Table[Sin[i], {i, 0, 10, 0.1}] // N


And I plotted the data as follows,

Now I want to know the value of each maximum with high accuracy. It can see that for example the first maximum is around 1.0. However, I want it in terms of an accurate number. Can I do it using interpolation? If yes, how can I know what should be the accurate starting point?

I appreciate it if you could help me.

• From data with machine precision you can not get an exact answer. Exact means infinite precision. For this you need an analytic procedure, like setting the derivative to zero. Sep 27, 2023 at 13:00

Find the peaks

peaks = FindPeaks[data]


{{17, 0.999574}, {80, 0.998941}}

But the "accurate number" should be 1

FunctionRange[Sin[x], x, y]


-1 <= y <= 1

Hence

Round[peaks, 1]


{{17, 1}, {80, 1}}

To find the corresponding x-values:

x /. Solve[Sin[x] == 1, x] /. C[1] :> {0, 1} // Flatten


{Pi/2, (5*Pi)/2}

ListLinePlot[data,
Epilog -> {Red, PointSize[Large], Point @ FindPeaks[data]}]


• Thanks for your help! Sep 27, 2023 at 10:45
• You're most welcome
– eldo
Sep 27, 2023 at 10:46

I suggest a graphical solution. The procedure can be used universally, not just specifically for the data given here. To get a more accurate solution I increased the resolution by 10.

data = Table[Sin[i], {i, 0, 10, 0.01}];
f = Interpolation@data;
p = Plot[f[x], {x, 0, 1000}, Mesh -> {{0}},
MeshFunctions -> {f'[#] &}, MeshStyle -> {Red, PointSize@Medium}] //Quiet


 pts = Cases[p, Point[{x_, y_ /; y > 0}] :> {x/100, y}, \[Infinity]] //Sort


{{1.5808, 0.999999}, {7.86396, 0.999999}}