# Finding the associated parameter of the maximum

I am trying to find the maximum value in a list. I can find the maximum value, but how can I find the value of the associated parameter at the maximum? (I don't want the index of the element in the list of the parameter since the actual list (of t in the example) is so long, so I want to get t=4 for the following example instead of its index:3)

 v = Table[
TR1 + TR2 /. Flatten[{Solve[TR1 - t == 0, TR1], TR2 -> t + 1}], {t,
2, 4, 1}]

tstar = Max[v]

• Could do v = Table[{t, TR1 + TR2 /. Flatten[{Solve[TR1 - t == 0, TR1], TR2 -> t + 1}]}, {t, 2, 4, 1}]; tstar = MaximalBy[v, Last][[1, 1]] – march Sep 14 '17 at 21:15
• list = RandomReal[1, 100]; Position[list, Max[list]] – anderstood Sep 15 '17 at 0:30

t = Range[2, 4, 1]
v = (TR1 + TR2 /.
Flatten[{Solve[TR1 - # == 0, TR1], TR2 -> # + 1}] &) /@ t
t[[Ordering[v, -1]]]


For you example, the following will work.

 Maximize[{1 + 2 t, 1 <= t <= 4 && t ∈ Integers}, t][[2, 1, 2]]


4

It will work for functions that are not monotonic as well.

Maximize[{Sin[π t/2], 0 <= t <= 4 && t ∈ Integers}, t][[2, 1, 2]]


1

In the above two examples the global maximum falls on an integer value, but this does not have be the case. In the following example, the global maximum is at π/2, but the integer maximum is at 2.

Maximize[{Sin[ t], 0 <= t <= 4 && t ∈ Integers}, t][[2, 1, 2]]


2