# Why are vector valued functions 'well-defined' when multivalued functions aren't?

I'm looking for an 'intuitive' answer here, because I have no formal mathematical training but find myself in a comparatively math-heavy PhD (visual perception; lots of neuroscientists on the one side and CS folk on the other).

Only functions which map some number of inputs to a single output are considered 'true' or 'well-defined' functions. I've seen squaring (and presumably other exponents) given as an example: [any number] squared produces a single 'output', though some outputs for different inputs may be the same: e.g. -2 and 2 squared both equal 4. By contrast, I've seen square-root given as an example of a NON-'well-defined' function, because sqrt(4) can equal both 2 and -2. A single input maps to multiple outputs, violating the definition of a 'true' function.

(EDIT: As @Eff says in the comments, this is an incorrect example because sqrt(4) is in fact defined to equal 2 alone. But I hope my broader point is still clear)

Presumably, the benefits of 'true' functions as defined by this constraint come in terms of assumptions one can make, and guarantees one can rely on when reasoning about the function. Vector-valued functions return multiple scalar values (organised within a tuple) and considering my programmer background I can't see how this differs, except in terminology, from a multivalued function.

Yet I have never read anybody suggesting vector-valued functions aren't true functions. As it stands, if I were faced with the task of inverting a function which takes multiple inputs, I'd simply define the inverse as vector-valued, to sidestep the constraint. My sqrt(4) would be the tuple (2,-2). From a software engineering perspective, even in C where functions may return no more than one argument, that argument could be an array or a struct. It feels like either both or neither of multivalued and vector-valued functions meet the definition of being 'well-defined' / 'true' functions. What am I misunderstanding?

• The (principal) square root function is not multi-valued, it is well-defined and $\sqrt{4} = 2$, not $-2$. Functions have a domain and a co-domain, and vector-valued functions make sense if the co-domain is a set containing vectors. Your square root function $f: [0,+\infty)\to\mathbb{R}^2$ defined by $x\mapsto (\sqrt{x},-\sqrt{x})$ is well-defined. – Eff Apr 6 '15 at 19:06
• There's no reason you can't define your sqrt(x) = (|x^(1/1)|,-|x^(1/1)|). It would be well-defined, and if you restrict your codomain, it's a bijection, thus it has an inverse. In the case of your inverse function, one possible construction would be where codomain is the set of vectors in the form (a,b), with a<=0, b>=0, and a=-b. – r12 Apr 6 '15 at 23:55
• Basically, if I have a function and I say it outputs an integer, but it then outputs a bunch of integers, that is bad, because the output was supposed to be an integer. On the other hand, if I specify that the function outputs collections of integers, and it outputs a single collection of integers, that is good, because it was supposed to do that. By saying you can only output one thing, you have to specify what type of collection you output it with. Its like if you had a sqrt function, but when you ran it it somehow forced both the positive and negative answer into the program. – PyRulez Apr 7 '15 at 0:29
• I would say the only misunderstanding is conceptual. You are confusing a whole for the sum of it's parts. Vector's parts (in your example) are numbers, but having few numbers is not the same as having a vector: vector has more structure - you know exactly which number is first, which is second etc. Think of a movie theater ticket. On it are written two numbers - row number and number of seat in a given row. These are not two outputs but only one - location of your seat. Now imagine if your ticket had two locations. Where would you sit? – Ennar Apr 7 '15 at 10:14

## 8 Answers

What you are getting confused by most probably is the fact that a vector seems to be multiple elements, but really it's not, it's just a single element which (often) has multiple parts.

You can even have so called set-valued functions. An easy one to think of is the function which takes a positive integer to the set of its prime divisors. Let's call this function $\pi$.

The important thing in both these cases is that a given input only has one output. So in the case of a vector-valued function the output is the full vector (all of its parts). In the case of the set valued function for prime divisors you have to get the set of all the prime divisors. So for example $\pi(15)=\{3,5\}$ you can't have $\pi(15)=\{3\}$ or $\pi(15)=\{5\}$. There is only the one set containing all the divisors. It's the same situation with vector-valued functions. There is only one vector for any input. The function can't return just part of a vector. Thus we still have only one output for every input--it's just a bigger output.

