Skip to content

Numerical Calcs Utility

Provide lightweight numerical calculations for 1D analysis workflows.

This module provides lightweight numerical tools for analyzing one-dimensional data series, such as detecting zero crossings or sign changes in curves produced by ReaxFF simulations.

Usage context

  • Curve analysis: Locate x-axis crossings in sampled functions.
  • Response detection: Identify switching points in driven signals.
  • Derived metrics: Detect sign changes in transformed observables.

Function: find_zero_crossings

Find x-values where a 1D function crosses zero.

Zero crossings are identified by detecting sign changes between consecutive data points and estimating the root location using interpolation and numerical bracketing. Exact zeros at sampled points are also included.

Parameters:

Name Type Description Default
x sequence of float

Monotonically ordered x-values (e.g., time, iteration index).

required
y sequence of float

Function values corresponding to x.

required

Returns:

Type Description
list of float

Sorted x-values at which y(x) = 0.

Examples:

>>> find_zero_crossings(time, polarization)
>>> find_zero_crossings(iters, energy - energy.mean())