# Find peaks, max and min of an interpolation function?

I'm new in mathematica.

I have a list of values and i don't know how to find some poitns, such as peaks, the max and min of an interpolation function.

RA = List[{0, 0.727578}, {0.4, 0.73179}, {0.8, 0.773248}, {1.2, 1.342248}, {1.6, 0.987746}, {2, 0.791317}, {2.4, 1.11788}, {2.8, 0.996614}, {3.2, 0.938749}];

f = Interpolation[RA]

InterpolatingFunction[{{0., 3.2}}, <>]


Thanks

• Welcome to Mathematica.SE, Jessica! I suggest the following: 1) Take the tour and check the faqs. 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. Nov 8, 2019 at 15:23
• Have you seen FindPeaks[]? Nov 8, 2019 at 17:27

This functionality is included in the FindMaxima, FindMinima & FindExtrema functions in my EcoEvo package (the continuous part is based on this answer by @DanielLichtblau).

Import["https://raw.githubusercontent.com/cklausme/EcoEvo/master/EcoEvo/EcoEvo.m"]
(* ... or install with: *)
(* then load the package: *)
(* <<EcoEvo *)
(* EcoEvo Package Version 1.1.0 (October 22, 2019) *)

FindMaxima[RA]
(* {{1.2, 1.34225}, {2.4, 1.11788}} *)

FindMaxima[f]
(* {{0.171237, 0.75627}, {1.2, 1.34225}, {2.41594, 1.11823}} *)

• @AntonAntonov Good idea, thanks! Nov 8, 2019 at 14:28
• These might be a good candidate for the Wolfram Function Repository, should you wish to make it available in that way. Nov 8, 2019 at 15:55
• @DanielLichtblau I might, but I'm mostly holding out for the Paclet Repository! Nov 8, 2019 at 17:35
• The advantage of the Function Repository is that it actually exists (not to get into ontological debates or anything...) Nov 9, 2019 at 16:12

Here is your list and its interpolation. I only made the interpolation smoother:

rA = List[{0, 0.727578}, {0.4, 0.73179}, {0.8, 0.773248}, {1.2,
1.342248}, {1.6, 0.987746}, {2, 0.791317}, {2.4, 1.11788}, {2.8,
0.996614}, {3.2, 0.938749}];

f = Interpolation[rA, InterpolationOrder -> 3, Method -> "Spline"];


Let us plot it:

Plot[f[x], {x, 0, 3.2}]


Now, try this:

Map[FindMaximum[f[x], {x, #}] &, {0.1, 1., 2.3}]

(*  {{0.801624, {x -> 0.169875}}, {1.35071, {x ->
1.24042}}, {1.13541, {x -> 2.48519}}}   *)

Map[FindMinimum[f[x], {x, #}] &, {0.6, 2.1, 2.9}]

(*  {{0.672974, {x -> 0.605239}}, {0.772641, {x ->
1.91542}}, {0.890775, {x -> 3.06279}}}   *)
`

Have fun!