# Change the Form of Formula

E-(E^2-2*R*C*E*P)^0.5<=I*R*(2*C*E)^0.5;and variables are E and P.
Many articles show this formula is convex,but it can not be accepted by cvx.
So I want to know how I can change the form of the formula so that cvx can accept it.
Thank you.

1 Like

Please show us the proof that this constraint is convex. If it is convex, is there a rotated second order (Lorentz) cone representation?

To simplify notation a bit I wrote x-\sqrt{x^2-axy}\leq b\sqrt{x} with variables x,y and constants a,b. After rearranging, squaring, cancellation etc. I got some equivalent Lorentz cone formulations, for example 4b^2(x-ay)\geq (ay-b^2)^2.

1 Like

Thank you,Michal_Adamaszek. Could you give me the process?Because I have some other similar formulas.

x\leq \sqrt{x^2-axy}+b\sqrt{x}

x^2\leq x^2-axy+2bx\sqrt{x-ay}+b^2x

ay-b^2\leq2b\sqrt{x-ay}

I guess I assumed x\geq 0 along the way.

Thank you very much.
dE(t)/dt<=-(E-(E^2-E*P)^0.5);and variables are E and P. And dE(t)/dt is derivative.
I do not know how to deal with dE(t)/dt. So I want to know how to change the form of this formula so that cvx can accept it. Does derivative have properties of the convex function?

CVX doesn’t “know” anything about derivatives. Do you have an explicit formula for the derivative? You will need to use that. Presumably the E on the ightr-hand side is also a function of t? But you don’t show that.

Yes,E and P both are functions of ‘t’ (E(t) and P(t)).
In addition,E(t)=(V(t))^2, and V(t) is a function of ‘t’ .
V(t)=a*SOC(t)+b,and SOC(t) is a function of ‘t’.
But there is not explicit formula for SOC(t).
But in cvx,E is the variable,so I do not think it need the formula of E(t)=(V(t))^2.

You need explicit formulas for everything in CVX. You need an explicit formula for \frac{dE}{dT} Perhaps t needs to be your CVX variable. And if that doesn’t wind up being convex, you can not use CVX.

Because t is time(such as 1s,2s,3s,4s…),I can not let it become a cvx variable and I also can not disturb it.

One way or another, you need an explicitt formulation for your optimization problem. If you can not do that, you can not use CVX for that problem.

Hi,Mark. dE(t)/dt can be replaced by discretization,just like E(k+1)-E(k) (and k is discrete time,such as 1s,2s,3s,4s…). So the formula of dE(t)/dt<=-(E-(E^2-E*P)^0.5) can become
the form of E(k+1)-E(k)<=-(E(k)-(E(k)^2-E(k)*P(k))^0.5).
So I want to know how to change the form of E(k+1)-E(k)<=-(E(k)-(E(k)^2-E(k)*P(k))^0.5) so that cvx can accept it.
Thank you.

That seems to be a rotated quadratic cone again:

E(k)*(E(k)-P(k))>=E(k+1)^2

But the formula of E(k)(E(k)-P(k))>=E(k+1)^2 can not be accepted by cvx,because cvx does not allow multiplication of variables,although it is convex.
(E(k)
(E(k)-P(k))^0.5>=E(k+1)

rotated_lorentz in http://web.cvxr.com/cvx/doc/funcref.html#sets

But the formula of E(k) *(E(k)-P(k))>=E(k+1)^2 can not be accepted by cvx,because cvx does not allow multiplication of variables.
So I want to know how I should do?
Thank you.

You have not understood the rotated lorentz cone. Indeed you have y=E(k) and z=E(k)-P(k) and x=E(k+1) so the multiplication is build into the cone the definition. You do not do it.

If you’re asking what the syntax is then probably {x, y, z} == rotated_lorentz(3)