As to why we don't define inverses as vector valued, that has a very easy reason. They wouldn't be inverses anymore. The definition of an inverse to a function $f$ is a function $g$ for which $g(f(x))=x$ if the value of $g$ is a vector containing $x$ that doesn't do what we want. It doesn't tell us the value of the original input to function $f$.

• "not inverses anymore" I'm not sure you're saying anything very clear in your last paragraph about inverses. If your function f is a bijection, an inverse function g exists. If he decided to define his sqrt function as sqrt(x) = (|x^(1/1)|,-|x^(1/1)|), for sqrt:X->Y, where X is the set of reals and Y = {(a,b):a>=0,b<=0, a=-b}, then he as defined a bijection, and thus an inverse function exists. I think you're trying to answer the "what's the point?" question, but instead you're giving a bit of a "is it possible?" answer. It is possible (I just did it), but it may not be very purposeful. – r12 Apr 6 '15 at 23:52
• @rodney Hmm I think I might have not expressed myself correctly. What I thought the OP was proposing was to take functions which are not injective (such as $x^2$ not square root, since the usual definition of that trivially has an inverse) and define "pseudo inverses" by sending $f(x)$ to a vector of all $y$ such that $f(y)=f(x)$. Ignoring the problem with ordering the preimages, you are also left with the problem of not having defined an inverse to the original function since your domains and ranges don't even match up. – DRF Apr 7 '15 at 5:33

Your intuition seems fine; the issue seems primarily linguistic.

Let's start with the usual (mildly pedantic) definition of a "function" in terms of sets: If $X$ and $Y$ are non-empty sets, their Cartesian product $X \times Y$ is the set whose elements are ordered pairs $(x, y)$ with $x \in X$ and $y \in Y$. A function $f:X \to Y$ is a subset of $X \times Y$ satisfying the following property:

For every $x$ in $X$, there exists a unique $y$ in $Y$ such that $(x, y) \in f$.

The conceptual content is that each input $x$ uniquely determines the output $y = f(x)$. Philosophically, a function can be viewed as a mathematical formalization of determinism: If initial conditions (i.e., $x$) are known, then a subsequent state (i.e., $y$) is uniquely determined.

Note that to avoid verbal ambiguity, mathematicians always (at least implicitly) specify the domain $X$ (the set of inputs) and the target $Y$ (the set of potential outputs) when speaking of a function. (Non-mathematicians can often afford to be more lax, writing down formulas or the equivalent and speaking of "the corresponding function".)

It's certainly useful in some circumstances to allow "multi-valued functions". A multi-valued function $F:X \to Y$ might be defined as a subset of $X \times Y$ satisfying the property:

For every $x$ in $X$, there exists a $y$ in $Y$ such that $(x, y) \in F$.

Just as in computer science, a multi-valued function $F:X \to Y$ may be "interpreted as" (or, more precisely, "converted to") a single-valued function by allowing the function to return a "compound data structure" rather than an element of $Y$.

To convert a multi-valued function into a single-valued function, we might view $F$ as taking values in the power set $\mathscr{P}(Y)$, whose elements are subsets of $Y$.

For example, if $X = [0, \infty)$ and $Y = (-\infty, \infty)$ denote intervals of real numbers, the set $$F = \{(x, y)\text{ in } X \times Y: y^{2} = x\}$$ would be the (generally double-valued, i.e., not well-defined) "square root function", $F(x) = \pm\sqrt{x}$.

The "value" of $F$ at a positive real number $x$ could, however, be viewed as the set (a.k.a., unordered pair) $\{\sqrt{x}, -\sqrt{x}\}$. Doing so would amount to defining a single-valued (i.e., well-defined) function $F_{1}:[0, \infty) \to \mathscr{P}\bigl((-\infty, \infty)\bigr)$ in "the obvious way": If $0 \leq x$, then $y \in F_{1}(x)$ if and only if $y^{2} = x$, if and only if $y = \sqrt{x}$ or $y = -\sqrt{x}$. As a formula, $$F_{1}(x) = \{-\sqrt{x}, \sqrt{x}\}.$$

Alternatively, the "value" of $F$ could be viewed as an ordered pair: $(-\sqrt{x}, \sqrt{x})$. Doing so would amount to defining a single-valued function $F_{2}:[0, \infty) \to (-\infty, \infty) \times (-\infty, \infty)$. As a formula, $$F_{2}(x) = (-\sqrt{x}, \sqrt{x}).$$

