function demo_find_minima()
fstr_org=input('key in a 1D function:','s');
v=[];
ep=10^-6;
fstr=demo_diff(fstr_org);
for i=1:50
    x0=rand(1,1)*10-5;
    r=fzero(fstr,x0);
    if sum(find(abs(v-r)<ep)) == 0
        v=[v r];
    end
end
v
fx=inline(fstr_org);
x=linspace(-5,5);
%plot(v,zeros(size(v)),'bo');
plot(v,fx(v),'bo');
return
function ss1=demo_diff(ss)
% input a string to specify a function
% plot its derivative
fx=inline(ss);
x=sym('x');
ss=['diff(' ss ')'];
ss1=char(eval([sprintf(ss)]));
fx1=inline(ss1)
x=linspace(-5,5);
plot(x,fx(x),'r');hold on;
%for i=1:length(x)
%    y(i)=fx1(x(i));
%end
%plot(x,y,'b');
return