1

Is there a notation for a function that returns another function? Maybe something like $f(x) = (y) = y + x$ i.e. the function being returned would return it's input plus $x$, e.g. $f(2)(3) = 5$?

Is the way I have written it correct?

2 Answers2

4

Let $\mathcal{F}$ be the set of functions $\Bbb{R}\to \Bbb{R}$. If I'm understanding you correctly, what you're talking about is a function $f:\Bbb{R}\to \mathcal{F}$, such that for all $x\in \Bbb{R}$, $f(x)\in \mathcal{F}$ is that function $\Bbb{R}\to \Bbb{R}$ such that for all $\alpha\in \Bbb{R}$, we have \begin{align} [f(x)](\alpha):= \alpha + x \end{align}

A slightly quicker way of writing this is that for all $x\in \Bbb{R}$, \begin{align} f(x):= (\Bbb{R}\ni \alpha \mapsto \alpha + x) \end{align}

Or yet another way of writing this is: $f:\Bbb{R}\to \mathcal{F}$, \begin{align} x\mapsto (\alpha \mapsto \alpha + x) \end{align} In words, this is saying that $f$ is that function which maps an element $x\in \Bbb{R}$ to the function $\alpha\mapsto \alpha + x$ from $\Bbb{R}\to \Bbb{R}$.


So, yes we have $[f(2)](3) = 2+3 = 5$. If you want to be slightly more economical with your bracketing then sure $f(2)(3) = 5$ is also true. But if you're ever writing this stuff down for someone else to read then make sure you write "$f:\Bbb{R}\to \mathcal{F}$" before hand to avoid any misunderstanding. Because if you don't say anything before hand then people will automatically assume that $f$ is itself a function $\Bbb{R}\to \Bbb{R}$ so when they see $f(2)(3)$ they'll either think this is weird notation/ a typo/ a multiplication of $(f(2)) \cdot (3) = 3 \cdot f(2)$, which is of course not what you intended.

peek-a-boo
  • 55,725
  • 2
  • 45
  • 89
0

Is there a notation for a function that returns another function?

Yes, lambda notation can be used to define a function that returns another function.

Example. The function that takes as an argument a natural number N, and returns the function $x^N$ can be written as

$$\lambda N . \lambda x . x^N$$

To apply this function it is best to first give it a name

$$f = \lambda N . \lambda x . x^N$$

Then to apply it to two arguments you would write

$$f(2)(\pi)$$

exactly as in your question. The result will be $\pi^2$

However, it is not necessary that you give the function a name. You can also use the lambda expression "anonymously".

$$(\lambda N . \lambda x . x^N)(2)(\pi)$$

means exactly the same thing.

A function whose range is a set of functions is called a higher-order function.