clear all;
close all;
clc;

figure(1)
x = linspace(-1,1,256);
Px = monic3term(5,x,'legendre');
subplot(2,2,1)
plot(x,Px(2,:),x,x,'r')
title('name = legendre, P_1')
subplot(2,2,2)
plot(x,Px(3,:),x,x.^2-1/3,'r')
title('name = legendre, P_2')
subplot(2,2,3)
plot(x,Px(4,:),x,x.^3-3/5*x,'r')
title('name = legendre, P_3')
subplot(2,2,4)
plot(x,Px(5,:),x,x.^4-30/35*x.^2 + 3/35,'r')
title('name = legendre, P_4')


figure(2)
x = linspace(0,5,256);
Px = monic3term(5,x,'laguerre');
subplot(2,2,1)
plot(x,Px(2,:),x,x-1,'r')
title('name = laguerre, P_1')
subplot(2,2,2)
plot(x,Px(3,:),x,x.^2-4*x+2,'r')
title('name = laguerre, P_2')
subplot(2,2,3)
plot(x,Px(4,:),x,x.^3-9*x.^2+18*x-6,'r')
title('name = laguerre, P_3')
subplot(2,2,4)
plot(x,Px(5,:),x,x.^4-16*x.^3+72*x.^2 - 96*x + 24,'r')
title('name = laguerre, P_4')


figure(3)
x = linspace(-1,1,256);
Px = monic3term(5,x,'tscheb');
subplot(2,2,1)
plot(x,Px(2,:),x,x,'r')
title('name = tscheb, P_1')
subplot(2,2,2)
plot(x,Px(3,:),x,x.^2-1/2,'r')
title('name = tscheb, P_2')
subplot(2,2,3)
plot(x,Px(4,:),x,x.^3-3/4*x,'r')
title('name = tscheb, P_3')
subplot(2,2,4)
plot(x,Px(5,:),x,x.^4-x.^2+1/8,'r')
title('name = tscheb, P_4')

figure(4)
x = linspace(-1,1,256);
Px = monic3term(5,x,'hermite');
subplot(2,2,1)
plot(x,Px(2,:),x,x,'r')
title('name = hermite, P_1')
subplot(2,2,2)
plot(x,Px(3,:),x,x.^2-1/2,'r')
title('name = hermite, P_2')
subplot(2,2,3)
plot(x,Px(4,:),x,x.^3-3/2*x,'r')
title('name = hermite, P_3')
subplot(2,2,4)
plot(x,Px(5,:),x,x.^4-48/16*x.^2+12/16,'r')
title('name = hermite, P_4')