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