Why does the domain and range of $\sqrt x$ contain only positive real numbers?
The square root of a negative number is defined when discussing complex numbers, but when only real numbers are discussed (as is usual with most of calculus) there is no advantage to using the complex numbers as square roots.
Not an answer, but something heavy I want to get of my chest here: Some of you make statements as "The square root of a negative number is complex" That is from a mathematical standpoint a very poor way of "introducing" complex numbers. It falls in the same category as stating $i=\sqrt{-1}$ whereas $i^2=-1$ is a far better concept. A Squareroot of negative numbers are pretty meaningless in the real word as well as in the complex world, however, an equation like $x^2=-9$ has exactly two (complex) solutions by rewriting $-9=9i^2$ and then take square roots (which is NOT the same thing as saying +/-$\sqrt{-9}$) If we truly want to consider the complex number set as a field (which complex analysts want), we need to step away from this "squareroot of a negative number is complex" notion. More on this here: https://en.wikipedia.org/wiki/Complex_number
Because in these resources $f$ is defined as $$f:A\to B$$ where $A,B\subset \mathbb R$.
Of course square root function $g(z)=\sqrt z$ is defined for every complex argument, moreover - it is multivalued. It means that for example $g(-4)$ may be equal to $2i$ or $-2i$.
The same situation may be noticed on the real line; $x^2=4$ have two roots: $2$ and $-2$, but the function $f$ is single-valued. That's because it is only a branch of square root function, its principal value.