The cvx_optval is not equal to the object value

I haven’t verified that enger_counter_3(1,20) is the same as your objective function. So you should check that.

I don’t think you need parentheses around the objective function (you do if there are any spaces), but it can’t hurt to try.

The optimal objective value is rather large, so there could be some numerical inaccuracies. I don’t know whether this could be significant enough to account for the discrepancy.

Perhaps, in combination wit the large numbers, the discrepancy can be explained by use of CVX’s Successive Approximation method. Try using CVX 2.2 with Mosek 9.x,; or if that is not available to you, follow the advice at CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions