# How to write the following objective function in CVX?

Hi, Everyone
The variable x(n) with n=8

The objective function is the following:
(x(1)+x(2)) * (x(1)/(x(1)+x(2)))^2+(x(3)+x(4)) * (x(3)/(x(3)+x(4)))^2 + (x(5)+x(6)) * (x(5)/(x(5)+x(6)))^2 + (x(7)+x(8)) * (x(7)/(x(7)+x(8)))^2

subject to some constrains.

I know there is a {real affine}.\ {real affine} in this objective function. I don’t know how to avoid this problem.

Assuming x \geq 0 then let us look at the term

(x(1)+x(2)) * (x(1)/(x(1)+x(2)))^2 = \frac{x(1)^2}{x(1)+x(2)}

then

2st \geq x(1)^2 \mbox{ and } t = x(1)+x(2)

implies

2s \geq \frac{x(1)^2}{x(1)+x(2)}

This seems to prove you can rewrite the objective using the rotated Lorentz cone to a form that can be handled in CVX.

1 Like