-2

if a function all have exactly one output per input, then how come $f(x)= \sqrt{x}$ is a function? assuming $f: \mathbb R \rightarrow \mathbb R$. When $f(-1)$ it outputs a complex number and is not part of the codomain, this is really confusing me.

My second confusion is f$(x)=1/x$, call it $g: \mathbb R \rightarrow \mathbb R$. When $x = 0$, it doesn't output a something in the co-domain since $1/0$ is undefined. So it must not be a function? Or is it I don't know. Pardon my English thank you.

N. F. Taussig
  • 76,571
  • 4
    A function is not just a formula; the domain and codomain are part of the definition of any function. E.g., $1/x$ is not a function on the reals, but it is a function on the nonzero reals. – Gerry Myerson Mar 26 '22 at 12:12
  • It is rather confusing that $\mathbb R->\mathbb R$ is not allowed if the function is not defined for all real numbers. The domain is the set of non-negative real numbers , OK. But in the theory of turing machines it is common that a function over the naturals might be undefined for some (or all) natural numbers. – Peter Mar 26 '22 at 12:21
  • For $\sqrt x$ ,if your codomain is R then your domain should be$x>0$. –  Mar 26 '22 at 12:21
  • But to answer your question : For non-negative real numbers $x$ , there is a clear convention what $\sqrt{x}$ is, hence with the domain of the non-negative real numbers, $\sqrt{x}$ is a function. For negative $x$, there is no convention which complex (non-real) number we should choose. – Peter Mar 26 '22 at 12:22
  • For $\frac{1}{x}$, you can choose $\mathbb R${$0$} to get a function. For $x=0$, it is not defined. – Peter Mar 26 '22 at 12:25
  • Thank you all for the answer, my conclusion is I can just play with the domain. –  Mar 26 '22 at 12:29
  • 1
    If you searched "is sqrt a function", you'd find this. and if you searched "is 1/x a function", you'd find this. – Joe Mar 26 '22 at 12:33
  • @SecretYesNo: Please don't vandalize questions (including your own!), especially after people have taken time to answer them. – Blue Feb 18 '23 at 12:38

2 Answers2

4

When we define any function $f: A \rightarrow B$, its domain $A$ must be carefully chosen so that $f(x)$ is a unique, well-defined, output for each input variable $x$ in the domain $A$.

If we take $f(x) = + \sqrt{x}$, then it is a well-defined function over the non-negative real number system, i.e. if we take its domain as

$A = \{ x \in \mathbf{R} : x \geq 0 \}$.

Similarly, if we take $g(x) = {1 \over x}$, then $g$ is well-defined except at the point $x = 0$.

Hence, $g(x)$ is a well-defined function over $\mathbf{R} \setminus \{ 0 \} $, i.e.

Domain(g) = $\{ x \in \mathbf{R} : x \neq 0 \}$.

Dr. Sundar
  • 2,677
1

The key thing there is that you don't have $f:\mathbb{R}\to\mathbb{R}$ for $f(x)=\sqrt{x}$. Instead we usually either define it as a function $f:\mathbb{R}^+_0\to\mathbb{R}$, or a function $f:\mathbb{R}\to\mathbb{C}$ depending on our purpose. As you say, if we want the domain to be $\mathbb{R}$, then we need the codomain to be $\mathbb{C}$.

For $f(x)=\frac{1}{x}$, a similar thing applies. It is not a function with domain $\mathbb{R}$, but it is a function with domain $\mathbb{R}\setminus\{0\}$.

Lorago
  • 9,239