/**
  * Axiom: x₍n₎ = ∑ (-1)ⁿ⁻ᵏ L(n,k) x⁽ᵏ⁾
  * Falling factorial can be represented as the summation of Lah numbers and rising factorials
  *
  * @dataProvider dataProivderForLahNumbers
  */
 public function testFallingFactorialAsLahNumberAndRisingFactorial(int $x, $n)
 {
     $x₍n₎ = Combinatorics::fallingFactorial($x, $n);
     $∑⟮−1⟯ⁿ⁻ᵏL⟮n、k⟯x₍k₎ = 0;
     for ($k = 1; $k <= $n; $k++) {
         $⟮−1⟯ⁿ⁻ᵏ = (-1) ** ($n - $k);
         $L⟮n、k⟯ = Combinatorics::lahNumber($n, $k);
         $x⁽ᵏ⁾ = Combinatorics::risingFactorial($x, $k);
         $∑⟮−1⟯ⁿ⁻ᵏL⟮n、k⟯x₍k₎ += $⟮−1⟯ⁿ⁻ᵏ * $L⟮n、k⟯ * $x⁽ᵏ⁾;
     }
     $this->assertEquals($x₍n₎, $∑⟮−1⟯ⁿ⁻ᵏL⟮n、k⟯x₍k₎);
 }
예제 #2
0
 public function testRisingFactorialExceptionNLessThanZero()
 {
     $this->setExpectedException('MathPHP\\Exception\\OutOfBoundsException');
     Combinatorics::risingFactorial(5, -1);
 }