Ipopt's "local" optimum can be very substandard

I see, but
The cos function is a nice function in that it belongs to C^\infty (having arbitrary orders of continuous derivative). In the first example, Ipopt gives me a local Maximum which cannot survive any slight perturbation. In this case, what is the meaning of specifying Min in JuMP.@objective(NLP, Min, cos(x))?

I don’t think Ipopt can memorize the best solution found so far.
Let’s discuss it separately here.

In the third example, my meaning was:
Ipopt returns 3 * pi, which is correct. But clearly pi is the nearest optimality, from the start value 0.0.

One more question: is the usage in my first post correct (as expected)?
Do I have to explicitly pass gradient and Hessian info to Ipopt? or something else?