function [x,h,xopt] = proxabs(lambda,rho,v)
% plot the prox-abs function: h(x)=lambda|x| + (rho/2)(x-v)^2
% the minimizer xopt is computed explicitly by soft threshholding
clf
x=linspace(-1,1,1001); % 1000 equally spaced points between -1 and 1
h=lambda*abs(x)+(rho/2)*(x-v).^2;
plot(x,h)
shg
mu = lambda/rho;
if abs(v) <= mu
    xopt = 0;
elseif v > mu
    xopt = v - mu;
else % v < -mu
    xopt = v + mu;
end
hopt = lambda*abs(xopt)+(rho/2)*(xopt-v).^2;
hold on
plot(xopt,hopt,'ro')