% Pseudoethane Function
% Range of initial points: 0 <= x <= 2*pi
% Global minima: x=3.201787176863421
% f(x)=-1.071114593111043
% Coded by: Ali R. Alroomi | Last Update: 05 March 2015 | www.al-roomi.org
 
clear
clc
warning off
 
r0=1.54;
theta=109.5*(pi/180);
 
xmin=0;
xmax=2*pi;
R=100000; % steps resolution
x=xmin:(xmax-xmin)/R:xmax;
 
for i=1:length(x)
    f1=588600/((3*r0^2-4*r0^2*cos(theta)-2*((sin(theta)^2)*cos(x(i)-(2*pi/3))-cos(theta)^2)*r0^2)^6);
    f2=1079.1/((3*r0^2-4*r0^2*cos(theta)-2*((sin(theta)^2)*cos(x(i)-(2*pi/3))-cos(theta)^2)*r0^2)^3);
    f3=600800/((3*r0^2-4*r0^2*cos(theta)-2*((sin(theta)^2)*cos(x(i))-cos(theta)^2)*r0^2)^6);
    f4=1071.5/((3*r0^2-4*r0^2*cos(theta)-2*((sin(theta)^2)*cos(x(i))-cos(theta)^2)*r0^2)^3);
    f5=481300/((3*r0^2-4*r0^2*cos(theta)-2*((sin(theta)^2)*cos(x(i)+(2*pi/3))-cos(theta)^2)*r0^2)^6);
    f6=1064.6/((3*r0^2-4*r0^2*cos(theta)-2*((sin(theta)^2)*cos(x(i)+(2*pi/3))-cos(theta)^2)*r0^2)^3);
    f(i)=f1-f2+f3-f4+f5-f6;
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');