for i=1:60

  x(i)=i/20;

  y0(i) = 1;
  y1(i) = y0(i) - (x(i)-1)^1;
  y2(i) = y1(i) + (x(i)-1)^2;
  y3(i) = y2(i) - (x(i)-1)^3;
  y4(i) = y3(i) + (x(i)-1)^4;
  y5(i) = y4(i) - (x(i)-1)^5;
  y6(i) = y5(i) + (x(i)-1)^6;

  yexact(i) = 1/x(i);

end

plot(x,yexact,'b');
hold on;
plot(x,y1,'b');
hold on;
plot(x,y2,'c');
hold on;
plot(x,y3,'y');
hold on;
plot(x,y4,'g');
hold on;
plot(x,y5,'m');
hold on;
plot(x,y6,'r');
hold on;

% Label the plot

title('Fourier expansion for 1/x');
xlabel('x');
ylabel('p(x)');
legend('exact','p0','p1','p2','p3','p4','p5')

