# Incorrect expression output

Hi
I have a simple Matlab code below.

Very strangely, the solver output of the expression u_norm_vec is not consistent with what it should be (manually computed from u_vec).

Any help will be gr appreciated. Thank!

clear;
n = 1e1;

cvx_begin

``````expression u_norm_vec(n)
variables u_vec(n) y_vec(n+1)
y_vec(1) == 0.5;

minimize   y_vec(8)
subject to

for i = 1:n

u_norm_vec(i) = norm(u_vec(1:i));
u_norm_vec(i) <=.2;

y_vec(i+1) == y_vec(i) - u_vec(i);

end
``````

cvx_end

Conflicting results below: u_norm_vec(i) \neq norm(u_vec(1:i))

u_norm_vec =

``````0.1464
0.1525
0.1640
0.1742
0.1837
0.1924
0.2000
0.2000
0.2000
0.2000
``````

u_vec(1:i)
=
0.0756
0.0756
0.0756
0.0756
0.0756
0.0756
0.0756
0
0
0

The value of a CVX expression after results are returned by CVX does not necessarily have the value corresponding to the final (i.e.,optimal) values of the CVX variables. CVX variables always have their final values after results are returned by CVX. So if you want to know the optimal value of a CVX expression, you need to calculate it using the final (optimal) values of CVX variables.