```
B=1.5*10^9;
noise=10^(-20.4)*1.5*10^9;
hsr=1.54646531372085e-07;
hLI=0.003;
hrd=1.50100039911696e-09;
cvx_begin
cvx_quiet(true);
cvx_expert true
variable x nonnegative
expression frd
expression pr
expression Q
frd=4*noise*hsr*hLI*hrd*x;
pr=sqrt(frd);
Q=log(pr*hrd+noise)/log(2)-log(noise)/log(2);
maximize(Q)
subject to
x<=0.0025;
cvx_end
ps=x;
rate=Q;
```

# When frd=sqrt(x) is used in cvx, the values of frd and sqrt(x) are very different.

**ZHQ**(Zhang Hanqing) #1

**Mark_L_Stone**(Mark L. Stone) #2

`frd`

is a CVX expression. If CVX completes with `Status: Inaccurate/Solved`

or `Status: Solved`

, the optimal values of the declared CVX variables are in the MATLAB variables having those names. In general, the values of CVX expressions after CVX completes are not guaranteed to correspond to the optimal values of the CVX variables; however, in this case`frd`

and `4*noise*hsr*hLI*hrd*x`

are both equal to `2.0792e-32`

after CVX completes.using SDPT3 as solver.

Why do you think `frd`

should equal `sqrt(x)`

? There is nothing in your program which would force that. If you want `frd`

to equal `sqrt(x)`

. then you need to change the problem formulation.

Also, your problem scaling is terrible. Any solution of your program as is is essentially meaningless. You need to make non-zero numbers much close to one in magnitude.

I recommend you not use `cvx_quiet(true)`

or `cvx_expert true`

until you are confident everything is working and being solved correctly.

Given you use of `log(cvx_expression),`

I recommend you follow the advice in 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 .

**ZHQ**(Zhang Hanqing) #3

Sorry, my question is wrong, my original question ：when pr=sqrt(frd) is used in CVX, the values of pr and sqrt(frd) are very different

**Erling**(Erling D.Andersen) #4

This

noise=10^(-20.4)*1.5*10^9;

says your model has significant scaling issues.

**Mark_L_Stone**(Mark L. Stone) #5

@Erling and i agree about the terrible scaling.

Nevertheless, the failure of `p`

r to equal `sqrt(frd)`

after CVX execution completes, us due to what I wrote in my previous post

`frd`

is a CVX expression. If CVX completes with`Status: Inaccurate/Solved`

or`Status: Solved`

, the optimal values of the declared CVX variables are in the MATLAB variables having those names. In general, the values of CVX expressions after CVX completes are not guaranteed to correspond to the optimal values of the CVX variables;

The only way to be guaranteed to get the correct optimal values of CVX expressions is to calculate them using optimal CVX variable values after CVX execution completes, `x`

will contain the optimal value of the CVX variable `x`

, so you can execute

```
frd=4*noise*hsr*hLI*hrd*x
pr=sqrt(frd)
```

after CVX execution completes to get the optimal values of `frd`

and `pr.`