Precision in $f : A \to B$ notation Here I have a nice function (also known as $f(x)=\sin (\pi x/2)+1$) that is continuous on the interval $[0,4]$:
￼
According to the definitions I've found, $f:A\rightarrow B$ means that $\forall n\in A:f(n)\in B$. Therefore, in describing this function’s domain and range, the most precise thing to do would be to say $f:[1,4]\rightarrow [0,2]$. However, from what I understand, this notation is not the most precise, and the following would also be true:


*

*$f:[1,4]\rightarrow [-5,5]$

*$f:[1,4]\rightarrow\Bbb{R}$

*$f:[1,2]\rightarrow\Bbb{R}$


Basically, $A$ must include some—but not all of—$f$’s domain but must not include any number for which $f$ is not defined while $B$ can include any numbers so long as it includes the range of $f$ on $A$—which makes sense when looking at the definition of $f:A\rightarrow B$.
All of this research I’ve been doing (I’m only a junior in high school who just started AP Calculus BC) was originally to determine a concise and symbolic way to express that a function is continuous on a certain interval, but now my question has evolved to include something else: how can one clearly and symbolically define the full domain and range of a function without any ambiguity and in one fell swoop?

Update:
It has come to my attention that codomain and range are actually different. From what I understand at this point, codomain is a kind of restriction on the range. Here's an example:
Let $f:x\mapsto\sin\left(\dfrac{\pi x}{2}\right) +1$, as shown in red:

If one wishes to restrict the domain, simply graph $f:[0,4]\rightarrow\Bbb R$ (as shown in blue):

Want to restrict the range, too? Go ahead and meddle with the codomain. Here's $f:[0,4]\rightarrow [0.25,1.75]$ in green:

As of right now I'm confused as to whether or not you have to restrict the domain to exclude images of x that would be excluded anyways by restricting the codomain
 A: The Range of $f:A\to B$ is sometimes denoted $f(A)$. $f(A)$ is defined as $\{f(a) \ | \  a\in A\}$. A well-defined function (i.e. a function) satisfies $f(A)\subseteq B$.
Requiring a function be defined as $f: A\to f(A)$ is too constricting. While this defines in a sense the "best" restriction of any $f:A\to B$, sometimes the set $f(A)$ is unknowable or tedious to describe.
Take for example the function
$$f:\mathbb N\to \mathbb N, \ \ \ \ f(n) = \text{the $n^{th}$ largest prime number}$$
We don't have a formulaic way to describe $f(\mathbb N)$. $\mathbb N$ is simply a good choice for a codomain, rather than say $\mathbb Z$ or $[0,\infty)$ because the others are unncessarily large or complicated.
A: You are wrong when you say that $A$ must include some, but not all of $f$'s domain. The notation $f:A\to B$ is used to denote a function $f$ whose domain is exactly $A$, and whose codomain is exactly $B$. The notation makes no mention whatsoever of the function's range. To specify the range of a function is not the same as specifying the codomain of that function.
When it comes to precision, the notation $A\to B$ is meant to emphasize the domain and codomain of our function, and besides the most simple cases where it is obvious what the range of the function is, it is up to us to be explicit and identify the range of our function where it is necessary.
For a function $A\to B$ you could come up with another function $g:A\to\operatorname{range}f$ defined by $g(a) = f(a)$ for $a \in A$. This function has the same domain as $f$ and its codomain is equal to its range.
A: The set-theoretic def'n of a function $f:A\to B$ is that $f$ is a subset  of the Cartesian product $A\times B$ such that $\forall x\in A\; \exists ! y\in B\; (\;(x,y)\in f).$ The notation $\exists !y$ means "there exists exactly one $y$" , also said "there exists, uniquely, $y$".
But if any $C$ satisfies $C\supset \{y:\exists x \;(\;(x,y)\in f\}$ then we can also write $f:A\to C.$ So the range $B$ is not uniquely defined.
For any $D\subset A$ we write $f|D$ or, more commonly, $f|_D$ to denote the function $f\cap (D\times B).$ When $D\ne A$ this is called the restriction of $f$ to $D.$
Of course it is convenient to write $y=f(x)$ for $(x,y)\in f.$ For any $D\subset A,$ different authors use different names and notations for the set $\{y:\exists x\in D\;(\;(x,y)\in f\}=\{f(x): x\in D\}.$ E.g., the image of $D$ (under $f$), or $f(D)$ or  $fD$ or $f''D.$  The last one, "$f$-double-prime $D$" or "$f$-double-tick $D$" ,  is favored by many set-theorists, and can be written $f''(D).$
The difficulty with $f(D)$ is that $D$ may be both a subset of and a member of $A=dom (f).$ E.g. $A=\{ \phi, \{\phi\}\}$ and $D=\{\phi \}.$ The problem with $fD$ is that if D is represented by a compound expression and we don't want to introduce another symbol then we will need brackets anyway to avoid ambiguity.(E.g is $fG\cap H$ equal to $f''(G\cap H)$ or to $(f''G)\cap H$ ?). The notation $f(D)$ is common, though, especially in analysis, where it is usually assumed  that $dom (f)$ is anti-transitive. (I.e. members of $dom (f)$ are  assumed not to be subsets of $dom (f).)$
There is also,as usual, some abuse of notation. E.g. when $dom (f)=[0,1)$: "Extend $f$ to domain $[0,1]$ by letting $f(1)=42$", which really means that we define another function $g$ with $g|_{dom (f)}=f ,$ and $dom (g)=\{1\}\cup dom(f) ,$ and $g(1)=42.$  Or, equivalently, "Let $g=f\cup \{(1,42)\}.$" 
A: For a function $f:A\to B$, the domain is $A$, the codomain is $B$, and the image (range) is $\{f(a)|a\in A\}$.
The domain $A$ is all the values that the function is defined on. The function is not defined on any values not in $A$, and it is defined for all values in $A$.
For every element $a$ in $A$, $f(a)$ must be in the codomain $B$.
The image is all the values $b$ for which there exists a value $a$ in the domain such that $f(a)=b$. This leads to the fact that the image is always an improper subset of the codomain.
As for your edit, you can't really restrict the codomain as you would the domain. If you restrict the codomain to exclude some values, but leave the domain the same, now you have some values in the domain for which the function is not defined. That doesn't work. The only way to restrict a function is to restrict the domain. The image may change, but you can leave the codomain as it is.
A: One notation that I have seen is
$f([0, 4])
= [0, 2]
$.
