List<Double> nec = new ArrayList<Double>();
List<Double> pos = new ArrayList<Double>();
// border cases
updateNecPos(nec, pos, new Point(overlap.min(), A.apply(overlap.min())), B);
updateNecPos(nec, pos, new Point(overlap.max(), A.apply(overlap.max())), B);
for (Point p : A.points)
updateNecPos(pos, nec, p, B);
return new double[]{ Collections.min(nec), Collections.max(pos) };