If $f(x,y)=x+y$, how does one determine $(f\circ f)(x,y)$? This may be a simple question to a lot of you, but I can't wrap my head around the idea of iterating a function of multiple variables. I chose an example that I thought would be easy to show a solution for, but I would really appreciate an explanation of what it means to iterate a function of any number of variables.
My guess is this:
$$(f\circ f)(x,y)=(x+y)+(x+y)=2x+2y$$
, since, for a function of only $x$, we simply replace all instances of $x$ with $f(x)$, e.g.:
$$f(x)=x^2\implies (f\circ f)(x)=(x^2)^2=x^4$$
. However, this doesn't make much sense to me, as $x+y$ is neither a function of $x$ nor of $y$, but both. I am finishing up my final year of high school (currently taking a calculus class) and we haven't had much of an opportunity to explore the realms of multivariate calculus, as many students in said class still can't long divide [crying in background]. Anyway, any insights or explanations would be much appreciated. Thank you for your time!
 A: You can't compose $f$ with itself this way. $f$ has two real numbers as input and a single real number as output.
If you want to compose functions $g\circ h$ (including the case where $g$ and $h$ are the same function), the output of the inner / right function $h$ must match the input of the outer / left function $g$.
A: This isn't possible. The domain of $f$ is $\mathbb R^2$, the set of pairs of real numbers, but the range of $f$ is $\mathbb R$, the set of real numbers.
Note the distinction here: 6 is a member of $\mathbb R$, but not of $\mathbb R^2$. And, similarly, the point $(0,6)$ is a member of $\mathbb R^2$, but not of $\mathbb R$.
Now, the composition $f \circ f = f(f)$ only exists if the range of $f$ is contained in the domain of $f$, which is not the case here. For example, $[f\circ f](0,6) = f(6)$, but $f(6)$ is undefined since the domain of $f$ is $\mathbb R^2$.
In general, $f \circ g$ exists when the range of $g$ is contained within the domain of $f$. (Thanks Arthur)
A: As has been pointed out in another answer, $f \circ f$ doesn't work if $f$ maps pairs to individual values.
You can view $(x, y) \mapsto (x + y) + (x + y)$ as a kind of composite built up from $f$ (defined by $f(x, y) = x + y$). But to do so you need a few more notational tools. Define the diagonal function, $\Delta$, by
$$\Delta(x) = (x, x)$$
and define the functional pairing of two functions $f$ and $g$ by
$$\langle f, g \rangle(x) = (f(x), g(x))$$
Then $(x, y) \mapsto (x + y) + (x + y)$ can be written as:
$$f \circ \langle f, f\rangle \circ \Delta$$
(where $\Delta$ is being used to map a pair $(x, y)$ to a pair of pairs $((x, y), (x, y))$).
Keeping track of which combinations of $\Delta$, $\langle \cdot, \cdot\rangle$ and $\circ$ are allowable is a (very elementary) part of category theory that is also very familiar to users of typed functional programming languages.
