edu.rit.numeric

## Class Interpolation

- java.lang.Object
- edu.rit.numeric.Interpolation

- All Implemented Interfaces:
- Function

public class Interpolationextends Objectimplements Function

Class Interpolation provides an object for interpolating in an XYSeries of real values (type`double`). Linear interpolation is used. The X-Y series must have at least two elements; the X values must be distinct; but the X values need not be in any particular order. When doing interpolations, the (X,Y) pairs are arranged in ascending order of X values.Class Interpolation implements interface Function. An instance of class Interpolation can be used as a function object.

### Constructor Summary

Constructors Constructor and Description **Interpolation**(XYSeries theSeries)Construct a new interpolation object that will interpolate between values in the given X-Y series.

### Constructor Detail

#### Interpolation

public Interpolation(XYSeries theSeries)

Construct a new interpolation object that will interpolate between values in the given X-Y series. The X-Y series must have at least two elements; the X values must be distinct; but the X values need not be in any particular order.*Note:*A copy of the given series' elements is made. Changing`theSeries`will not affect this interpolation object.- Parameters:
`theSeries`

- X-Y series.- Throws:
`NullPointerException`

- (unchecked exception) Thrown if`theSeries`is null.`IllegalArgumentException`

- (unchecked exception) Thrown if`theSeries`has fewer than two elements. Thrown if the X values in`theSeries`are not distinct.

### Method Detail

#### f

public double f(double x)

Using linear interpolation, compute the Y value for the given X value. If`x`is less than the smallest X value in the underlying X-Y series, the Y value is computed by extrapolating the first interval. If`x`is greater than the largest X value in the underlying X-Y series, the Y value is computed by extrapolating the last interval.

**SCaVis 2.1 © jWork.ORG**