/** Simplify (x^a)^b when a and b are both numeric. * @param Node $leftOperand * @param Node $rightOperand * @retval Node|null */ private function doubleExponentiation($leftOperand, $rightOperand) { // (x^a)^b -> x^(ab) for a, b numbers if ($leftOperand instanceof ExpressionNode && $leftOperand->getOperator() == '^') { $factory = new MultiplicationNodeFactory(); $power = $factory->makeNode($leftOperand->getRight(), $rightOperand); $base = $leftOperand->getLeft(); return self::makeNode($base, $power); } // No simplification found return null; }
/** * Create a multiplication node representing '$leftOperand * $rightOperand'. * * @param mixed $leftOperand * @param mixed $rightOperand * @retval ExpressionNode * */ public function multiplication($leftOperand, $rightOperand) { return $this->multiplicationFactory->makeNode($leftOperand, $rightOperand); }