A non-trivial problem?

P=10;
T=3;
cvx_begin
variable w(T,1)
variable x
expression med
med=square_abs(norm(w)-x);

 minimize( med +norm(w) ) 
 subject to 
 norm(w)<=x;
 x^2<=P;

cvx_end
Due to some reasons, I have to introduce another variable x in problem, and I want the squre form of the error, i.e. (norm(w)-x)^2 But the problem is that I have tried all the function the cvx user’s guide suggested, like square_abs, square_pos, square,pow_p, pow_pos,pow_abs. And I always get the same reply ‘illegal operation’. Does that mean this problem can’t be solved if I want to keep the squrare form?

I believe (norm(w) - x)^2 is non-convex.

square_pos(norm(w) - x)) is convex and is allowed by CVX. However, it is not equal to (norm(w) - x)^2 if norm(w) - x is negative.

However,square_pos(norm(w)) is convex and is allowed by CVX. The reason this equals norm(w)^2 is because norm(w) >= 0.

Thanks for your reply