Beginner questions about how functions work

These are great questions!

Is it correct to say that $g(x+y)$ is a function of one variable or two variables?

Firstly, let me pedantically distinguish between $g$ (the thing you plug input values into) and $g(x+y)$ (the result of plugging $x+y$ into $g$), both of which are often called "functions".

Focus on $g$ first of all. Those values you plug in can be variables, or constants, or whatever(*). It can be $x+y$, or it can be $5$, or it can be $x+y-z+abc-d^5$, but you're only allowed to plug one thing into $g$, because it only has space for one input. The correct term for "a value you plug in" is an argument. So $g$ takes one argument.

On the other hand, there are clearly two variables visible here: $x$ and $y$. Why might that be? Well, as you rightly pointed out, this particular argument we've plugged in is some kind of combination (really: function!) of these two variables. Let's give that function a name, say $\mathrm{sum}(x,y) = x+y$ (a function that takes two arguments).

So you could rewrite $g(x+y)$ as $g(\mathrm{sum}(x,y))$, if you like that kind of thing. Note that you're still plugging one thing into $g$: it's just now called $\mathrm{sum}(x,y)$. And there are still two variables present. Nothing's changed here.

Is there some inherent "two-ness" about $g(x+y)$, though? Well, not necessarily. Here's another function: $\mathrm{bigsum}(w,x,y,z) = w+x+y+z$. This one takes four arguments; but there's nothing stopping me looking at what happens when I plug this into $g$ with $w = -z$, i.e. $$g(\mathrm{bigsum}(-z,x,y,z)).$$ Try it, and you'll see this also evaluates to $g(x+y)$. Or here's another function: $\mathrm{forgetful}(a,b,c,d,\dots,x,y,z) = x+y$ - a function of 26 arguments (but most of them happen to be redundant).

The take-home message is: whenever someone writes down (e.g.) a formula, there should(!) also be an underlying context for that formula. In the world of functions, this normally amounts to specifying a domain, i.e. an allowable range of input values. These don't come for free with formulas: it's your job, as the mathematician, to make sure that they're well specified (so that e.g. everyone reading your work understands what they are, or you don't accidentally change something subtle about the function in the middle of a long piece of work, or whatever).

(*) In practical, mathematical terms: there isn't really much of a distinction. What does "variable" mean anyway, apart from "some constant I don't know" or "a placeholder for some constants"?

I think other people have addressed your other questions, but one final comment from me:

What are some trivial examples of the statement above? My attempts:

Others have told you why three of these are wrong. Actually, I'd be pedantic here: (a) and (b) are wrong, and (d) is underspecified - in other words, it needs more information before it makes sense. For example:

  • if $u$ is a new, independent variable, then the formula given doesn't make any sense.
  • if $u$ is secretly a function, and you plug $x+y$ (or something dependent only on $x+y$) into it, then the formula given makes sense, but this is probably not a valid counterexample.
  • if $u$ just happens to be your favourite name for the number $2.75$, then the formula given makes sense and this is a valid counterexample.

Again, context matters.


Maybe you should clarify the definition of function that is a relation between a set of inputs and a set of permissible outputs with the property that each input is related to exactly one output.

Thus, on real numbers, in general a function $f$ has a set of input $\mathbb{R^n}$, which elements are n-dimensional vectors, and a set of output $\mathbb{R^m}$ which elements are m-dimensional vectors.

For example, the function $$g(x,y) = x+y$$

is a relation with a set of input $\mathbb{R^2}$ and a set of output $\mathbb{R}$ which is formally expressed by

$$g: \mathbb{R^2}\to\mathbb{R},\quad(x,y)\to x+y$$

and it is denoted as a function of severable variables.

Otherwise $$g(x+y) = x+y \quad$$ (that is $g: \mathbb{R}\to\mathbb{R} \quad t\to t$) is denoted as a function of a single variable.


A function is defined in term of sets. Functions can act on elements/points and very importantly, also on sets.

The two central and formal sets used to define a function are:

  • A set called the Domain, $D$.
  • A set called the Co-domain, $C$.

$f: D \to C$ means: $\forall x \in D$, $f(x) \in C$.

  • The set $G=\{f(x)|x\in D\} \subseteq C$ is called the Image of $f$.
  • For every $U \subseteq C$, the set $f^{-1}(U) = \{x|f(x)\in U\} \subseteq D$ (Where I used action on sets) is called the Preimage of $U$. ($f^{-1}$ in this context is defined $\mathcal{P}(C)\to \mathcal{P}(D)$, and is not the inverse of $f$ that need not necessarily exist)

Example: The absolute value function from the domain of real numbers to the codomain of real numbers: $$f: \mathbb{R} \to \mathbb{R}, f(x)=|x|= \begin{cases} x & x \geq 0 \\ -x & x < 0 \end{cases}$$

The image in this case is $G=\{x|x\geq0\} \subset \mathbb{R}$.

For every $x \in G$ the preimage is $f^{-1}(\{x\})=\{x,-x\}$ beacuse the rule $x \mapsto |x|$ maps both positive and negative versions of $x$ to the positive $|x|$.

Let's consider the Cartesian product $D \times C$. all subsets $F \subseteq D \times C$ are called relations.

A relation $R$ is a function if and only if

1.1: $xRy \land xRz \implies y=z$. Equivalently: $(x,y),(x,z)\in R \implies y=z$.

1.2: $\forall x \in D, \exists y \in C$ such that $(x,y) \in R$

A function represented by relation $R$ can be:

2.1: Injective: $xRy \land zRy \implies x=z$. ($|x|$ is not injective)

2.2: Surjective: $C=G$. i.e the image is the entire codomain.

2.3: Bijective: 2.1 and 2.2. In this case there is a two sided unique inverse.

1: $g(x+y)$ is a composition of a function $h: D \times D \to T, h(x,y)=x+y$ on the function $g: S \to A$ dentoed $g \circ h$ with the restriction that the image of $h$ which is a subset $I \subseteq T$ is the domain of $g$: $S$. More accurately this is generally a restriction of $g$ to $I \subseteq S$.

In the equation $f(x)=g(x+y)$ it is helpful to "fix" $x$. In that case the LHS is fixed as well. But $y$ is variable of $h$ and by varying $y$ you can get the entire image of $h$ regardless of $x$. This means $g$ does not depend on $y$.