# Perplexing DCP error from pow_p()

I’m trying to do an optimization where my original problem contained a Heaviside step function, u(x) = 0 (x<=0); 1 (x>0). It’s easy to write a MATLAB function for u(x), but in its simplest form it doesn’t conform to DCP rules. So, I rewrote an approximation to u(x) which I thought conformed to DCP rules, but I still get an error. My approximation is actually for u(x-xth) with x, xth > 0:

``````function u = ua( x, xth )
N = 100;
u = pow_p( x ./ xth, -N );
u = pow_p( 1 + u, -1 );
return;
end
``````

However, CVX issues the following error message:

``````Error using cvx/pow_cvx (line 144)
Disciplined convex programming error:
Illegal operation: pow_p( {convex}, {-100} )
``````

The CVX documentation for `pow_p(x,p)` seems to clearly allow for p < 0 and x real.

Here is the use in context:

``````cvx_begin
variable W( N, P ) complex;
variable err( P, 1 );
for p = 1 : P
err(p) = max( abs( ( Phi{p} * W(:,p) - vF{p} ) ./ d ) );
end;    % for p ...
minimize sum( ua( sum( ua( abs(W), Wmin ), 2 ), 0.5 ) );
subject to
max( abs( W(:) ) ) <= Wmax;
max(     err     ) <= err_thr;
cvx_end;
``````

N, P, Wmin, Wmax, and err_thr are scalar constants; Phi and vF are cell arrays of complex constants; d is an array of complex constants.

`pow_p( {}, -100 )` is convex and decreasing. Therefore, according to the DCP ruleset, it accepts a concave argument. It cannot accept a convex argument.

The Heaviside function is not, in fact, convex.

This is an example where the output of help pow_p contains the DCP requirements on the argument, but the CVX Users’ Guide does not. If the Users’ Guide were beefed up for this and other functions with the help results, some DCP errors could be headed off. Not everyone thinks to look at the help.

Fair criticism! Truth be told the `pow` function is messy because, really, it is a bunch of different functions wrapped into one, some convex, some concave, some increasing, some decreasing.

Thanks! I actually checked to see if the Heaviside function is convex, but I made an error in my proof. Oops.