%format long;
fx=inline('3*x+sin(x)-exp(x)')
fplot ( fx, [ 0 2 ]) ; grid on
realroot=solve('3*x+sin(x)-exp(x)=0')
realroot=double(realroot);
[k1,x,y,err,S,F1]=muller(fx,0,0.5,1,10^-4,10^-4,15);
%gx=inline('log(3*x+sin(x))'); Try also with this
gx=inline('(exp(x)-sin(x))/3');
[k2,x,err,X,F2]=fixedpoint(gx,0.3,10^-4,15);
if k1>k2
max1=k1;
else
max1=k2;
end
disp('              Muller Fixed-Point   Muller  Fixed-Point')
disp('iteration      (x-r)     (x-r)      f(x)     f(x)')
for k=1:max1
   if k1>=k& k2>=k
plotyx1(k)=S(k)-realroot;
plotyx2(k)=X(k)-realroot;
plotxx1(k)=k;
plotxx2(k)=k;
   D=[k,plotyx1(k),plotyx2(k),F1(k),F2(k)];
   else if  k1<k& k2>=k
plotyx2(k)=X(k)-realroot;
plotxx2(k)=k;
   D=[k,S(k1)-realroot,plotyx2(k),F1(k1),F2(k)];
   else if  k1>=k& k2<k
plotyx1(k)=S(k)-realroot;
plotxx1(k)=k;
   D=[k,plotyx1(k),X(k2)-realroot,F1(k),F2(k2)];
   end
   end
   end
   disp(D); 
end
plot(plotxx1,plotyx1,plotxx2,plotyx2);
%plot(plotxx2,plotyx2);

xlabel('iteration, k');
ylabel('error, x-r');