function [x]=FUN_quad(q,t,K)

% soft-thresholding: min_x 0.5*x^2-q*x+t|x|

x=max(q-t,zeros(K,1))-max(-q-t,zeros(K,1));

% function [x]=FUN_quad(p,q,t,N)
% 
% % function [x]=FUN_quad(p,q,t,N)
% % The function returns the optimal variable of the following optimization problem:
% % max 0.5*p*x^2+q*x+t*|x|
% % dimension of x: N
% 
% if nargin==3,
%     N=length(q);
% end;
% 
% x=max(-(q+t)./p,zeros(N,1))-max((q-t)./p,zeros(N,1));
% 
% % cvx_begin quiet
% %     variable x_cvx(N,1)
% %     minimize(0.5*x_cvx'*diag(p)*x_cvx+q'*x_cvx+t'*abs(x_cvx))
% % cvx_end
% % disp(['solver precision is ' num2str(norm(x-x_cvx))]);