# Computed dual is not equal to primal for a simple example from book

Hi, This is an example from Convex Optimization Book. I only want to check the strong duality by using dual variables returned by cvx. For the first problem it does hold. But for the dual problem it is not. Even when I remove negative instances which make the result complex number, the strong duality does not hold. Why? Actually I have the same difficulty with the dual variables returned by cvx, in one of my own problems and when I tried to figure out it using a simple problem using cvx, I encountered this even with problems from the book.

``````% Section 11.8.4: Network rate optimization
% Boyd & Vandenberghe "Convex Optimization"
% Argyrios Zymnis - 05/03/08

rand('state',1)
L = 20;
n = 10;
k = 7; %average links per flow
A = double(rand(L,n) <= k/L);
c = 0.9*rand(L,1)+0.1;

% Solve network rate problem
cvx_begin
variable x(n);
dual variable LA % I added this
maximize(sum(log(x)))
subject to
LA:A*x <= c
cvx_end
primal_obj = cvx_optval;
% Solve dual problem to obtain link prices
cvx_begin
variable lambda(L);
dual variable xd % I added this
minimize(c'*lambda-sum(log(A'*lambda))-n)
subject to
xd:lambda >= 0
cvx_end
What version of CVX are you using? I’m getting that `lambda` and `LA` are identical, and `xd` and `c-A*x` are identical.
What version of CVX are you using? I’m getting that `lambda` and `LA` are identical, and `xd` and `c-A*x` are identical, and the objective functions are identical. I tested this with CVX 2.1.
I disagree. `sum(log(xd))` should not be the same. `xd` and `x` are not the same. Rather, `xd` and `c-A*x` are the same.