for (var i = 0; i < values.length; i++) {
      sum +=Math.pow((values[i] - x1), 2);
    }