This repository has been archived on 2021-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
ICS/hw4/hw4.tex

178 lines
7 KiB
TeX
Raw Normal View History

2020-05-14 13:52:49 +00:00
% vim: set ts=2 sw=2 et tw=80:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc} \usepackage[margin=2cm]{geometry}
\usepackage{amstext} \usepackage{amsmath} \usepackage{array}
\newcommand{\lra}{\Leftrightarrow}
\title{Howework 4 -- Introduction to Computational Science}
\author{Claudio Maggioni}
\begin{document} \maketitle
\section*{Question 1}
$$L_0(x) = \prod_{j = 0, j \neq 0}^n \frac{x - x_j}{x_i - x_j} =
\frac{x - (-0.5)}{(-1) - (-0.5)} \cdot \frac{x - 0.5}{(-1) - 0.5} \cdot
\frac{x - 1}{(-1) - 1} = -\frac{2}{3}x^3 + \frac{2}{3}x^2
+\frac{1}{6} x - \frac{1}{6}$$
$$L_1(x) = \prod_{j = 0, j \neq 1}^n \frac{x - x_j}{x_i - x_j} =
\frac{x - (-1)}{(-0.5) - (-1)} \cdot \frac{x - 0.5}{(-0.5) - 0.5} \cdot
\frac{x - 1}{(-0.5) - 1} = \frac{4}{3}x^3 - \frac{2}{3}x^2 - \frac{4}{3}x + \frac{2}{3}$$
$$L_2(x) = \prod_{j = 0, j \neq 2}^n \frac{x - x_j}{x_i - x_j} =
\frac{x - (-1)}{0.5 - (-1)} \cdot \frac{x - (-0.5)}{0.5 - (-0.5)} \cdot
\frac{x - 1}{0.5 - 1} = -\frac{4}{3}x^3 - \frac{2}{3}x^2 + \frac{4}{3}x + \frac{2}{3}$$
$$L_3(x) = \prod_{j = 0, j \neq 3}^n \frac{x - x_j}{x_i - x_j} =
\frac{x - (-1)}{1 - (-1)} \cdot \frac{x - (-0.5)}{1 - (-0.5)} \cdot
\frac{x - 0.5}{1 - 0.5} = \frac{2}{3}x^3 + \frac{2}{3}x^2 -\frac{1}{6}x - \frac{1}{6}$$
$$p(x) = \sum_{i=0}^n y_i L_i(x) =
2 \cdot \left(-\frac{2}{3}x^3 + \frac{2}{3}x^2
+\frac{1}{6} x - \frac{1}{6}\right) +
1 \cdot \left(\frac{4}{3}x^3 - \frac{2}{3}x^2 - \frac{4}{3}x + \frac{2}{3}\right) +
$$$$
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$$
$$\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$$
The statement above is true so p satisfies the error estimate:
$$\max_{x \in [-1,1]} |f(x) - p(x)| \leq 8$$
2020-05-15 13:19:53 +00:00
\section*{Question 2}
We first use the Lagrange method:
$$L_1(x) = \prod_{j = 0, j \neq 1}^2 \frac{x - x_j}{x_i - x_j} =
\frac{x-0}{1-0} \frac{x-3}{1-3} = -\frac{1}{2}x^2 + \frac{3}{2}x$$
$$L_2(x) = \prod_{j = 0, j \neq 2}^2 \frac{x - x_j}{x_i - x_j} =
\frac{x-0}{3-0} \frac{x-1}{3-1} = \frac{1}{6}x^2 - \frac{1}{6}x $$
$$p(x) = (-3) \cdot \left(-\frac{1}{2}x^2 + \frac{3}{2}x\right) +
1 \cdot \left(\frac{1}{6}x^2 - \frac{1}{6}x\right) =
\frac{5}{3}x^2 - \frac{14}{3}x$$
Then we use the Newtonian method:
$$a_0 = f[0] = 0, \hspace{2cm} f[1] = -3 \hspace{2cm} f[3] = 1$$
$$a_1 = f[0,1] = \frac{-3-0}{1-0} = -3, \hspace{2cm} f[1,3] = \frac{1-(-3)}{3-1} = 2 $$
$$a_2 = f[0,1,3] = \frac{2-(-3)}{3-0} = \frac{5}{3}$$
$$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.
2020-05-16 11:58:14 +00:00
\section*{Question 4}
\subsection*{Point a)}
The node coordinates to which fix the quadratic spline are $(1/2, y_0), (1, y_1),(3/2, y_2),(2, y_3)$.
Then, we can start formulating the equations for the linear system:
$$y_0 = s\left(\frac{1}{2}\right) = a_{-1}B_2\left(\frac{1}{2} + 1\right) + a_{0}B_2\left(\frac{1}{2}\right) + a_{1}B_2\left(\frac{1}{2} - 1\right) + $$$$
+ a_{2}B_2\left(\frac{1}{2} - 2\right)
+ a_{-1}B_2\left(\frac{1}{2} - 3\right)
+ a_{0}B_2\left(\frac{1}{2} - 4\right)
+ a_{1}B_2\left(\frac{1}{2} - 5\right)=$$$$
a_{-1} \cdot 0 + a_{0} \cdot \frac{1}{2} + a_{1} \cdot \frac{1}{2} + a_{2} \cdot 0 + a_{-1} \cdot 0 + a_{0} \cdot 0 + a_{1} \cdot 0 = \frac{a_0 + a_1}{2}$$
$$y_1 = s\left(1\right) = a_{-1}B_2\left(1 + 1\right) + a_{0}B_2\left(1\right) + a_{1}B_2\left(1 - 1\right) + $$$$
+ a_{2}B_2\left(1 - 2\right)
+ a_{-1}B_2\left(1 - 3\right)
+ a_{0}B_2\left(1 - 4\right)
+ a_{1}B_2\left(1 - 5\right)=$$$$
a_{-1} \cdot 0 + a_{0} \cdot \left(\frac{1}{8}\right) + a_{1} \cdot \frac{3}{4} + a_{2} \cdot \left(\frac{1}{8}\right) + a_{-1} \cdot 0 + a_{0} \cdot 0 + a_{1} \cdot 0 =
\frac{1}{8} a_{0} + \frac{3}{4} a_{1} + \frac{1}{8} a_{2}$$
$$y_2 = s\left(\frac{3}{2}\right) = a_{-1}B_2\left(\frac{3}{2} + 1\right) + a_{0}B_2\left(\frac{3}{2}\right) + a_{1}B_2\left(\frac{3}{2} - 1\right) + $$$$
+ a_{2}B_2\left(\frac{3}{2} - 2\right)
+ a_{-1}B_2\left(\frac{3}{2} - 3\right)
+ a_{0}B_2\left(\frac{3}{2} - 4\right)
+ a_{1}B_2\left(\frac{3}{2} - 5\right)=$$$$
a_{-1} \cdot 0 + a_{0} \cdot 0 + a_{1} \cdot \frac{1}{2} + a_{2} \cdot \frac{1}{2} + a_{-1} \cdot 0 + a_{0} \cdot 0 + a_{1} \cdot 0 = \frac{a_1 + a_2}{2}$$
$$y_3 = s\left(2\right) = a_{-1}B_2\left(2 + 1\right) + a_{0}B_2\left(2\right) + a_{1}B_2\left(2 - 1\right) + $$$$
+ a_{2}B_2\left(2 - 2\right)
+ a_{-1}B_2\left(2 - 3\right)
+ a_{0}B_2\left(2 - 4\right)
+ a_{1}B_2\left(2 - 5\right)=$$$$
a_{-1} \cdot 0 + a_{0} \cdot 0 + a_{1} \cdot \left(\frac{1}{8}\right) + a_{2} \cdot \frac{3}{4} + a_{-1} \cdot \left(\frac{1}{8}\right) + a_{0} \cdot 0 + a_{1} \cdot 0 =
\frac{1}{8} a_{1} + \frac{3}{4} a_{2} + \frac{1}{8} a_{-1}$$
The linear system in matrix form is:
\[\frac{1}{8} \cdot
\begin{bmatrix}
4&4&0&0\\
1&6&1&0\\
0&4&4&0\\
0&1&6&1\\
\end{bmatrix}
\begin{bmatrix}
a_0\\a_1\\a_2\\a_{-1}\\
\end{bmatrix}
=
\begin{bmatrix}
y_0\\y_1\\y_2\\y_{3}\\
\end{bmatrix}\]
The determinant of that matrix is 0 so the matrix is singular.
\subsection*{Point b)}
The node coordinates to which fix the quadratic spline are $(0, y_0), (1, y_1),(2, y_2),(3, y_3)$.
Then, we can start formulating the equations for the linear system:
$$y_0 = s(0) = a_{-1}B_2\left(1\right) + a_{0}B_2\left(0\right) + a_{1}B_2\left(- 1\right) + $$$$
+ a_{2}B_2\left(- 2\right)
+ a_{-1}B_2\left(- 3\right)
+ a_{0}B_2\left(- 4\right)
+ a_{1}B_2\left(- 5\right)=$$$$
a_{-1} \cdot \frac{1}{8} + a_{0} \cdot \frac{3}{4} + a_{1} \cdot \frac{1}{8} + a_{2} \cdot 0 + a_{-1} \cdot 0 + a_{0} \cdot 0 + a_{1} \cdot 0 =
\frac{1}{8} a_{-1} + \frac{3}{4} a_{0} + \frac{1}{8} a_{1}$$
$$y_1 = s\left(1\right) = \frac{1}{8} a_{0} + \frac{3}{4} a_{1} + \frac{1}{8} a_{2}$$
$$y_2 = s\left(2\right) = \frac{1}{8} a_{1} + \frac{3}{4} a_{2} + \frac{1}{8} a_{-1}$$
$$y_3 = s\left(3\right) = a_{-1}B_2\left(3 + 1\right) + a_{0}B_2\left(3\right) + a_{1}B_2\left(3 - 1\right) + $$$$
+ a_{2}B_2\left(3 - 2\right)
+ a_{-1}B_2\left(3 - 3\right)
+ a_{0}B_2\left(3 - 4\right)
+ a_{1}B_2\left(3 - 5\right)=$$$$
a_{-1} \cdot 0 + a_{0} \cdot 0 + a_{1} \cdot 0 + a_{2} \cdot \frac{1}{8} + a_{-1} \cdot \frac{3}{4} + a_{0} \cdot \frac{1}{8} + a_{1} \cdot 0 =
\frac{1}{8} a_{2} + \frac{3}{4} a_{-1} + \frac{1}{8} a_{0}$$
The linear system in matrix form is:
\[\frac{1}{8} \cdot
\begin{bmatrix}
6&1&0&1\\
1&6&1&0\\
0&1&6&1\\
1&0&1&6\\
\end{bmatrix}
\begin{bmatrix}
a_0\\a_1\\a_2\\a_{-1}\\
\end{bmatrix}
=
\begin{bmatrix}
y_0\\y_1\\y_2\\y_{3}\\
\end{bmatrix}\]
2020-05-14 13:52:49 +00:00
\end{document}