See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig; 4 5 use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; 6 use PhpOffice\PhpSpreadsheet\Calculation\Exception; 7 use PhpOffice\PhpSpreadsheet\Calculation\Functions; 8 9 class SeriesSum 10 { 11 use ArrayEnabled; 12 13 /** 14 * SERIESSUM. 15 * 16 * Returns the sum of a power series 17 * 18 * @param mixed $x Input value 19 * @param mixed $n Initial power 20 * @param mixed $m Step 21 * @param mixed[] $args An array of coefficients for the Data Series 22 * 23 * @return array|float|string The result, or a string containing an error 24 */ 25 public static function evaluate($x, $n, $m, ...$args) 26 { 27 if (is_array($x) || is_array($n) || is_array($m)) { 28 return self::evaluateArrayArgumentsSubset([self::class, __FUNCTION__], 3, $x, $n, $m, ...$args); 29 } 30 31 try { 32 $x = Helpers::validateNumericNullSubstitution($x, 0); 33 $n = Helpers::validateNumericNullSubstitution($n, 0); 34 $m = Helpers::validateNumericNullSubstitution($m, 0); 35 36 // Loop through arguments 37 $aArgs = Functions::flattenArray($args); 38 $returnValue = 0; 39 $i = 0; 40 foreach ($aArgs as $argx) { 41 if ($argx !== null) { 42 $arg = Helpers::validateNumericNullSubstitution($argx, 0); 43 $returnValue += $arg * $x ** ($n + ($m * $i)); 44 ++$i; 45 } 46 } 47 } catch (Exception $e) { 48 return $e->getMessage(); 49 } 50 51 return $returnValue; 52 } 53 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body