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