function demo_bps_l0norm_smooth
% min_{c,s} A*s + B*c + C*s*s + D*c*s + lambda*norm(s*x + c*y,1), s.t. c*c + s*s = 1;

clc;clear all;close all;
for iter = 1:10000000000000
    seed = iter; rand('seed',seed); randn('seed',seed);
    n = 10; 
    lambda = rand(1,1)*110; 
%     x = randn(n,1).*(sign(randn(n,1))-1); y = randn(n,1).*(sign(randn(n,1))-1); 
    
       x = randn(n,1); y = randn(n,1); 
    A = randn(1); B = randn(1)*10; C= randn(1)*10; D = randn(1)*10;
%     A=0; B=0;lambda=0.000001;
%      A=0; C=0;lambda=0.000001;

    
    HandleObj = @(t)A*sin(t) + B*cos(t) + C*sin(t)^2 + D*sin(t)*cos(t) + lambda*nnz2(sin(t)*x + cos(t)*y);

    HandleObj2 = @(c,s)A*s + B*c + C*s^2 + D*s*c + lambda*nnz2(s*x + c*y);
    options.MaxFunEvals = 5000000;
    options.MaxIter = 5000000;
    options.TolX = 1e-200;
    t0 = fminbnd(HandleObj,-1000,1000,options);
 
    f0 = HandleObj(t0);
    [c,s] = bps_l0norm_quadratic(A,B,C,D,lambda,x,y);

    f1 =  HandleObj2(c,s);
    fprintf('iter:%d, cs:%.10e %.10e, %f %f %e\n',iter,cos(t0),sin(t0),f0,f1,f0-f1);
    if(f0 <f1 && abs(f0 - f1) > 0.1)
        f0
        f1
        f0 - f1
        sin(t0)*x + cos(t0)*y
        ddd
        ddd
    end
end












