% Moore's Function (or 50th Degree Polynomial Problem)
% Range of initial points: 1 <= x <= 5
% Global minima: x=1.091165036224843
% f(x)=-663.5000966105010
% Coded by: Ali R. Alroomi | Last Update: 09 August 2015 | www.al-roomi.org
 
clear
clc
warning off
 
a=[-500.0,2.5,1.666666666,1.25,1.0,0.8333333,0.714285714,...
0.625,0.555555555,1.0,-43.6363636,0.41666666,0.384615384,...
0.357142857,0.3333333,0.3125,0.294117647,0.277777777,0.263157894,...
0.25,0.238095238,0.227272727,0.217391304,0.208333333,0.2,...
0.192307692,0.185185185,0.178571428,0.344827586,0.6666666,...
-15.48387097,0.15625,0.1515151,0.14705882,0.14285712,...
0.138888888,0.135135135,0.131578947,0.128205128,0.125,...
0.121951219,0.119047619,0.116279069,0.113636363,0.1111111,...
0.108695652,0.106382978,0.208333333,0.408163265,0.8];
 
xmin=1;
xmax=5;
R=100000; % steps resolution
x=xmin:(xmax-xmin)/R:xmax;
 
for i=1:length(x)
    
    for j=1:50
        P(j)=a(j)*x(i).^j;
    end
    
    f(i)=sum(P);
    
end
 
plot(x,f,'r','LineWidth',2);grid;set(gca,'FontSize',12);axis([1 1.17 -800 2000]);
xlabel('x','FontName','Times','FontSize',20,'FontAngle','italic');
ylabel('f(x)','FontName','Times','FontSize',20,'FontAngle','italic');