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

79 lines
3.2 KiB
TeX

% 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$$
\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.
\end{document}