06.09.2021 Views

First Semester in Numerical Analysis with Julia, 2020a

First Semester in Numerical Analysis with Julia, 2020a

First Semester in Numerical Analysis with Julia, 2020a

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 5. APPROXIMATION THEORY 185<br />

Out[8]: 2.607047619047626<br />

Next we plot the least squares l<strong>in</strong>e and the data together.<br />

In [9]: a=leastsqfit(xd,yd,1)<br />

xaxis=1:1/100:6<br />

yvals=map(x->poly(x,a),xaxis)<br />

plot(xaxis,yvals)<br />

scatter(xd,yd);<br />

We try a second degree polynomial <strong>in</strong> least squares approximation next.<br />

In [10]: a=leastsqfit(xd,yd,2)<br />

xaxis=1:1/100:6<br />

yvals=map(x->poly(x,a),xaxis)<br />

plot(xaxis,yvals)<br />

scatter(xd,yd);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!