What does it mean for a variable to be a function of another?

The confusion arises because there are two inconsistent, albeit related, uses of the word function. The older use is what may be called a dependent variable, in (for example) the phrase “$y$ is a function of $x$” or, more specifically, “the function $y=2x+4$”. This usage is still common among non-mathematicians who employ mathematics. This language tends to be avoided by present-day mathematicians, because it implies, in this case for example, that a function is a kind of real number (which depends on another, freely specifiable, real number). The function here is not $y$ but (in simple terms) the rule that specifies how $y$ is obtained from $x$. In the modern sense, a function can be precisely defined as a kind of mathematical object, which is quite distinct from the values (e.g. $y$) associated with the function.


Ultimately, I think that you are correct to write $y = f(x)$ when given the information "$y$ is a function of $x.$"

Like you mention, the equation $y(x) = 2x + 4$ implicitly gives the information that the output $y$ depends upon the input $x,$ i.e., $y$ is the dependent variable, and $x$ is the independent variable; however, it is a common abuse of notation to write $y = 2x + 4$ in place of the function $y(x) = 2x + 4.$ Unfortunately, in this case, the notation is ambiguous because as you noted, we could also write $x = \frac 1 2 y - 2,$ and this describes $x$ as a function $x(y) = \frac 1 2 y - 2$ of $y.$ What you are witnessing in this example is that the function $f(x) = 2x + 4$ has an inverse, i.e., there exists a function $g(x)$ such that $f \circ g(x) = x$ and $g \circ f(x) = x.$ Explicitly, the inverse function is $g(x) = \frac 1 2 x - 2.$ One can check that $f \circ g(x) = 2g(x) + 4 = x$ and $g \circ f(x) = \frac 1 2 f(x) - 2 = x.$

Like Maryam mentions above, the clear distinction between a function $f(x)$ and an equation is that a function comes with a domain (i.e., a set of $x$-values that are valid inputs for $f(x)$) and a codomain (i.e., a set of $y$-values that are valid outputs for $f(x)$). Unfortunately, in the case of $f(x) = 2x + 4,$ all $x$-values are valid inputs, and all $y$-values are valid outputs, so the domain and codomain are often suppressed; however, for the function $g(x) = \sqrt x,$ the domain and the codomain are quite important because the square root of a negative number is not a real number, hence the equation $y = \sqrt x$ is rather meaningless.


A function is the sum of three informations: the domain, the codomain, and a rule. You say a function $f:A\to B$ is defined by $y=f(x)$ to specify that the domain is $A$, the codomain is $B$ and the rule is expressed by the equation $y=f(x)$. Equivalently, you can see a function from a domain $A$ to a codomain $B$ and defined by an equation $y=f(x)$ as a relation from $A$ to $B$, that is as a subset of the cartesian product $A\times B$, such that the ordered pair $(x,f(x))$ is an element of that relation for all $x$ in the domain $A$ of $f$. If, as in your example, the relation is invertible, then for all $x\in A$ and all $(x,y)\in f$, you have that the symmetric pair $(y, x)$ is in the inverse relation $f^{-1}$, which is a function from the domain $B$ to the codomain $A$, defined by the equation $x=f^{-1}(y)$ for all $y\in B$.