Derivatives
Finite-difference utilities for first and second derivatives on uniformly spaced one-dimensional grids.
Finite-difference derivative helpers on uniformly spaced 1D grids.
This module provides simple central-difference routines for first and second derivatives. Both functions return the derivative evaluated on the interior points only (the first and last grid points are dropped).
- edlgt.tools.derivatives.first_derivative(grid_values, function_values, dx)[source]
Compute the first derivative using a central-difference stencil.
- Parameters:
grid_values (
numpy.ndarray) – One-dimensional grid values. Only interior points are returned.function_values (
numpy.ndarray) – Function values sampled ongrid_values.dx (
float) – Uniform grid spacing.
- Returns:
(x_interior, df_dx)as two NumPy arrays, both of lengthlen(grid_values) - 2.- Return type:
Notes
This routine assumes a uniformly spaced grid and uses the standard second-order central-difference approximation on interior points.
- edlgt.tools.derivatives.second_derivative(grid_values, function_values, dx)[source]
Compute the second derivative using a central-difference stencil.
- Parameters:
grid_values (
numpy.ndarray) – One-dimensional grid values. Only interior points are returned.function_values (
numpy.ndarray) – Function values sampled ongrid_values.dx (
float) – Uniform grid spacing.
- Returns:
(x_interior, d2f_dx2)as two NumPy arrays, both of lengthlen(grid_values) - 2.- Return type:
Notes
This routine assumes a uniformly spaced grid and uses the standard second-order central-difference approximation on interior points.