Example: The B-spline least squares fit

A B-Spline least squares fit to data is computed. The value of the spline at point 4.5 is printed.
import com.imsl.math.*;

public class BsLeastSquaresEx1 {
    public static void main(String args[]) {
        int		n = 11;
        double x[] = {0, 1, 2, 3, 4, 5, 8, 9, 10};
        double y[] = {1.0, 0.8, 2.4, 3.1, 4.5, 5.8, 6.2, 4.9, 3.7};
        
        BsLeastSquares bs = new BsLeastSquares(x, y, 5);
        double bsv =  bs.value(4.5);
        System.out.println("The computed B-spline value at point 4.5 is "
        + bsv);
    }
}

Output

The computed B-spline value at point 4.5 is 5.228554323596942
Link to Java source.