How to add self-defined convex function to atom library?

Thanks again for Mark’s suggestion. I reread the user’s guide and found a concept of perspective of a function from Boyd’s book (Page 103, 3.2.6). Actually, my function is a perspective of 2^x, thus it’s convex. On the other hand, thanks to the guidance from Michael C. Grant in another post, I found a way to develop my own function follows DCP ruleset as follows:

function cvx_optval = myFoo( x, y )
cvx_begin
    variables z;
    minimize( z );
    subject to
        {x * log(2), y, z} == exponential;
cvx_end

And it works for me. :slight_smile:

In addition, I’d like to share my understandings about “adding new functions to the atom library” for those who might have the same issue with me. Actually, the code I posted in my question is only suitable for numerical inputs but not for CVX expressions, same with the functions under cvx/functions. The functions under cvx/functions/@cvx are suitable for CVX expressions, thus cvx/functions/@cvx is where atom library located at, i think.

1 Like