{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Tutorial 05 - Function approximation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Piece-wise linear interpolation, Lagrange interpolation and Neville’s algorithm, Chebyshev polynomials and approximation, polynomial least squares fit." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from scipy import linalg, interpolate, special\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Local interpolation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Linear interpolation\n", "\n", "[Linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation) is defined as a concatenation of straight lines connecting each pair of the set of known points. If the two known points are given by the coordinates $ (x_{i}, y_{i}) $ and $ (x_{i + 1}, y_{i + 1}) $, the linear interpolation in the interval $ (x_{i}, x_{i + 1}) $ is given by the following formula,\n", "\n", "$$\n", "y = y_i + \\alpha (x - x_i), \\qquad x \\in [x_i, x_{i+1}],\n", "$$\n", "\n", "where\n", "\n", "$$\n", "\\alpha = \\frac{y_{i+1} - y_{i}}{x_{i + 1} - x_{i}}.\n", "$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "