If I run the command
ResourceFunction[ "GlobalMaxima"][{x*y + 2*y*z + 6*x, x^2 + y^2 + z^2 == 36}, {x, y, z}]
This returns a closed form solution of
If I take $N[]$, it returns
Adding a Chop produces a max
57.6271 at x = 3.7642, y = 3.68959, z = 2.86666
If I run the command
N[Maximize[{x*y + 2*y*z + 6*x, x^2 + y^2 + z^2 == 36}, {x, y, z}]]
I get the chopped version of the result.
My question is, how do users know that they should chop a result in general (sure, the imaginaries are quite small) but why does one command show them and the other does not?
Is a user expected to test the results to determine if chopping should be used or is this never true?
Aside: It appears that MathJax/LaTex is not working at the moment for some reason hence the pictures above.
Chop
to the result. This way no need to guess. If it is needed, it will be used, if not, it will not affect the result, right? $\endgroup$"GlobalMaxima"
returned the results in the form of radical expressions that can produce imaginary artifacts particularly when using machine precision. However, if youFullSimplify
the results they will be in the form ofRoot
expressions (same as those produced byMaximize
) that will avoid the imaginary artifacts whenN
is used. In general, use arbitrary-precision (e.g.,N[#, 15]&
) rather than machine precision (i.e.,N
) to get better precision. $\endgroup$N[res, prec]
withprec >= $MachinePrecision
, imo, if you $\endgroup$