# Coupled expression leading to inaccurate optimization results

Hello, everyone. How to express a coupled expression shown as follows:

variable r(K)
expression C(K)
expression D(K)
for k =1:K
C(k) = log(1+r(k))/log(2);
end
for k=2:K
D(k) = r(k) + max(0,D(k-1)-C(k-1));
end

Since D(k) is determined by D(k-1), that is to say, D(k) is a set of coupled expressions, thus leading to inaccurate optimization results.

What is the difficulty you are encountering? I see nothing wrong with your coupled equations. CVX should accept your program, and submit it to a solver.

If there are “inaccurate” optimization results, perhaps your program has some other undesirable attribute, such as bad scaling. You haven’t shown your complete program, so I can’t determine what else mind not be good about your program.

`C` and therefore `D` involbe log of CVX expression. Therefore, the most reliable solution option in CVX is to specify the most recent version of Mosek 9.x (currently 9.2.14) as the solver. If Mosek is not available to you, then follow the directions 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 , including installation of CVQUAD’s `exponential,m` replacement, as well as reformulation of your program as described in the link.

Thank you. At the very beginning, I thought the inaccurate results were caused by the inaccurate expression results. However, I have solved the problem via trying another solver, i.e., SeDuMi, instead of the default solver, i.e., SDPT3.

Was the optimal objective value much different between SDPT3 and SeDuMi?

Yes. SDPT3 failed to solve such problem with the output NAN, while SeDuMi could solve the problem optimally.