%%
addpath ../QR

npts = 10;
x = linspace(0,2,npts);
x = x(:);
n = length(x) ;
%%-------------------- approx. f=sin(pi x) by a cubic
F = [ones(npts,1), x ,x.^2, x.^3];
b = sin(pi*x);
%%-------------------- solve LS problem via Householder
a = hoLS(F, b)

%%-------------------- plot function with 100 points

npts = 100;

xn = linspace(0,2,npts)';

Fn = [ones(npts,1), xn ,xn.^2, xn.^3];
yn = Fn*a;
%% 
plot(xn,yn,'k--','linewidth',2)  
hold on 
plot(xn,sin(pi*xn),'r-','linewidth',2) 
%%-------------------- legend
h = legend('approx','orig function')
set(h,'fontsize',16)

