g1 = @(x,y) (x^2+y^2);
g2 = @(x,y) (exp(x)+y^2);
%g3 = @(x,y,z) (x^2+y^2-10);
x0=0.5; y0=0.4; %z0=;
N = 3; % number of iterations
d=3; % number of decimal digits ==> use round()
%digits(d) % number of sig fig ==> use vpa()

p(1)=x0; q(1)=y0; %r(1)=z0;
for i=2:N+1
   p(i)=g1(p(i-1),q(i-1)); %p(i)=g1(p(i-1),q(i-1),r(i-1));
   q(i)=g2(p(i-1),q(i-1)); %q(i)=g2(p(i-1),q(i-1),r(i-1));
   %r(i)=g3(p(i-1),q(i-1),r(i-1));
   
   p(i)=round(p(i),d); %p(i)=vpa(p(i));
   q(i)=round(q(i),d); %q(i)=vpa(q(i));
   %r(i)=round(r(i),3); %r(i)=vpa(r(i));
   
   disp("p"+(i-1)+"=g1(p"+(i-1)+",q"+(i-1)+")=g1("+p(i-1)+","+q(i-1)+")="+p(i));
   %disp("p"+(i-1)+"=g1(p"+(i-1)+",q"+(i-1)+",r"+(i-1)+")=g1("+p(i-1)+","+q(i-1)+",r"+(i-1)+")="+p(i));

   disp("q"+(i-1)+"=g2(p"+(i-1)+",q"+(i-1)+")=g2("+p(i-1)+","+q(i-1)+")="+q(i));
   %disp("q"+(i-1)+"=g2(p"+(i-1)+",q"+(i-1)+",r"+(i-1)+")=g2("+p(i-1)+","+q(i-1)+",r"+(i-1)+")="+q(i));
   
   %disp("r"+(i-1)+"=g3(p"+(i-1)+",q"+(i-1)+",r"+(i-1)+")=g3("+p(i-1)+","+q(i-1)+",r"+(i-1)+")="+r(i));
   disp(' ');
end