# The second argument must be positive or negative semidefinite for convex objective function

(Kimia Shayestehfard) #1

Hi,
Bellow is my objective function in CVX.
variable x(n);
variable y(n);
minimize (w*x+norm(x’*A’y))
where w and A are two matrixes and x and y are two vectors. w
x is a scaler and x’*A’*y would generate a scaler as well. When I executed the code it showed “The second argument must be positive or negative semidefinite” error. I do not know where does this error come from and how can I fix that?
Any help of you is really appreciated.
Thank You!

Best,
Kimia

(Mark L. Stone) #2

`x'*A*y` is an indefinite form, being neither convex nor concave, and this is not allowed in CVX. For instance, if A = 1 and x and y are scalars, this comes out to `x*y` , Additionally, you wold not be allowed in CVX to use norm on it given it is not affine.

(Kimia Shayestehfard) #3

Hi Mark,
Thanks for your quick response. I have two questions which might seem silly so I apologize in advance.

1. If A is for example 162*162 matrix, still x’Ay is non-convex? If I want to be more precise, for defining convexity should we do case study on check the convexity based on matrix A size or a function is convex iff for any given size of A the function remains convex?

2. As far as I know a norm 2 of a given objective function is convex. Does the reason that CVX in the cases which we have norm work iff the function is affine is that if the function is not affine, the norm would not be convex or this is only CVX’s restriction?

(Mark L. Stone) #4
1. If `x'*A*y i`s non-convex for`A` (and x and y) being a scalar, it won’t become convex in higher dimensions. In this case, 1-D is sufficient to easily disprove convexity, and makes things easier to see and understand. In other cases, 1-D could be a special case which is different than the general case. You need to prove convexity of whatever you provide to CVX. If you follow CVX’s rules to create objective function and constraints, you will have proved convexity and know that you can use CVX for the problem.

2. The norm of a non-affine function may or may not be convex. See section 3.2.4 of https://web.stanford.edu/~boyd/cvxbook/ for a discussion of composition rules which preserve convexity.

(Kimia Shayestehfard) #5

Thank you so much.
For a given objective function like minimize norm(A*x,2) where A is a scaler with bounded values CVX returns inf as the optimum value and Nan for values of x. I do not know why I am getting this response!

(Mark L. Stone) #6

Please show a complete reproducible example, complete with output.

It sounds like your problem was determined to be infeasible, which could only be the case if there were one or more constraints (which you haven’t told us about). In such case, presuming you didn;t use the quiet option, you should see
`Status: Infeasible` .