# CVX: Illegal operation: pow_p( {convex}, {-1} )？

Hi, everyone
I encounter problem using CVX, specifically, matlab codes are given as following:

    function [ Belta1_out,Belta2_out] =  CvxFixedPower( Snr_PS,Snr_PR )
%UNTITLED3 此处显示有关此函数的摘要
%   此处显示详细说明
global N m x0 y0 xF yF T_slot G H;
cvx_begin
variable x(N)
variable y(N)
expression Belta1(N-1)
expression Belta2(N-1)
expression SumBelta1(N-1)
expression SumBelta2(N-1)
for i=1:N-1
Belta1(i)= G*inv_pos(power((power(x(i),2)+power(y(i),2)+H^2),m/2));
end
for i=1:N-1
Belta2(i)= G*inv_pos(power((power(x(i)-D,2)+power(y(i),2)+H^2),m/2));
end
%     Belta1= G*inv_pos(power((power(x(1:N-1),2)+power(y(N-1),2)+H^2),m/2));
%     Belta2= G*inv_pos(power((power(x(1:N-1)-D,2)+power(y(N-1),2)+H^2),m/2));
for i=1:N-1
SumBelta1(i)=inv_pos(Belta1(i)*Snr_PS(i));
end
for i=1:N-1
SumBelta2(i)=inv_pos(Belta2(i)*Snr_PR(i));
end
minimize sum(SumBelta1+SumBelta2)
subject to
power(x(1)-x0,2)+power(y(1)-y0,2)-(T_slot*V_Max)^2<=0;
for k=1:N-1
power(x(k+1)-x(k),2)+power(y(k+1)-y(k),2)-(T_slot*V_Max)^2<=0;
end
power(x(N)-xF,2)+power(y(N)-yF,2)-(T_slot*V_Max)^2<=0;

cvx_end
Belta1_out=G./(power(x(1:N-1),2)+power(y(1:N-1),2)+H^2).^(m/2);
Belta2_out=G./(power(x(1:N-1)-D,2)+power(y(1:N-1),2)+H^2).^(m/2);
end


However, Matlab gives messages error using

Actually, the formula in line 13 is given as following
[\beta {\rm{ = }}\frac{G}{{{{\left( {{x^2}[n] + {y^2}[n] + {H^2}} \right)}^{{m \mathord{\left/
{\vphantom {m 2}} \right.
\kern-\nulldelimiterspace} 2}}}}}]

Thanks anyone who can help me.

，我也是出现了这个问题

This is an English language forum.

help pow_p

pow_p Positive branch of the power function.
pow_p(X,P) computes a convex or concave branch of the power function:
P < 0: pow_p(X,P) = X.^P if X > 0, +Inf otherwise
0 <= P < 1: pow_p(X,P) = X.^P if X >= 0, -Inf otherwise
1 <= P : pow_p(X,P) = X.^P if X >= 0, +Inf otherwise
Both P and X must be real.

Disciplined convex programming information:
The geometry of pow_p(X,P) depends on the precise value of P,
which must be a real constant:
P < 0: convex  and nonincreasing; X must be concave.
0 <= P < 1: concave and nondecreasing; X must be concave.
1 <= P    : convex  and nonmonotonic;  X must be affine.
In all cases, X must be real


if the 2nd argument of pow_p is negative, the first argument must be concave (or affine). Hence, the error message.

Unsurprisingly, inv_p also requires its argument to be concave (or affine).

So the first thing you need to do is prove that your model is convex.