Precision problem

I meet a problem with the precision.

I want to solve a simple problem as follows:

cvx_begin

variable x;
maximize (0.5*x+0.5-0.125*x^2)
subject to
    1<=x<=2;

cvx_end

The correct answer is 1 when x = 2 obviously.

But CVX shows the maximum = 1 when x = 1.99986.

I use CVX with the solver gurobi and the cvx_precision has already been set as “best”.

How can I do to reach a more higer precision?

The current precision is not enough for me because the solution will be used as a parameter of another problem. The another problem can be only solved when x=2 in cvx.

You can certainly try the other solvers and see if any of them give you higher precision. But frankly, this is an entirely reasonable level of precision for convex optimization solvers. After all, this produces an objective function value that is correct to a relative precision of 2.45\times 10^{-9}!

It is not reasonable to expect more from a general-purpose framework like this. If you need higher precision you will have to build custom machinery to do so.

But I would argue that if you have designed an algorithm that must have x=2 precisely, then you might want to reconsider that design.