Examples from Data fitting and polynomial interpolation All examples from Data fitting and polynomial interpolation.
[ EXAMPLE ] For ( 0 , 2 ) (0,2) ( 0 , 2 ) , ( 3 , 4 ) (3,4) ( 3 , 4 ) and ( 4 , 4 ) (4,4) ( 4 , 4 ) ,
M = ( 0 1 3 1 4 1 ) , Y = ( 2 4 4 ) . M=
\begin{pmatrix}
0&1\\
3&1\\
4&1
\end{pmatrix},
\qquad
Y=
\begin{pmatrix}
2\\4\\4
\end{pmatrix}. M = 0 3 4 1 1 1 , Y = 2 4 4 . Here
M T M = ( 25 7 7 3 ) , M T Y = ( 28 10 ) . M^{\mathsf T}M=
\begin{pmatrix}25&7\\7&3\end{pmatrix},
\qquad
M^{\mathsf T}Y=\binom{28}{10}. M T M = ( 25 7 7 3 ) , M T Y = ( 10 28 ) . The determinant of M T M M^{\mathsf T}M M T M is 26 26 26 and solving the normal
equations gives
( m c ) = 1 26 ( 3 − 7 − 7 25 ) ( 28 10 ) = ( 7 / 13 27 / 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}. ( m c ) = 26 1 ( 3 − 7 − 7 25 ) ( 10 28 ) = ( 7/13 27/13 ) . Thus the best-fit line is
y = 7 13 t + 27 13 . y=\frac{7}{13}t+\frac{27}{13}. y = 13 7 t + 13 27 . It does not pass through all three data points; it minimises their total
squared vertical error.
[RIGHT CLICK] [ASK AI]
[ EXAMPLE ] For
g ( x ) = x − 9 − x , g(x)=x-9^{-x}, g ( x ) = x − 9 − x , use the inputs 0 , 1 2 , 1 0,\frac12,1 0 , 2 1 , 1 . The data values are
g ( 0 ) = − 1 , g ( 1 2 ) = 1 6 , g ( 1 ) = 8 9 . g(0)=-1,\qquad g\left(\frac12\right)=\frac16,\qquad g(1)=\frac89. g ( 0 ) = − 1 , g ( 2 1 ) = 6 1 , g ( 1 ) = 9 8 . The corresponding Lagrange polynomials are
ℓ 1 ( t ) = 2 ( t − 1 2 ) ( t − 1 ) , ℓ 2 ( t ) = − 4 t ( t − 1 ) , ℓ 3 ( t ) = 2 t ( t − 1 2 ) . \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). ℓ 1 ( t ) = 2 ( t − 2 1 ) ( t − 1 ) , ℓ 2 ( t ) = − 4 t ( t − 1 ) , ℓ 3 ( t ) = 2 t ( t − 2 1 ) . Therefore
p ( t ) = − ℓ 1 ( t ) + 1 6 ℓ 2 ( t ) + 8 9 ℓ 3 ( t ) = − 1 + 25 9 t − 8 9 t 2 . \begin{aligned}
p(t)
&=-\ell_1(t)+\frac16\ell_2(t)+\frac89\ell_3(t)\\
&=-1+\frac{25}{9}t-\frac89t^2.
\end{aligned} p ( t ) = − ℓ 1 ( t ) + 6 1 ℓ 2 ( t ) + 9 8 ℓ 3 ( t ) = − 1 + 9 25 t − 9 8 t 2 . Solving p ( t ) = 0 p(t)=0 p ( t ) = 0 gives
8 t 2 − 25 t + 9 = 0 , t = 25 ± 337 16 . 8t^2-25t+9=0,
\qquad
t=\frac{25\pm\sqrt{337}}{16}. 8 t 2 − 25 t + 9 = 0 , t = 16 25 ± 337 . The root of the interpolating polynomial in the data range is
t ≈ 0.415. t\approx 0.415. t ≈ 0.415. This root is chosen because the sampled values change sign between 0 0 0
and 1 2 \frac12 2 1 ; the other quadratic root lies outside the data interval.
It approximates the root of g g g itself, which is about 0.408004 0.408004 0.408004 .
Interpolation is exact at the sampled values, not at a zero between sample
points.
[RIGHT CLICK] [ASK AI]
Data fitting and polynomial interpolation Builds on Basis and dimension and 2 more.