/** 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; }