hw4: done 1,2,3,4,5

This commit is contained in:
Claudio Maggioni (maggicl) 2020-05-16 15:37:49 +02:00
parent ea73cb66aa
commit c4990cab11
2 changed files with 137 additions and 5 deletions

Binary file not shown.

View File

@ -37,16 +37,16 @@ $$$$
0.5 \cdot \left(-\frac{4}{3}x^3 - \frac{2}{3}x^2 + \frac{4}{3}x + \frac{2}{3}\right) +
0.4 \cdot \left(\frac{2}{3}x^3 + \frac{2}{3}x^2 -\frac{1}{6}x - \frac{1}{6}\right) = -\frac{2}{5}x^3 + \frac{3}{5}x^2 - \frac{2}{5}x + \frac{3}{5}$$
$$\frac{\max_{x \in [-1,1]} |f^{(n+1)}|}{5!} =
\frac{\max_{x \in [-1,1]}|\frac{7680}{|2x+3|^6}|}{120} =
\max_{x \in [-1,1]}\frac{64}{|2x+3|^6} = 64$$
$$\frac{\max_{x \in [-1,1]} |f^{(n+1)}|}{4!} =
\frac{\max_{x \in [-1,1]}|\frac{768}{|2x+3|^6}|}{24} =
\max_{x \in [-1,1]}\frac{32}{|2x+3|^6} = 32$$
$$\max_{x \in [-1,1]} \left|(x - 1)\left(x - \frac{1}{2}\right)
\left(x + \frac{1}{2}\right)(x+1)\right| =
\max_{x \in [-1,1]} \left| x^4 - \frac{5}{4}x^2 + \frac{1}{4}\right| = \frac{1}{4}$$
$$\max_{x \in [-1,1]} |f(x) - p(x)| \leq \frac{\max_{x \in [-1,1]} |f^{(n+1)}|}{5!} \max_{x \in [-1,1]} \left|(x - 1)\left(x - \frac{1}{2}\right)
\left(x + \frac{1}{2}\right)(x+1)\right| =$$$$= 64 \cdot \frac{1}{4} = 8 \leq 8$$
$$\max_{x \in [-1,1]} |f(x) - p(x)| \leq \frac{\max_{x \in [-1,1]} |f^{(n+1)}|}{4!} \max_{x \in [-1,1]} \left|(x - 1)\left(x - \frac{1}{2}\right)
\left(x + \frac{1}{2}\right)(x+1)\right| =$$$$= 32 \cdot \frac{1}{4} = 8 \leq 8$$
The statement above is true so p satisfies the error estimate:
@ -76,6 +76,16 @@ $$p(x) = \left(\frac{5}{3}(x-1)-3\right) x + 0 = \frac{5}{3}x^2 - \frac{14}{3}x$
The interpolating polynomials are indeed equal.
Now we use the Horner method to compute $p(0.5)$:
$$y=a_n = a_2 = \frac{5}{3}$$
$$i = 1$$
$$y = y (x - x_1) + a_1 = \frac{5}{3} (0.5 - 1) + a_1 - 3 = -\frac{5}{6} - 3 = -\frac{23}{6}$$
$$i = 0$$
$$y = y (x - x_0) + a_0 = -\frac{23}{6} \cdot 0.5 + 0 = -\frac{23}{12}$$
\section*{Question 4}
\subsection*{Point a)}
@ -174,4 +184,126 @@ a_0\\a_1\\a_2\\a_{-1}\\
y_0\\y_1\\y_2\\y_{3}\\
\end{bmatrix}\]
\subsection*{Question 5}
$$1 = y_0 = s(x_0) = 0 = a_{-1}B_3(1) +a_0B_3(0)
+a_1B_3(-1)
+a_2B_3(-2)
+a_3B_3(-3) = \frac{1}{6}a_{-1} + \frac{2}{3}a_0 + \frac{1}{6}a_1$$
$$5 = y_1 = s(x_1) = 1 = a_{-1}B_3(2) +a_0B_3(1)
+a_1B_3(0)
+a_2B_3(-1)
+a_3B_3(-2) = \frac{1}{6}a_{0} + \frac{2}{3}a_1 + \frac{1}{6}a_2$$
$$1 = y_2 = s(x_2) = 2 = a_{-1}B_3(3) +a_0B_3(2)
+a_1B_3(1)
+a_2B_3(0)
+a_3B_3(-1) = \frac{1}{6}a_{1} + \frac{2}{3}a_2 + \frac{1}{6}a_3$$
$$s''(0) = a_{-1}B''_3(1) +a_0B''_3(0)
+a_1B''_3(-1)
+a_2B''_3(-2)
+a_3B''_3(-3) = a_{-1} - 2 a_0 + a_{1}$$
$$s''(2) = a_{-1}B''_3(3) +a_0B''_3(2)
+a_1B''_3(1)
+a_2B''_3(-0)
+a_3B''_3(-1) = a_{1} - 2 a_2 + a_{3}$$
\[\frac{1}{6} \cdot
\begin{bmatrix}
1&-2&1&0&0\\
1&4&1&0&0\\
0&1&4&1&0\\
0&0&1&4&1\\
0&0&1&-2&1\\
\end{bmatrix}
\begin{bmatrix}
a_{-1}\\a_0\\a_1\\a_2\\a_3\\
\end{bmatrix}
=
\begin{bmatrix}
0\\y_0\\y_1\\y_2\\0\\
\end{bmatrix}\]
We then use Gaussian \textit{ellimination} to solve the system.
\[
\begin{array}{@{}ccccc|c@{}}
1&-2&1&0&0&0\\
1&4&1&0&0&6\\
0&1&4&1&0&30\\
0&0&1&4&1&6\\
0&0&1&-2&1&0\\
\end{array}
\qquad
\begin{array}{@{}ccccc|c@{}}
1&-2&1&0&0&0\\
0&6&0&0&0&6\\
0&1&4&1&0&30\\
0&0&1&4&1&6\\
0&0&1&-2&1&0\\
\end{array}
\qquad
\begin{array}{@{}ccccc|c@{}}
1&-2&1&0&0&0\\
0&1&4&1&0&30\\
0&6&0&0&0&6\\
0&0&1&4&1&6\\
0&0&1&-2&1&0\\
\end{array}
\]
\[
\begin{array}{@{}ccccc|c@{}}
1&0&9&2&0&60\\
0&1&4&1&0&30\\
0&0&-24&-6&0&-174\\
0&0&1&4&1&6\\
0&0&1&-2&1&0\\
\end{array}
\qquad
\begin{array}{@{}ccccc|c@{}}
1&0&9&2&0&60\\
0&1&4&1&0&30\\
0&0&1&4&1&6\\
0&0&-24&-6&0&-174\\
0&0&1&-2&1&0\\
\end{array}
\qquad
\begin{array}{@{}ccccc|c@{}}
1&0&0&-34&-9&6\\
0&1&0&-15&-4&6\\
0&0&1&4&1&6\\
0&0&0&90&24&-30\\
0&0&0&6&0&-6\\
\end{array}
\]
\[
\begin{array}{@{}ccccc|c@{}}
1&0&0&-34&-9&6\\
0&1&0&-15&-4&6\\
0&0&1&4&1&6\\
0&0&0&1&4/15&-1/3\\
0&0&0&6&0&-6\\
\end{array}
\qquad
\begin{array}{@{}ccccc|c@{}}
1 & 0 & 0 & 0 & 1/15 & -16/3 \\
0 & 1 & 0 & 0 & 0 & 1 \\
0 & 0 & 1 & 0 & -1/15 & 22/3 \\
0 & 0 & 0 & 1 & 4/15 & -1/3 \\
0 & 0 & 0 & 0 & 8/5 & -8 \\
\end{array}
\qquad
\begin{array}{@{}ccccc|c@{}}
1 & 0 & 0 & 0 & 0 & -5 \\
0 & 1 & 0 & 0 & 0 & 1 \\
0 & 0 & 1 & 0 & 0 & 7 \\
0 & 0 & 0 & 1 & 0 & 1 \\
0 & 0 & 0 & 0 & 1 & -5 \\
\end{array}
\]
Therefore, the coefficients are $a_{-1} = a_3 = -5$, $a_0 = a_2 = 1$, and $a_1 = 7$.
\end{document}