# channelflow.org

### Site Tools

gibson:teaching:fall-2016:math753:finitediff

# Differences

This shows you the differences between two versions of the page.

 gibson:teaching:fall-2016:math753:finitediff [2016/11/17 06:41]gibson gibson:teaching:fall-2016:math753:finitediff [2016/12/12 18:49] (current)gibson Both sides previous revision Previous revision 2016/12/12 18:49 gibson 2016/11/17 06:41 gibson 2016/11/17 06:40 gibson 2016/11/17 06:40 gibson 2016/11/17 06:39 gibson created 2016/12/12 18:49 gibson 2016/11/17 06:41 gibson 2016/11/17 06:40 gibson 2016/11/17 06:40 gibson 2016/11/17 06:39 gibson created Line 5: Line 5: === First derivative df/dx === === First derivative df/dx === - Given a set of evenly space gridpoints $x_1, x_2, \ldots$, where $x_i = x_1 + (i-1) h$, and a function evaluated at the gridpoints $f(x_1), ​f(x_2), \ldots$, we can approximate the first derivative of $f$ at the gridpoints several ways + Given a set of evenly space gridpoints $x_1, x_2, \ldots$, where $x_i = x_1 + (i-1) h$, and a function ​$y(x)$ ​evaluated at the gridpoints $y_1 = y(x_1), ​y_2 = y(x_2), \ldots$, we can approximate the first derivative of $y(x)$ at the gridpoints several ways **One-sided finite differencing for the first derivative**,​ rightwards **One-sided finite differencing for the first derivative**,​ rightwards \begin{equation*} \begin{equation*} - \frac{df}{dx}(x_i) = \frac{x_{i+1} - x_{i}}{h} + O(h) + \frac{dy}{dx}(x_i) = \frac{y_{i+1} - y_{i}}{h} + O(h) \end{equation*} \end{equation*} **One-sided finite differencing for the first derivative**,​ leftwards **One-sided finite differencing for the first derivative**,​ leftwards \begin{equation*} \begin{equation*} - \frac{df}{dx}(x_i) = \frac{x_{i} - x_{i-1}}{h} + O(h) + \frac{dy}{dx}(x_i) = \frac{y_{i} - y_{i-1}}{h} + O(h) \end{equation*} \end{equation*} **Centered finite differencing for the first derivative** **Centered finite differencing for the first derivative** \begin{equation*} \begin{equation*} - \frac{df}{dx}(x_i) = \frac{x_{i+1} - x_{i-1}}{2h} + O(h^2) + \frac{dy}{dx}(x_i) = \frac{y_{i+1} - y_{i-1}}{2h} + O(h^2) \end{equation*} \end{equation*} Line 26: Line 26: === Second derivative === === Second derivative === - To approximate the second derivative $d^2f/dx^2$, we use the + To approximate the second derivative $d^2y/dx^2$, we use the **Centered finite differencing for the second derivative** **Centered finite differencing for the second derivative** \begin{equation*} \begin{equation*} - \frac{d^2f}{dx^2}(x_i) = \frac{x_{i+1} - 2 x_i + x_{i-1}}{h^2} + O(h^2) + \frac{d^2y}{dx^2}(x_i) = \frac{y_{i+1} - 2 y_i + y_{i-1}}{h^2} + O(h^2) \end{equation*} \end{equation*}