Type a command or search the notes. Tab cycles completions. Up and down recall history when blank. Escape dismisses, then leaves the prompt.
MATH
[1251]

Examples from Data fitting and polynomial interpolation

All examples from Data fitting and polynomial interpolation.

A least-squares line

For (0,2)(0,2), (3,4)(3,4) and (4,4)(4,4),

M=(013141),Y=(244).M= \begin{pmatrix} 0&1\\ 3&1\\ 4&1 \end{pmatrix}, \qquad Y= \begin{pmatrix} 2\\4\\4 \end{pmatrix}.

Here

MTM=(25773),MTY=(2810).M^{\mathsf T}M= \begin{pmatrix}25&7\\7&3\end{pmatrix}, \qquad M^{\mathsf T}Y=\binom{28}{10}.

The determinant of MTMM^{\mathsf T}M is 2626 and solving the normal equations gives

(mc)=126(3−7−725)(2810)=(7/1327/13).\begin{pmatrix}m\\c\end{pmatrix} =\frac1{26} \begin{pmatrix}3&-7\\-7&25\end{pmatrix} \binom{28}{10} =\begin{pmatrix}7/13\\27/13\end{pmatrix}.

Thus the best-fit line is

y=713t+2713.y=\frac{7}{13}t+\frac{27}{13}.

It does not pass through all three data points; it minimises their total squared vertical error.

Estimating a root from an interpolant

For

g(x)=x−9−x,g(x)=x-9^{-x},

use the inputs 0,12,10,\frac12,1. The data values are

g(0)=−1,g(12)=16,g(1)=89.g(0)=-1,\qquad g\left(\frac12\right)=\frac16,\qquad g(1)=\frac89.

The corresponding Lagrange polynomials are

ℓ1(t)=2(t−12)(t−1),ℓ2(t)=−4t(t−1),ℓ3(t)=2t(t−12).\ell_1(t)=2\left(t-\frac12\right)(t-1),\qquad \ell_2(t)=-4t(t-1),\qquad \ell_3(t)=2t\left(t-\frac12\right).

Therefore

p(t)=−ℓ1(t)+16ℓ2(t)+89ℓ3(t)=−1+259t−89t2.\begin{aligned} p(t) &=-\ell_1(t)+\frac16\ell_2(t)+\frac89\ell_3(t)\\ &=-1+\frac{25}{9}t-\frac89t^2. \end{aligned}

Solving p(t)=0p(t)=0 gives

8t2−25t+9=0,t=25±33716.8t^2-25t+9=0, \qquad t=\frac{25\pm\sqrt{337}}{16}.

The root of the interpolating polynomial in the data range is

t≈0.415.t\approx 0.415.

This root is chosen because the sampled values change sign between 00 and 12\frac12; the other quadratic root lies outside the data interval. It approximates the root of gg itself, which is about 0.4080040.408004. Interpolation is exact at the sampled values, not at a zero between sample points.

On this page