Interpolation.InverseLinearAfter Method

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.0.0

Overload List

InverseLinearAfter(Double[], Double[], Double, Double) Performs inverse linear interpolation to find the smallest x-coordinate ≥ a reference value where the interpolated curve equals a given y-value.
InverseLinearAfter(ReadOnlySpan<Double>, ReadOnlySpan<Double>, Double, Double) Performs inverse linear interpolation to find the smallest x-coordinate ≥ a reference value where the interpolated curve equals a given y-value.

InverseLinearAfter(Double[], Double[], Double, Double)

Performs inverse linear interpolation to find the smallest x-coordinate ≥ a reference value where the interpolated curve equals a given y-value.
C#
public static double InverseLinearAfter(
	double[] xValues,
	double[] yValues,
	double y,
	double x
)

Parameters

xValues  Double[]
The x-coordinates of the data points. Must be strictly increasing.
yValues  Double[]
The y-coordinates of the data points. Can be non-monotone.
y  Double
The y-coordinate for which to find the corresponding x-coordinate.
x  Double
The reference x-coordinate. The method returns the smallest solution ≥ this value.

Return Value

Double
The smallest x-coordinate ≥ x where the interpolated curve equals y.

Remarks

This method is designed for non-monotone data where multiple solutions may exist. It scans all consecutive pairs and returns the smallest x-coordinate ≥ x where the curve crosses y.

For flat segments where yi = yi+1 = y, the reference x is projected onto the interval and used as a candidate solution.

This method makes no allocations and is suitable for performance-critical scenarios.

Exceptions

ArgumentNullExceptionxValues or yValues is null.
DimensionMismatchException The lengths of xValues and yValues do not match.
ArgumentExceptionxValues does not have at least 2 elements, or the values in xValues are not strictly increasing.
InvalidOperationException No solution exists (y does not intersect the interpolated curve at any x ≥ the reference value).

InverseLinearAfter(ReadOnlySpan<Double>, ReadOnlySpan<Double>, Double, Double)

Performs inverse linear interpolation to find the smallest x-coordinate ≥ a reference value where the interpolated curve equals a given y-value.
C#
public static double InverseLinearAfter(
	ReadOnlySpan<double> xValues,
	ReadOnlySpan<double> yValues,
	double y,
	double x
)

Parameters

xValues  ReadOnlySpan<Double>
The x-coordinates of the data points. Must be strictly increasing.
yValues  ReadOnlySpan<Double>
The y-coordinates of the data points. Can be non-monotone.
y  Double
The y-coordinate for which to find the corresponding x-coordinate.
x  Double
The reference x-coordinate. The method returns the smallest solution ≥ this value.

Return Value

Double
The smallest x-coordinate ≥ x where the interpolated curve equals y.

Remarks

This method is designed for non-monotone data where multiple solutions may exist. It scans all consecutive pairs and returns the smallest x-coordinate ≥ x where the curve crosses y.

For flat segments where yi = yi+1 = y, the reference x is projected onto the interval and used as a candidate solution.

This method makes no allocations and is suitable for performance-critical scenarios.

Exceptions

ArgumentNullExceptionxValues or yValues is null.
DimensionMismatchException The lengths of xValues and yValues do not match.
ArgumentExceptionxValues does not have at least 2 elements, or the values in xValues are not strictly increasing.
InvalidOperationException No solution exists (y does not intersect the interpolated curve at any x ≥ the reference value).

See Also