2
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$
    – Chris K
    Commented Nov 8, 2019 at 15:23
  • 1
    $\begingroup$ Have you seen FindPeaks[]? $\endgroup$
    – Michael E2
    Commented Nov 8, 2019 at 17:27
  • 1
    $\begingroup$ This answer might be helpful. $\endgroup$
    – anderstood
    Commented Nov 9, 2019 at 9:07

2 Answers 2

7
$\begingroup$

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: *)
(* PacletInstall["https://github.com/cklausme/EcoEvo/releases/download/v1.1.0/EcoEvo-1.1.0.paclet"] *)
(* 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}} *)
$\endgroup$
4
  • $\begingroup$ @AntonAntonov Good idea, thanks! $\endgroup$
    – Chris K
    Commented Nov 8, 2019 at 14:28
  • 2
    $\begingroup$ These might be a good candidate for the Wolfram Function Repository, should you wish to make it available in that way. $\endgroup$ Commented Nov 8, 2019 at 15:55
  • $\begingroup$ @DanielLichtblau I might, but I'm mostly holding out for the Paclet Repository! $\endgroup$
    – Chris K
    Commented Nov 8, 2019 at 17:35
  • $\begingroup$ The advantage of the Function Repository is that it actually exists (not to get into ontological debates or anything...) $\endgroup$ Commented Nov 9, 2019 at 16:12
6
$\begingroup$

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}]

enter image description here

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!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.