Should the domain of a function be inferred? It is a common practice to have students of elementary algebra infer the domain of a function as an exercise. I believe this is contrary to the spirit of the definition of a function as a collection of ordered pairs, no two of which have the same first term. In all serious, set-theoretic presentations of functions, relations, of which functions are a special case, come first, and then the definition of domain and range. So, if any inference is to be done, it would seem like it should be of the “formula”, or explicit rule, if there is one, that defines how the ordinate is obtained from the abscissa.
What the inference amounts to in practice is finding what values of the independent variable would result in either a denominator of 0 or the positive even root of a negative number. This sounds like a made-to-order exercise for students of elementary algebra, and so I can understand the temptation to take this path. Still, it does seem to me to go against the very spirit of the subject. Furthermore, I recall seeing someplace a discussion that ran something like this:
A.  Why don’t we just agree that the domain of the function is the set of all values for which the formula is meaningful?
B.  We can’t do even that, because such a maximal set of such values is not necessarily unique.
Speaker B then goes on to give an explicit example where there is more than one maximal set of numbers satisfying the formula. If I recall correctly, this diaglog was in a book on complex variables, or within a larger discussion regarding complex variables. Of course, we can easily construct a crude counterexample by citing the function that takes every number to its square root: for real numbers the domain is the set of non-negative real numbers, but for complex numbers the domain is the set of all complex numbers. However, I believe the example given by speaker B had something to do with a tricky denominator. Does anyone know the dialog/example I am referring to?
So, I believe the answer to this question is in the negative, but I wanted to see what the community thinks.
After all, here at MSE, we seem to take such exercises in stride, such as here:
Domain of a function
and here:
Finding a function's domain from the function's formula
 A: Inferring a domain can hide some subtle issues that may well be trivial at a beginners' level, but become more critical later on. As such, my personal view is that one must be very explicit at the lower levels, and not worry too much further up the food chain - when everyone has the understanding required to see the subtleties and potential pitfalls in what the domain is taken to be.
My canonical example of this in teaching first year undergraduates was continuity, and limits of functions. A standard homework problem is something along the lines of
"Let $f: \mathbb{R}\backslash \{1\} \rightarrow \mathbb{R}$ be given by $f(x) = \frac{x^2-1}{x-1}$. Show that $\lim_{x \rightarrow 1}f(x) = 2$."
The clever way to do this is to say that we may factor out the $(x-1)$ from the top, cancel it from the bottom to get the continuous function $x+1$. Then by properties of continuous functions, the limit is $f(1) = 2$.
This is the right idea, but most students end up saying something like $f(x) = \frac{(x+1)(x-1)}{x-1} = x+1$: and this is continuous on $\mathbb{R}$ so etc etc.
The point is once you get why you have to be careful with this argument, that indeed $f$ isn't defined on the whole of $\mathbb{R}$ but you can say that where it is defined it is equal to $x+1$ (and this does the job if you're careful), you really get the whole point of a whole bunch of fairly subtle ideas in analysis that may be a big bother later.
So even lower down the food chain there's a real benefit to being explicit: it teaches people to care about things before they absolutely have to.
A: I'll tackle A and B in reverse order.

B. We can’t do even that, because such a maximal set of such values is not necessarily unique.

For someone in pre-calculus/calculus who has to do these types of problems, there are essentially three restrictions on these sets: 


*

*Division by zero (which includes cases like $\csc(0)$)

*Roots where undefined

*Logarithms where undefined


Also, the domains are usually restricted to be subsets of $\mathbb{R}^n$. In that situation, any composition of elementary functions has a unique maximal domain. Now, if we shift the domain to $\mathbb{C}$, then we're stepping out of the box of those courses, and then you can argue about choices of principal branch of logarithm or of principal roots…

A. Why don’t we just agree that the domain of the function is the set of all values for which the formula is meaningful?

I think there's a problem with this, but my primary issue is not that this is at odds with the way domains of functions are usually treated in more theoretical courses. In my opinion, the issue is with how domains end up being used. In calculus especially, the concern is not really about a maximal domain (which may be unique in the expected cases), but about a maximal connected domain, which is certainly not unique in general. It is unique when you require a particular point inside, but this is glossed over.
There is a good reader survey at n-cat cafe discussing the issue of "the general antiderivative of $1/x$" and the fact that when you're working on any given side of zero, $\log\left|x\right|+C$ will suffice, but technically not in general. Wikipedia also brings up the similar issue of antiderivatives of $\tan x$. These sorts of issues also come up when students are asked to solve "fairly straightforward" separable differential equations when case distinctions are swept under the rug.
In short, I think maximal connected domains should be emphasized more, because that's what you care about when you have an initial value problem to solve, etc.
A: The domain should not be inferred as there are situations where the function behaves strangely such as being discontinuous or allowing possible division by 0 or taking a square root or other even root of a negative number, or taking a logarithm of a negative number, or other function with bad behavior at a point.
Note how in complex analysis principal branches are selected.
A: I agree with the author of the question that inferring the domain from the definition of the function is backward. There are a couple of points that I think would be worth adding to the previous answers.
Firstly, it is not quite clear to me that the one right setup in which all of mathematics is happening is $\mathbb{R}$. There seems to be no particular reason why not work in $\mathbb{R} \cup \{\infty\}$, or $\mathbb{R} \cup \{-\infty, + \infty \}$, or $\mathbb{C}$ and so on. I for one would not be too strongly opposed to statements like "$\sqrt{x}$ exists for all $x \in \mathbb{R}$; if $x \geq 0$ then $\sqrt{x} \in \mathbb{R}$, and if $x \leq 0$ then $\sqrt{x} \in i \mathbb{R}$", or "$ \log 0 = -\infty$", or even "$\log (+\infty) = +\infty$".
Secondly, one is not always (hardly ever?) interested in a function as a purely set-theoretic object. What matters is that a function has some desirable properties, for instance that it is smooth, satisfies some differential equation. I would think twice before allowing a singular point into a domain of an otherwise smooth function (which naturally depends on where the function comes from). If I had a (complex valued) function given by $f(z) = \sum_n a_n z^n$, with $|a_n| \to 1$, I would strongly feel that the right domain is $\{ |z| < 1\}$, even if the series converges for some $z$ with $|z| = 1$.
Finally, let me point out that much of mathematics was about extending domains of functions. The complex numbers were first thought of because people wanted to take roots of negative numbers. Analytic continuation is largely about extending domain of functions outside of what it would normally be. Functional calculus extends domains of definition of functions to matrices/operators on Banach spaces. I am not saying that we should teach people that the domain of $\sin x$ includes all bounded operators on all Banach spaces, but the mathematics is progressing in quite the reverse direction.
