From 183c55c09e62c069d65b2f5d9f5d7c065ad16228 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Wed, 3 Sep 2025 13:19:49 -0600 Subject: Updated entries --- tutorials/module_3/numerical_differentiation.md | 67 ------------------------- 1 file changed, 67 deletions(-) delete mode 100644 tutorials/module_3/numerical_differentiation.md (limited to 'tutorials/module_3/numerical_differentiation.md') diff --git a/tutorials/module_3/numerical_differentiation.md b/tutorials/module_3/numerical_differentiation.md deleted file mode 100644 index b34b315..0000000 --- a/tutorials/module_3/numerical_differentiation.md +++ /dev/null @@ -1,67 +0,0 @@ -# Numerical Differentiation -Finding a derivative of tabular data can be done using a finite difference. Here we essentially pick two points on a function or a set of data points and calculate the slope from there. Let's imagine a domain $x$ as a vector such that $\vec{x}$ = $\pmatrix{x_0, x_1, x_2, ...}$. Then we can use the following methods to approximate derivatives - -## Forward Difference -Uses the point at which we want to find the derivative and a point forwards on the line. -$$ -f'(x_i) = \frac{f(x_{i+1})-f(x_i)}{x_{i+1}-x_i} -$$ -*Hint: Consider what happens at the last point.* - -```python -import numpy as np -import matplotlib.pyplot as plt - -# Initiate vectors -x = np.linspace(0, 2, 100) -y = 34 * np.exp(3 * x) - -dydx = (y[1:] - y[:-1]) / (x[1:] - x[:-1]) - -# Plot the function -plt.plot(x, y, label=r'$y(x)$') -plt.plot(x, dydx, label=b'$/frac{dy}{dx}$') -plt.xlabel('x') -plt.ylabel('y') -plt.title('Plot of $34e^{3x}$') -plt.grid(True) -plt.legend() -plt.show() -``` - - -## Backwards Difference -Uses the point at which we want to find -$$ -f'(x_i) = \frac{f(x_{i})-f(x_{i-1})}{x_i - x_{i-1}} -$$ - - -```python -import numpy as np -import matplotlib.pyplot as plt - -# Initiate vectors -x = np.linspace(0, 2, 100) -y = 34 * np.exp(3 * x) - -dydx = (y[1:] - y[:-1]) / (x[1:] - x[:-1]) - -# Plot the function -plt.plot(x, y, label=r'$y(x)$') -plt.plot(x, dydx, label=b'$/frac{dy}{dx}$') -plt.xlabel('x') -plt.ylabel('y') -plt.title('Plot of $34e^{3x}$') -plt.grid(True) -plt.legend() -plt.show() -``` -## Central Difference - -$$ -f'(x_i) = \frac{f(x_{i+1})-f(x_{i-1})}{x_{i+1}-x_{i-1}} -$$ - - - -- cgit v1.2.3