# How to extract the minimal value from NMinimize? [closed]

According to the manual, if I calculate

NMinimize[x^4 - 3 x^2 - x, x]


that returns {-3.51391, {x -> 1.30084}}, I can extract the minimal value -3.51391 using

x /. Last[NMinimize[x^4 - 3 x^2 + x, x]]


Now, if I want to calculate e.g.

NMinimize[x^4 - 3 x^2 - x + y^2, {x,y}]


then how do I extract the minimal value?

## closed as off-topic by Bob Hanlon, m_goldberg, Henrik Schumacher, bbgodfrey, J. M. is away♦Jan 6 at 2:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, m_goldberg, Henrik Schumacher, bbgodfrey, J. M. is away
If this question can be reworded to fit the rules in the help center, please edit the question.

If you mean you want to find what the minimum value of the expression is then this

First[NMinimize[x^4 - 3 x^2 - x, x]]

(*-3.5139*)


If you mean that you want both the x and y values that minimize the expression then this

{x,y}/.Last[NMinimize[x^4 - 3 x^2 - x + y^2, {x,y}]]

(*{1.3008, 0.}*)


And you can do even more interesting things, you can put any expression in front of that /. and then every x and y value inside that expression will be replaced by the values of x and y found by NMinimize, whether the expression is a list or anything else.