function [x_star,fval]=SA_matlab()

% For reproducibility:
rng default 

% Function handle for cost function:
CostFunction = @myfun;

% Starting point
x0 = 3;   

% **************************************************
% Call SA solver, use verbose mode:

options = optimoptions('simulannealbnd',...
    'FunctionTolerance',1e-8,'PlotFcns',...
     {@saplotbestx,@saplotbestf,@saplotx,@saplotf});
      
[x_star,~] = simulannealbnd(CostFunction,x0,[],[],options);

% After getting a rough idea of the position of 
% the global minimum using SA, I now refine the 
% estimate using local optimization methods:

[x_star,fval] = fminunc(CostFunction,x_star);

% **************************************************

    function y=myfun(x)
        y=sin(x)/(x*x+10);
    end
        
end