Is sqrt(x) a function? Does it matter if a domain is given? [duplicate]

I saw the following during a practice exam:

$f(x) = \sqrt x$ for $x ≥ 2$

After the exam, I pointed out to my teacher that this was not actually a function, but instead a mapping, because it can have both positive and negative values. She told me that this didn't matter; you assume the answer of $\sqrt x$ to be positive, unless otherwise stated. However, this contradicts her previous statement that $\sqrt x$ is a mapping. (She gave it as an example of something that was not a function, when defining functions.)

So, is $f(x)$ a function? Does it matter if there is a domain restriction?

marked as duplicate by davidlowryduda♦, Asaf Karagila♦, Fabian, J. M. is a poor mathematician, t.b.Jul 25 '11 at 3:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• What exactly do you mean by "it can have both positive and negative values"? The (principal) square root function lives entirely in the first quadrant... – J. M. is a poor mathematician Jul 24 '11 at 0:26
• @J.M. -2 and +2 are both the square root of 4. – Thomas O Jul 24 '11 at 0:27
• That's why one chooses the principal square root; when people write $f(x)=\sqrt{x}$ they (usually) mean that the principal value is assumed. Thus, $\sqrt{4}=-2$ is incorrect, but $4=(-2)^2$ is alright. – J. M. is a poor mathematician Jul 24 '11 at 0:29
• @J.M. I think you should consider expanding your last comment into an answer, as that's all there really is to say. – davidlowryduda Jul 24 '11 at 0:31
• Ah... here we are! – J. M. is a poor mathematician Jul 24 '11 at 0:34

4 Answers

The specification of a function is never complete unless you give its domain and range. The rule alone is insufficient.

• The rule alone is insufficient, but it is not necessary to give domain and range explicitly: both are implicit in the function itself as a set of ordered pairs. For that matter, the range is implied by the domain and rule. What does need to be given explicitly for a complete specification is the codomain. – Brian M. Scott Jul 24 '11 at 18:10
• The set of ordered pairs is the graph of the function, not the function itself. – ncmathsadist Jul 25 '11 at 1:02
• From a set-theoretic point of view the set of ordered pairs most certainly is the function. – Brian M. Scott Jul 25 '11 at 3:17
• The set of ordered pairs does not define the range (codomain) of the function. The totality of all co-ordinates of these ordered pairs only shows the smallest possible codomain of the function. – ncmathsadist Jul 25 '11 at 13:15
• That is essentially what I said in my original comment, in which I noted that the codomain can’t be inferred from the set of ordered pairs. From my point of view, however, the function is still the set of ordered pairs, and the codomain, while necessary for a complete specification, is an ‘extra’ that may or may not be of interest in any given case. (My view of such things is distinctly set-theoretic, not algebraic or category-theoretic.) – Brian M. Scott Jul 25 '11 at 17:54

You can easily define a function $f : \mathbb R \to \mathbb R$ to output for each $x$ the positive square root of $x$. You can also have a function from $\mathbb R \to \mathbb R \times \mathbb R$ defined by $f(x) = (\sqrt{x}, -\sqrt{x})$, where $\sqrt{x}$ is the positive square root of $x$ (with $x \ge 2$ if you wish).

By the way, for most authors in most theories, a mapping and a function is the same, same thing. No difference. To be honest, for me there is no difference. I don't call a mapping a "function which can output more than one value". I'd rather not give those things a name since we don't use them very often in mathematics, we stick to functions almost all the time.

In general, you should not argue in the meaning of words if the context is well-understood and that you don't have any problem with it. Words are meant for comprehension and clarity, so if you understand and it's clear to everyone, there's no need to argue. I think your teacher clearly meant the positive square root because everyone does think that way, it's a convention. Although it's good to ask yourself what's going on and wonder why things are as they are. What I meant is : don't think your teacher is bad because he wasn't clear to you or something.

Hope that helps,

