code: public static function LOGEST($yValues, $xValues = null, $const = true, $stats = false)
      {
          $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const);
          $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats);
          if ($xValues === null) {
              $xValues = range(1, count(Functions::flattenArray($yValues)));
          }
  
          if (!self::checkTrendArrays($yValues, $xValues)) {
              return Functions::VALUE();
          }
          $yValueCount = count($yValues);
          $xValueCount = count($xValues);
  
          foreach ($yValues as $value) {
              if ($value <= 0.0) {
                  return Functions::NAN();
              }
          }
  
          if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
              return Functions::NA();
          } elseif ($yValueCount == 1) {
              return 1;
          }
  
          $bestFitExponential = Trend::calculate(Trend::TREND_EXPONENTIAL, $yValues, $xValues, $const);
          if ($stats) {
              return [
                  [
                      $bestFitExponential->getSlope(),
                      $bestFitExponential->getSlopeSE(),
                      $bestFitExponential->getGoodnessOfFit(),
                      $bestFitExponential->getF(),
                      $bestFitExponential->getSSRegression(),
                  ],
                  [
                      $bestFitExponential->getIntersect(),
                      $bestFitExponential->getIntersectSE(),
                      $bestFitExponential->getStdevOfResiduals(),
                      $bestFitExponential->getDFResiduals(),
                      $bestFitExponential->getSSResiduals(),
                  ],
              ];
          }
  
          return [
                  $bestFitExponential->getSlope(),
                  $bestFitExponential->getIntersect(),
              ];
      }
docs: LOGEST.
  
  Calculates an exponential curve that best fits the X and Y data series,
  and then returns an array that describes the line.
  
  @param mixed[] $yValues Data Series Y
  @param null|mixed[] $xValues Data Series X
  @param bool $const a logical value specifying whether to force the intersect to equal 0
  @param bool $stats a logical value specifying whether to return additional regression statistics
  
  @return array