public function testProduct()
{
// f(x) = x² + 8x - 12
$f = function ($x) {
return $x ** 2 + 8 * $x - 12;
};
// g(x) = x - 9
$g = function ($x) {
return $x - 9;
};
// Π(x) = f(x) * g(x) = x³ - x² -84x + 108
$product = Arithmetic::multiply($f, $g);
// Π(0) = 108
$expected = 108;
$x = $product(0);
$this->assertEquals($expected, $x);
// Π(5) = -212
$expected = -212;
$x = $product(5);
$this->assertEquals($expected, $x);
// Π(-5) = 378
$expected = 378;
$x = $product(-5);
$this->assertEquals($expected, $x);
// Π(100) = 981708
$expected = 981708;
$x = $product(100);
$this->assertEquals($expected, $x);
// Π(-100) = -1001492
$expected = -1001492;
$x = $product(-100);
$this->assertEquals($expected, $x);
}