=40;
randn(<span class="string">'state'</span>,0);
<span class="comment">% generate 50 ponts ui, vi</span>
u = linspace(-1,1,m);
v = 1./(5+40*u.^2) + 0.1*u.^3 + 0.01*randn(1,m);


<span class="comment">% LS fit polynomial x_1 + x_2*u + ... + x_n*u^(n-1) to (ui,vi)</span>
fprintf(1,<span class="string">'Computing optimal polynomial in the case of L2-norm...'</span>);

A = vander(u');
A = A(:,m-n+[1:n]);     <span class="comment">% last n columns of A</span>
x = A\(v');             <span class="comment">% coe