How do I square a norm in CVX?
Asked Answered
A

1

5

In the CVX package for Matlab, I want to minimize a function like $|Ax-b|_2^2$ . Meaning the square of a 2-norm. How do I code that in CVX? I tried both:

minimize (norm(A*x-b,2)^2);

and

minimize (norm(A*x-b,2)*norm(A*x-b,2));

but both threw errors. Is there a builtin function I'm supposed to be using?

(Note, really I'm trying to minimize the sum of that norm squared plus another norm like minimize (norm(A*x-b,2)^2 + norm(x,1)); so that's why I'm trying to specify the norm squared and not just be satisfied with finding the minimum of the norm unsquared.)

Aright answered 11/4, 2016 at 23:21 Comment(2)
What about sum_square_abs( A*x-b )? Also, regardless of the success, I'm wondering why you wish to do this; minimization of the norm is a minimization of the norm squared.Cuttlebone
Well the square norm is differentiable, while the norm itself is not. That's a big plus.Bindle
I
7

CVX does not support the ()^2 operator. You can either do

(A*x-b)'*(A*x-b)  

or

power(2,norm(A*x-b,2))
Interosculate answered 14/4, 2016 at 18:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.