% Rokne's Function # 2
% Range of initial points: 0 <= x <= 2
% Global minima: x=1
% f(x)=0
% Coded by: Ali R. Alroomi | Last Update: 29 June 2015 | www.al-roomi.org
 
clear
clc
warning off
 
xmin=0;
xmax=2;
R=100000; % steps resolution
x=xmin:(xmax-xmin)/R:xmax;
 
for i=1:length(x)
    f(i)=x(i)^10-10*x(i)^9+45*x(i)^8-120*x(i)^7+210*x(i)^6-252*x(i)^5+210*x(i)^4-120*x(i)^3+45*x(i)^2-10*x(i)+1;
end
 
plot(x,f,'r','LineWidth',2);grid;set(gca,'FontSize',12);
xlabel('x','FontName','Times','FontSize',20,'FontAngle','italic');
ylabel('f(x)','FontName','Times','FontSize',20,'FontAngle','italic');