Domain, Codomain, Range, Image and Preimage

Consider a function for example $f:R\to R$ defined by $f(x)=x^2$. The domain is the largest possible set of inputs which in this case the set of all real numbers. The codomain is given as $R$, the set of all real numbers. The range is the set of all possible outputs which is the interval $[0,\infty)$.

The image of a subset $A$ of of real numbers is $f(A)$ which is the set of all $f(x)$ where $x\in A$. For example, $f((-1,1))=[0,1)$.

The pre-image of a subset $B$ of the range is the set $f^{-1}(B)$ of all inputs $x$ such that $ f(x)$ is in $B$. For example $f^{-1}([1,4])=[-2,-1]\cup [1,2]$.