public function visitFunctionNode(FunctionNode $node)
    {
        $functionName = $node->getName();

        $operand = $node->getOperand()->accept($this);

        switch ($functionName) {
            case 'sqrt':
                return "\\$functionName{" . $node->getOperand()->accept($this) . '}';
            case 'exp':
                $operand = $node->getOperand();

                if ($operand->complexity() < 10) {
                    $this->solidus = true;
                    $result = 'e^' . $this->bracesNeeded($operand);
                    $this->solidus = false;

                    return $result;
                }
                // Operand is complex, typset using \exp instead

                return '\exp(' . $operand->accept($this) . ')';

            case 'ln':
            case 'log':
            case 'sin':
            case 'cos':
            case 'tan':
            case 'arcsin':
            case 'arccos':
            case 'arctan':
                break;

            case 'abs':
                $operand = $node->getOperand();

                return '\lvert ' . $operand->accept($this) . '\rvert ';

            case '!':
            case '!!':
                return $this->visitFactorialNode($node);

            default:
                $functionName = 'operatorname{' . $functionName . '}';
        }

        return "\\$functionName($operand)";
    }
public function visitFunctionNode(FunctionNode $node)
    {
        $functionName = $node->getName();

        $operand = $node->getOperand()->accept($this);

        switch ($functionName) {
            case 'sqrt':
                return "\\$functionName{" . $node->getOperand()->accept($this) . '}';
            case 'exp':
                $operand = $node->getOperand();

                if ($operand->complexity() < 10) {
                    $this->solidus = true;
                    $result = 'e^' . $this->bracesNeeded($operand);
                    $this->solidus = false;

                    return $result;
                }
                // Operand is complex, typset using \exp instead

                return '\exp(' . $operand->accept($this) . ')';

            case 'ln':
            case 'log':
            case 'sin':
            case 'cos':
            case 'tan':
            case 'arcsin':
            case 'arccos':
            case 'arctan':
                break;

            case 'abs':
                $operand = $node->getOperand();

                return '\lvert ' . $operand->accept($this) . '\rvert ';

            case '!':
            case '!!':
                return $this->visitFactorialNode($node);

            default:
                $functionName = 'operatorname{' . $functionName . '}';
        }

        return "\\$functionName($operand)";
    }
public function visitFunctionNode ( FunctionNode $ node ) { $ functionName = $ node -> getName ( ) ; $ operand = $ node -> getOperand ( ) -> accept ( $ this ) ; switch ( $ functionName ) { case 'sqrt' : return "\\$functionName{" . $ node -> getOperand ( ) -> accept ( $ this ) . '}' ; case 'exp' : $ operand = $ node -> getOperand ( ) ; if ( $ operand -> complexity ( ) < 10 ) { $ this -> solidus = true ; $ result = 'e^' . $ this -> bracesNeeded ( $ operand ) ; $ this -> solidus = false ; return $ result ; } // Operand is complex, typset using \exp instead return '\exp(' . $ operand -> accept ( $ this ) . ')' ; case 'ln' : case 'log' : case 'sin' : case 'cos' : case 'tan' : case 'arcsin' : case 'arccos' : case 'arctan' : break ; case 'abs' : $ operand = $ node -> getOperand ( ) ; return '\lvert ' . $ operand -> accept ( $ this ) . '\rvert ' ; case '!' : case '!!' : return $ this -> visitFactorialNode ( $ node ) ; default : $ functionName = 'operatorname{' . $ functionName . '}' ; } return "\\$functionName($operand)" ; }
Generate LaTeX code for a FunctionNode

Create a string giving LaTeX code for a functionNode.

### Typesetting rules:

- `sqrt(op)` is typeset as `\sqrt{op}
- `exp(op)` is either typeset as `e^{op}`, if `op` is a simple
expression or as `\exp(op)` for more complicated operands.

@retval string
@param FunctionNode $node AST to be typeset
Generate LaTeX code for a FunctionNode