Consider the function $f$ such that $a \in A$, $b \in B$:
$f : {A} \to {B} \quad$
where $A, B \subset \mathbb{R}$. When writing down $f(a)=b$, how may we define what a rule is for $f$? I know we may write $f(a)=b=a^2$ but I feel like I get confused when describing to someone that $a^2$ is the image of $a$ and also how $a$ is being mapped to $b$. Can someone please help me clarify this or does it sound like I have the right idea?
We don't "give the rule to the function". As a matter of fact, we first have a certain "rule" of interest to us. This rule can be some text describing how the image point of $x$ is found, it can be an expression defining how from an arbitrary number $x$ in the envisaged domain $A$ the function value $y\in B$ can be computed, the rule can be a certain geometric construction explained in a figure, etcetera. Such a rule then gets a name, e.g., $f$, and we sketch a flow diagram like $$f:\quad A\to {\mathbb R},\qquad x\mapsto f(x):={\cos x+e^{-x}\over 1-x^2}\ ,$$ where $A\subset{\mathbb R}$ is some interval containing only numbers $x$ for which the expression on the RHS can be computed, e.g., $A=\>]{-1},1[\>$.