Here you can find the source of interpolate(final int x1, final double y1, final int x2, final double y2, final double... f)
public static final void interpolate(final int x1, final double y1, final int x2, final double y2, final double... f)
//package com.java2s; public class Main { public static final void interpolate(final int x1, final double y1, final int x2, final double y2, final double... f) { // General equation of a straight line: y = mx + c final double m = gradient(x1, y1, x2, y2); // m = (y2 - y1) / (x2 - x1) final double c = y1; double y = c; for (int x = x1 + 1; x < x2; ++x) { f[x] = (y += m); // multiplication by repeated addition }// w ww .j a v a2 s . c om } public static final double gradient(final double x1, final double y1, final double x2, final double y2) { return (y2 - y1) / (x2 - x1); } }