(One can imagine returning even more exotic objects, such as probability measures on a set of elements. The point is, there's not a unique way of making a multi-valued function into a single-valued function.)

Again, the primary issue seems linguistic. The single relation $F$ above may be viewed as "double-valued" in the real numbers (not well-defined); as single-valued in sets of reals; or as single-valued in ordered pairs of reals. But there's no terminological ambiguity, because a mathematician would view these as three distinct entities.

• If we're going to be pedantic, then the "a function is its graph" definition is just barely not good enough because it doesn't allow one to talk of surjective functions. For example we could look at $$G = \{(x,y) \in \mathbb R^2 \mid y = x^2\} = \{(x,y) \in \mathbb R \times [0,\infty) \mid y = x^2\}.$$ Is $G$ the graph of $\mathbb R \owns x \mapsto x^2 \in \mathbb R$, or of $\mathbb R \owns x \mapsto x^2 \in [0,\infty)$ or maybe it has some entirely different codomain? – kahen Apr 6 '15 at 23:49
• Indeed, the Bourbakist definition of (partial) function is as an ordered triple $f = \langle D,G,C\rangle$ "(domain, graph, codomain)" such that $$G \subseteq D \times C \text{ and }(x,y),(x,y') \in G \implies y=y'.$$ A function is then a special case of partial function where $$x \in D \implies (\exists y \in C : (x,y) \in G).$$ – kahen Apr 6 '15 at 23:54
• @kahen: Perhaps I've missed your point? The $G$ in your first comment is unambiguously surjective because the codomain is the second factor in the Cartesian product. If we were speaking of squaring as a map from the reals to the reals, we'd be looking at the subset $$\{(x, y) \in \mathbf{R} \times \mathbf{R} : y = x^{2}\}.$$That is, my wording was intended to convey (albeit colloquially, per the OP's request) that a function from $X$ to $Y$ is the triple $(X, Y, f)$. Is that not precisely the content of your second comment? – Andrew D. Hwang Apr 7 '15 at 12:01
• It seems that you missed my point. I was saying that it isn't clear from $G$ whether I was talking about $x \mapsto x^2$ as a function from $\mathbb R$ to $\mathbb R$ or as a function from $\mathbb R$ to $[0,\infty)$. It's clearly only surjective in the latter case. Expanding the codomain of a function doesn't change its value, behaviour or graph (in analysis we most of the time don't really care about specifying the codomain too precisely, even), but it does change it as a function since it may go from being surjective to being... well... not. – kahen Apr 7 '15 at 12:51
• @kahen: Now it seems you've missed my point. :) By writing, "If $X$ and $Y$ are non-empty sets [...] a function $f:X \to Y$ is a subset [...]", I meant that $X$, $Y$, and $f$ are all essential to the definition, i.e. (in Bourbakese) that a function is a triple $(X, Y, f)$ satisfying conditions as in your second comment. On this point it seems we agree. Given that understanding, are you saying the definition I gave is lacking? – Andrew D. Hwang Apr 7 '15 at 14:04

Your terminology is confusing because there is such a thing as a vector valued function, that's a legitimate (and well defined) function into something like $\mathbb R\times\mathbb R$. What you mean is "why can't a function take two different values on the same input?" Such a thing does exist, it's called a relation. But a relation is not a function unless it has an extra property. There's no harm in working with relations, they just don't satisfy all the nice properties functions do, so you really need functions and not just relations to make headway.

• Do vector-valued functions have all these nice properties? How do vector-valued functions differ from relations? – benxyzzy Apr 6 '15 at 19:21
• Vector-valued functions are functions $f:X\rightarrow V$ where $V$ is a vector space. They are fully valid functions with all the properties that come from being a function. – Gregory Grant Apr 6 '15 at 19:24
• A function $f:X\rightarrow Y$ is a subset $S\subseteq X\times Y$ with the property that $(x,y)\in S$ and $(x,y')\in S$ $\Rightarrow$ $y=y'$. A relation is instead simply any subset of $X\times Y$ without the extra condition. – Gregory Grant Apr 6 '15 at 19:25

This is because of how we define equality of vectors:

$$(x_1,\dots,x_n)= (y_1,\dots,y_n) \iff x_1=y_1, \dots, x_n=y_n$$

A function $f:A \to B$ being single-valued if $a = b \implies f(a)=f(b)$.

Take for example the function $f: \mathbb{R} \to \mathbb{R}^2$ given by $f(x) = (x,2x)$.

This is well-defined because for any two numbers $x,y$ we have: $$x=y \implies x=y,2x=2y \implies f(x) = (x,2x) = (y,2y) = f(y)$$

Certain objects are called functions if they fit a certain defining criteria. If an object does not fit the definition of a function, it is not a function. On one hand, this is completely arbitrary. On the other hand, a large amount of mathematics depends heavily on this definition, so changing this definition to suit your fancy is not a task to take lightly.

You need to ask yourself if the 'functions' you are working with need to obey the mathematical definition of a function: in particular, do your research and conclusions depend on mathematical theorems that expect a function to behave a certain way? If they do, you should stick to the accepted definition. If they don't, you should stick to the accepted definition anyway.

To answer your direct question: a function that returns a vector fits the definition of a function because the 'single returned value' is a vector, and a vector is a single object. This is the same as a computer function returning a pointer or reference to a data structure other than the built in primitive types. When you call this computer function, you expect only a single return, and your algorithm functions properly. If you are expecting a vector, then your program probably knows to make sure it got a vector and then does something with that vector.

If you have a function that takes a number as input and returns a number, then any mathematical expression or computer program will be written expecting a single number. If you get a set or vector instead, then your expression or program will not work as expected.

A well defined Function is a function that when you give an input there is only one output. if different inputs coincide with some outputs its ok .BUT you cant have an input giving you 2 outputs

For vector-valued function, it's a function because it's a relation where every input has exactly one output. The key part about that definition is that it doesn't specify what type of output it has to be.

In math, a function is just a relation between two sets where each input has exactly one output. (There may be more nuance than that, I haven't looked up the formal definition in awhile.)

In your post, you use terms like "'true' function", as if there's a different type of function. There isn't. A relation is either a function or not a function. It isn't more complicated than that.

In your square-root example, f(x) = x^(1/2), you can simply define the output to be always positive, and it's a function. Or you could define the output to be positive or negative, and it's not a function. Your relation will still exist, but the state of your relation being a function will have changed.

For a 'multi-valued function', I'm assuming you mean 'valued' to mean the output value from the function for a given input, and 'multi-valued' to mean some inputs in the function has multiple outputs. That's not a function. That's something else (a relation). As I said above, a function is a relation where each input has exactly one output. If an input has multiple outputs or no outputs, it's not a function.

If you restrict the inputs so the cases where multiple or no outputs are removed, your relation has become a function. If you restrict the outputs so that each input has exactly one output, your relation has become a function.

If you want good intuition in math, you need to realize that your choices are where the flexibility lies, not in the definitions. Your definitions are immutable, but you can pick and choose which definitions you choose to accept/deny, and how to apply them. Be careful, however, because with your definitions comes all their logical extensions, which sometimes will make your choices of definitions meaningless.

(Some interesting things may show up if you say that the set of permissible outputs is a set of sets. For example, F:R->A, where f(x) = {y: x>y}, and R is the set of reals. That is, for a given input x a real number, the output is the set of all reals greater than that number. (I think) this would be a function, because although each set contains an infinite set of reals, each set is a single output object of the function.)

For a simple example, consider throwing a ball. The position of the ball is a function of time since you expect the ball to be in one place only (ignoring quantum effects). On the other hand, the position is somewhere in space so you will need a vector with three components (there goes relativity too) to determine its location.

• There's several answers now which clear this up for me (and which I've upvoted), but in response to your insightful one: I guess I'm saying why couldn't you treat the function of time describing that ball's position as a relation of t to x, y, and z? Why the trouble of grouping these into a vector? Why does drawing square brackets around [x,y,z] turn a relation into a 'well-defined function'? That was the crux of my question. – benxyzzy Apr 7 '15 at 20:13
• @benxyzzy What I was trying to get at with this example is that the function has a single well-defined value, which is the position of the ball; it just happens that we define that position using three numbers. I'd also point out that x(t), y(t) and z(t) are functions in their own right, not 'just' relations. This will always be true with vector functions. Contrast this, for example, to the squares on a chessboard accessible by a knight's move, where any one location is not a function of that move. – Alchymist Apr 8 '15 at 11:12