# Minimum value selection

Code

 y[1] = 1;
y[2] = 2;
y[3] = 3;
Min[y[1], y[2], y[3]]


Outputs "1", but desired result is y[1]

How to do that? Many thanks for help.

You can get the value(s) i for which y[i] is minimal :

 y[1] = 10;
y[2] = 20;
y[3] = 30;
MinimalBy[Range[3],y]


{1}

But as soon as you wrap the result 1 in y[...], y[1] will be evaluated to 10, accordingly to the princips of Mathematica.

• HoldForm[y[n]] /. n -> First@MinimalBy[Range[3], y] gives y[1] – bbgodfrey Jul 29 '17 at 3:01
• @bbgodfrey Your answer help me a lot. Many thanks. – Robin_Lyn Jul 29 '17 at 3:20

For the exact example given you could perhaps utilize the DownValues list:

MinimalBy[DownValues[y], Last][[1, 1]]

HoldPattern[y[1]]