code: public static function FORECAST($xValue, $yValues, $xValues)
      {
          $xValue = Functions::flattenSingleValue($xValue);
          if (!is_numeric($xValue)) {
              return Functions::VALUE();
          } elseif (!self::checkTrendArrays($yValues, $xValues)) {
              return Functions::VALUE();
          }
          $yValueCount = count($yValues);
          $xValueCount = count($xValues);
  
          if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
              return Functions::NA();
          } elseif ($yValueCount == 1) {
              return Functions::DIV0();
          }
  
          $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues);
  
          return $bestFitLinear->getValueOfYForX($xValue);
      }
docs: FORECAST.
  
  Calculates, or predicts, a future value by using existing values. The predicted value is a y-value for a given x-value.
  
  @param float $xValue Value of X for which we want to find Y
  @param mixed $yValues array of mixed Data Series Y
  @param mixed $xValues of mixed Data Series X
  
  @return float