NewtonInterpolation class base

Newton interpolation (also known as Newton's divided difference interpolation) is a polynomial interpolation method that constructs an interpolation polynomial for a given set of data points using divided differences.

This implementation supports both forward differences and backward differences:

  • Forward differences: Best used when interpolating near the beginning of the data set (i.e., when x is close to the first node's x-value). The formula uses Newton's forward difference formula.

  • Backward differences: Best used when interpolating near the end of the data set (i.e., when x is close to the last node's x-value). The formula uses Newton's backward difference formula.

Requirements

The interpolation nodes should be equally spaced for optimal accuracy. While the algorithm will work with unequally spaced nodes, the results may be less accurate.

Example

const interpolation = NewtonInterpolation(
  nodes: [
    InterpolationNode(x: 45, y: 0.7071),
    InterpolationNode(x: 50, y: 0.766),
    InterpolationNode(x: 55, y: 0.8192),
    InterpolationNode(x: 60, y: 0.866),
  ],
  forwardDifference: true, // Use forward differences
);

// Interpolate at x = 52
final result = interpolation.compute(52);
print(result); // Approximately 0.788
Inheritance

Constructors

NewtonInterpolation({required List<InterpolationNode> nodes, bool forwardDifference = true})
Newton interpolation (also known as Newton's divided difference interpolation) is a polynomial interpolation method that constructs an interpolation polynomial for a given set of data points using divided differences.
const

Properties

forwardDifference bool
When true, the algorithm uses forward differences. When false, the algorithm uses backward differences.
final
hashCode int
The hash code for this object.
no setterinherited
nodes List<InterpolationNode>
The interpolation nodes.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

backwardDifferenceTable() RealMatrix
Computes the backward differences table and stores the results in a RealMatrix object.
compute(double x) double
Returns the y value of the y = f(x) equation.
override
forwardDifferenceTable() RealMatrix
Computes the forward differences table and stores the results in a RealMatrix object.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited