Notation for multiline function

functionsnotation

Mathematical functions are often written as $f(x) = x^2$ or similar, but I have never seen a notation for a function that is over multiple lines.

To provide a simplified example, if a function $f$ is defined as $f(x) = x^2 + \log(x^2) + \exp(x^2)$, to make it more readable you could let a variable, e.g. $a$, equal $x^2$ inside the function on the first line, then return $a + \log(a) + \exp(a)$ on the next line.

Obviously here this makes little difference but if there was a more complicated expression than $x^2$, it would make the function much more readable to first declare a variable inside the function body rather than rewriting the expression multiple times.

Does a notation for these 'multiline' functions exist?

Best Answer

The "multiple lines" notation that you are thinking of is actually used frequently in cases where an otherwise very complex expression can be simplified in this way.

Often the order of the "lines" is reversed; for example, we might write

$$ f(x) = u + \log(u) + \exp(u)$$ where $$u = x^2.$$

As remarked in a comment, this really amounts to a composition of functions, which could be written more explicitly as a composition:

Let $$\begin{align} g(u) &= u + \log(u) + \exp(u),\\ h(x) &= x^2,\end{align}$$ then $f(x) = g(h(x)).$

Again the sequence of "lines" could be reversed, that is, "$f(x) = g(h(x))$ where $g(u) = \ldots$", etc.

Related Question