Is $f(x)=x^2$ from $\mathbb{R} \to \mathbb{R}$ surjective? A surjective function $f$ is one such that for all $y$ in the codomain of $f$, there exists an $x$ in domain of $f$ such that $f(x) = y$. Mathematically, we can show that for $f(x) = x^2$ where $f: \mathbb{R} \to \mathbb{R}$, this statement is true. However, looking at the graph, the negative values in the codomain of $f$ do not have any corresponding $x$ values in the domain of $f$. Therefore $f(x)=x^2$ is not surjective? So if I am solving a question like this for a function more complicated than $f(x) = x^2$, and I see that $f(x) = y$, then how to know if it is actually surjective? As it is possible for a function to show that $f(x) = y$ but it may not necessarily be surjective because there may be values in the codomain that do not get mapped by values in the domain, such as $f(x)=x^2$ from $\mathbb{R}$ to $\mathbb{R}$. Thanks
 A: Since you seem to confuse 'codomain' with 'image', let me first describe some general notions for you. Suppose we have a function $f: X \to Y$. Then the codomain is the set $Y$. However, we also have the notion of 'image'. The image is defined as
$$\text{Im}(f) = \{y \in Y \vert \exists x \in X \text{ such that } f(x) = y\}$$
and from this definition it is clear that we always have that the image of $f$ is a subset of the codomain of $f$.
Let us now return to your original example, being $f: \mathbb{R} \to \mathbb{R}: x \to x^2$. From the aforementioned, we have that the codomain of $f$ is $\mathbb{R}$. However, the image of $f$ is $\mathbb{R}^+$, the set of positive real numbers (including zero). Hence it is clear that $f$ in this case is $\textbf{NOT }$ surjective. Indeed, take for example $-2$ (which is an element of the codomain), there is not element $x$ in the domain such that $x^2 = -2$. The reason we can take this counterexample is that the codomain strictly contains the image.
However, we can solve this problem by restricting the codomain to the image. Consider the function
$g: \mathbb{R} \to \mathbb{R}^+: \to x^2$, then this function is surjective. Indeed, our counterexample with $-2$ of before will not work in this case, since $-2$ is not an element of the codomain of $g$. Another way to see this is that the codomain of $g$ is equal to the image of $g$. (Note that this is in general applicable to make functions surjective: restricting its codomain to its image).
Although $f$ and $g$ have the same graph, they are considered to be different functions, since they don't have the same domain and codomain.
All of this explicitely shows the importance of denoting the codomain, since surjectivity of a function is determined by this information!

An analogous reasoning applies to 'injectivity' of a function. If we again consider the example $f: \mathbb{R} \to \mathbb{R}: x \mapsto x^2$, then this function is not injective! Indeed, if we take $-2$ and $2$, which are both elements of the domain, then $f(-2) = f(2)$, although $-2 \neq 2$. 

This problem can be solved by, in this case, restriction the domain. Consider the function 
$g: \mathbb{R}^+ \to \mathbb{R}: x \mapsto x^2$, then $g$ is injective. Indeed, our counterexample of $-2$ and $2$ will not work in this case, since $-2$ is not an element of the domain. 

Long story short: It is very important to denote your functions properly and to see the difference between notions such as codomain and image, since properties of functions such as injectivity and surjectivity depend on it.
A: You can approach the problem analytically directly. Let $y < 0$. Then there is no real $x$ such that $f(x) = x^{2} = y$. This shows that $f$ is not surjective.
The graph is consistent with what mathematically has shown. As you saw, the graph does not go into the plane $\mathbb{R} \times \{ y \mid y < 0 \}$.
