ntf198602
(Shaoyan Robert)
1
Hello, friends
Optimization 1:
MaximalBy[{{4.9375, {x -> -(3/4)}}, {2.0792, {x -> 2/Sqrt[
3]}}}, First]
the result is: {{4.9375, {x → -(3/4)}}}
Optimization 2:
MaximalBy[{{79/
16, {x -> -(3/4)}}, {-1 + 16/(
3 Sqrt[3]), {x -> 2/Sqrt[3]}}}, First]
the result is: {{-1 + 16/(3 Sqrt[3]), {x → 2/Sqrt[3]}}}
Actually, they are the same optimization problems. Why?
Thank you very much!
neils
(Neil Singer)
2
I tried it as well. It appears to be a bug. I would report that to Support.
Regards
I think it might be a feature rather than a bug. Consider using FullForm:
Sort[{{4.9375, {x -> -(3/4)}}, {2.0792, {x -> 2/Sqrt[3]}}, {79/16, {x -> -(3/4)}},
{-1 + 16/(3 Sqrt[3]), {x -> 2/Sqrt[3]}}}, Last] // FullForm

So the sorting is lexicographic?
neils
(Neil Singer)
4
Jim,
You must be correct! If you do this, it works as “expected”.
MaximalBy[{{79/16, {x -> -(3/4)}}, {-1 +
16/(3 Sqrt[3]), {x -> 2/Sqrt[3]}}}, N@*First]
(I made the function the Composition of N[] and First[]. so it treats the sort function numerically.
Good catch! However, this should be sent to support to improve the documentation and to add an example.
Regards,
Neil