What is the exact definition of a metric? In some book I found, a metric on a non-empty set $X$ defined as a map
$$X\times X\to \Bbb R^{+}$$
and some other place as
$$X\times X\to \Bbb R$$
So, is a metric a real valued function or a non-negative real valued function or it doesn't matter at all? 
Since metric is a generalization of distance on the real line. I was convinced by the first definition. But the second one? I don't know and the worst part is, it is widely used definition. 
 A: You didn't read far enough when you looked at "some other place." If you had, you'd see nonnegativity is included as an axiom. Metrics always take nonnegative values.
A: A metric on $X$ is a map $d:X\times X\to \mathbb R$ that satisfies certain conditions:


*

*$\forall x,y\in X\  d(x,y)\ge 0$

*$\forall x,y\in X\  \text{if }d(x,y)=0\text{ then }x=y$

*$\forall x,y,z\in X\ d(x,y) \le d(x,z)+d(z,y)$


The first condition implies $d:X\times X\to [0,\infty)$.
A: If you write $X \times X \to \Bbb R^+$, you don't need to note that $d(x,y) \geq 0$ for all $x,y$, since it is already implied by the use of $\Bbb R^+$. If you write only $X \times X \to \Bbb R$, you must call the attention to this fact.
A: Non-negativity of a metric is implied by the axioms that define it. This can be seen in the following way. Take any $x, y \in X$. Then from the triangle inequality, we have $d(x, y) + d(y, x) \ge d(x, x)$. But from symmetry of the metric, $d(x, y) = d(y, x)$, so that $2d(x, y) \ge d(x, x)$. And from the fact that $d(x, x) = 0$, we get $d(x, y) \ge 0$.
Sometimes $d(x, y) \ge 0$ is taken as an axiom depending on whose definition you use, but all these definitions are equivalent.
