The error of function square_pos in cvx

As shown in the figure, i think the output result of function square_pos in cvx is wrong,can you help me?

Yes, that is wrong. Perhaps there is a conflict somewhere. It might be the case that square_pos when applied to a cvx variable or expression is correct, because that uses an “internal” version of square_pos.

Is there another square_pos in your MATLABPATH besides these two? If so, perhaps the “wrong” square_oos is being called.

>> which -all square_pos
C:\cvx_2.2_1148\functions\square_pos.m
C:\cvx_2.2_1148\functions\@cvx\square_pos.m  % cvx method

Below is the version of square_pos for double precision arguments: it is located in the functions directory of the CVX installation.

function y = square_pos( x )

%SQUARE_POS    Square of positive part.
%   SQUARE_POS(X) is the square of the postive parts of the elements of X;
%   i.e., SQUARE_POS(X)=MAX(X,0).^2. X must be real.
%
%   Disciplined convex programming information:
%       SQUARE_POS(X) is convex and nondecreasing in X. Thus when used in
%       CVX expressions, X must be convex (or affine).

narginchk(1,1);
if ~isreal( x ), 
    error( 'Argument must be real.' ); 
end

y = square( max( x, 0 ) );

% Copyright 2005-2016 CVX Research, Inc. 
% See the file LICENSE.txt for full copyright information.
% The command 'cvx_where' will show where this file is loc

Hello, Stone. there are only two versions of square_pos functions. however, the output of square_pos is still wrong, can you help me?

I don’t know what’s going on. Try redownloading CVX adn reinstalling it… And make sure it’s version 2.0. And do everything in a new MATLAB session.

ok,i have addressed this problem via reinstalling cvx. thank you very much.