• ‘Those things’ already have a standard name: they’re simply relations that aren’t functions. – Brian M. Scott Jul 24 '11 at 0:43
• I don't think OP is having this level of trouble... we've argued enough. – Patrick Da Silva Jul 24 '11 at 1:24
• I think that the OP is either seriously misunderstanding or being seriously misinformed by his teacher, and I consider that a much more important problem than his not realizing that $\sqrt{x}$ denotes the non-negative square root. Indeed, that confusion seems to have been at least partly the result of the misunderstanding or misinformation. – Brian M. Scott Jul 24 '11 at 1:29
• What I mean is that we're starting to argue about our own questions more than his own. At this point OP should either comment or accept an answer. – Patrick Da Silva Jul 24 '11 at 1:52

There are a few things going on here. First a function is the data of two sets $A$ and $B$, and an assignment $a\mapsto f(a)\in B$ for every $a\in A$. Having a domain and codomain is very important when dealing with general functions, but people are usually lazy when dealing with functions defined on (most of) $\mathbb{R}$. Given a function $f:A\to B$ and a subset $A'\subset A$, we can restrict $f$ to $A'$. Additionally, if $B\subset B'$, we can compose $f$ with the inclusion $i:B\to B'$ to get a function $i\circ f$. Every function can be written as the composition of a surjective function (namely shrinking the codomain of the function to be the image of the function) followed by an inclusion.

Second, given a function, $f:A\to B$, the inverse is a function $g:B\to A$ such that $f(g(b))=b$ for all $b\in B$ and $g(f(a))=a$ for all $a\in A$. Not every function has an inverse: it must be both injective (if $x\neq y$, then $f(x)\neq f(y)$), and surjective (if $b\in B$, then we can find $a\in A$ with $f(a)=b$). In this case, the inverse is easy to define: if $f(a)=b$, we define $g(b)=a$. Because of surjectivity, we have a value of $g(b)$ for every $b$. Because of injectivity, we have only one value. Therefore, this defines a function.

When we look at $f(x)=x^2$, with $f:\mathbb{R}\to \mathbb{R}$ we see that it is neither injective nor surjective. However, if we restrict both the domain and codomain, and view it as a function $f:\mathbb{R}_+\to \mathbb{R}_+$, then it is both injective and surjective, and so we have an inverse function, namely the square root function.

However, $\sqrt{x}$ is not the only thing that squares to $x$, as $(-\sqrt x)^2=x$. This was why we needed to restrict the squaring function before we could take an inverse: sending $x$ to all things which square to $x$ is NOT a function.

Of course, there are things more general than functions, "multi-valued functions," which take multiple values, and you can construct a normal function from a multi-valued function by choosing one value at every point. In this case, $\sqrt{x}$ and $-\sqrt{x}$ are both branches of a multivalued function defining the inverse to the squaring function. However, multi-valued functions are difficult to work with, and I don't recommend that you give them much thought until you have to (e.g. in a class on complex analysis).

By convention $\sqrt{x}$ unambiguously denotes the non-negative square root of $x$, so ‘$f(x) = \sqrt{x}\text{ for }x \ge 2$’ does describe a function.

However, unless you’ve misunderstood her, your teacher is using the term mapping incorrectly. It has a slightly different meanings for different people in different contexts, but in your apparent context I’d expect them to be synonymous, and I’d certainly expect every mapping to be a function. The relation $R$ consisting of all ordered pairs $(x^2,x)$ such that $x$ is a real number is an example of a relation that is not a function, since distinct pairs in $R$ can have the same first component, but it’s not a mapping in any common terminology with which I’m familiar.

• How do you define a mapping? It's usually a function... is it a relation in the way you've defined it for $(x,x^2)$? – Patrick Da Silva Jul 24 '11 at 0:37
• @Patrick: In my experience a mapping is always a function, though sometimes a function with some extra property. That was the whole point of my objection! I don’t understand your second question: every function is a relation, but the relation $R$ is not a function. – Brian M. Scott Jul 24 '11 at 0:41
• I was told a mapping was a function which was one-to-many. One input, multiple results. – Thomas O Jul 24 '11 at 1:04
• @Thomas: That’s just plain wrong. I don’t know of anyone who uses the term that way, never mind that a one-to-many relation is by definition not a function. – Brian M. Scott Jul 24 '11 at 1:07
• Huh? How is your relation $R$ not simply the function $x\mapsto x^2$? I think you meant $R$ to consist of all pairs $(x^2,x)$, or we are working in the opposite category (i.e. your relation is my inverse relation). – wildildildlife Jul 24 '11 at 1:07