# How do I know which element gave me the minimun when using Min? [duplicate]

This is my code down below. I wanted to know the minimun value of list gk and the element used from listf that gave me the minimum value of list gk. I can get the minimum value by using Min but, how do I get the element of listf that was used?

listf = Range[1, 10, 0.1];
g[p_] := p^2 - 6 p^3 + p^4;
gk = Map[g, listf]
Min[Map[g, listf]]


This is the output:

{-4., -5.3119, -6.8544, -8.6359, -10.6624, -12.9375, -15.4624,
-18.2359, -21.2544, -24.5119, -28., -31.7079, -35.6224, -39.7279,
-44.0064, -48.4375, -52.9984, -57.6639, -62.4064, -67.1959, -72.,
-76.7839, -81.5104, -86.1399, -90.6304, -94.9375, -99.0144, -102.812,
-106.278, -109.36, -112., -114.14, -115.718, -116.672, -116.934,
-116.438, -115.11, -112.88, -109.67, -105.404, -100., -93.3759,
-85.4464, -76.1239, -65.3184, -52.9375, -38.8864, -23.0679, -5.3824,
14.2721, 36., 59.9081, 86.1056, 114.704, 145.818, 179.563, 216.058,
255.424, 297.786, 343.268, 392., 444.112, 499.738, 559.012, 622.074,
689.063, 760.122, 835.396, 915.034, 999.184, 1088., 1181.64, 1280.25,
1384., 1493.05, 1607.56, 1727.71, 1853.65, 1985.56, 2123.62, 2268.,
2418.88, 2576.44, 2740.87, 2912.35, 3091.06, 3277.21, 3470.98,
3672.57, 3882.18, 4100.}

-116.934


## 1 Answer

listf = Range[1, 10, 0.1];
g[p_] := p^2 - 6 p^3 + p^4;
gk = Map[g, listf];


Either with Position:

Position[gk, Min[gk]]


{{35}}

or (I recommend) with Ordering:

pos = Ordering[gk, 1][[1]]


35

To extract the element of listf corresponding to the minimum:

listf[[pos]]


4.4

If you want a list {minimum, position}:

{Min[#], Ordering[#, 1][[1]]} & @ gk
(* or *)
Through[{Min, Ordering[#, 1][[1]] &}[gk]]


{-116.934, 35}

A list {minimum, element}:

{Min[#], listf[[Ordering[#, 1][[1]]]]} &@gk
(*or*)
Through[{Min, listf[[Ordering[#, 1][[1]]]] &}[gk]]


{-116.934, 4.4}

• Thank you! That was very helpful – Jun Jan 14 '17 at 12:01