How do I break down these math functions? I apologise as I know I'll probably get a lot of criticism here but I desperately need help as I've no idea how math functions work! I've looked through books, youtube videos, asked my tutor... but nowhere can I find an example that breaks down each component and what it is actually doing. It seems (from my perspective) that numbers (and answers!) are plucked from thin air.
Example A, $f: \mathbb{Z} \to \mathbb{Z}$ given by $f(m,n) = m + n + 1$.
Example B: $f: \mathbb{R} \to \mathbb{R}$ given by $f(x)=(x+1)(x+2)$.
This just looks like hieroglyphics to me. I don't get it at all!
I'm supposed to determine onto/1-1 but how do I know what numbers to put into the domain vs codomain? How do I know if the numbers in domain "relate" to numbers in codomain? What is showing the relation?
Here is what I wrote to try to solve example B so you can see I have no idea what I'm doing...
$Y=f(x), y=(x+1)/(x+2)  x=x-2overx-1$???
Domain $1,2,3...$ (domain of inf real numbers?)
Codomain:
if $x=1$ then $(1-2)/1-1)$** cannot divide by zero
If $x=2$ then $(2-2)/(2-1)=0$
If $x=3$ then $(3-2)/(3-1)=\frac{1}{2}$
Etc
**I reverse it??
My understanding is I pluck a number from the sky that becomes $x$ and then do "some calculation" to get the co-domain (probably wrong). And how would I know whether they "match"???
And example A has two numbers as $x$ so wth is with that?!
I know I'm rambling but I really need someone to break the parts down for me so I can finally do these! If you can help I'd be very grateful. Thank you!
 A: I will try to explain how I see a function.
A function is a tool, a tool that transforms what we call a vector ( usually name $x$ ) into another vector. I guess you have been working with function that are defined on $\mathbb{R}$ and that gives for a vector $x \in \mathbb{R}$ another number that you called $y \in \mathbb{R}$. We usually note $f : \mathbb{R} \rightarrow \mathbb{R}$.
A function $f : \mathbb{R} \rightarrow \mathbb{R}$ transforms a point to another point. That's why you draw the abscisse $Ox$ that is the real line where $x$ takes it value and then you drax the axis $y$ which will be the value of $f(x)$. Then each point $(x,f(x))$ is colored black and the rest in black, you have the graph of the function.
The unique function that transforms a given point to the same point is called the identity and it is trivially defined as $f : x \mapsto x$.
What it means is for a number for example $4$, you will by $f$ another number maybe $6$ maybe $\pi$ it depends on the function you are considering.
Such a function exists on a domain $D$ if the image of an element $x \in D$ actually exists. Most problems comes from fractional function where you have to check that the dominator does not equal to $0$. For example $\displaystyle x \mapsto \frac{1}{x}$ will be defined (almost) everywhere, $1/\text{something}$ does not bother except if this something is $0$. Hence it is defined on $\mathbb{R}^{*}$. For your example $B$.
$$
f : x \mapsto \frac{x+1}{x+2}
$$
All reals are will be defined unless the dominator $x+2$ equals to $0$ because it will tends to $+\infty$ and not take a finite value. So it is defined on $\mathbb{R}$ minus $-2$.
A more original way to consider a function is to see it as a " deformation " of the graph $y=x$. 
We've seen that a function can transform a real to another real. Your example A is not this type of function. It transforms a point of a plan to a real number.
For example the origin of the plan $P$ axed with $\left(O,x,y\right)$ will be given the value $1$. Imagine it is gridded. Then every point on the grid situated on the diagonal who goes through $(0,0)$ will be given the value $2n+1$, depending on how far you are on this diagonal.
A: Understand "Domain" as the set of  allowable “input” values, 
For example,
The function $f(x)=2x+1$ can be evaluated for any value of $x$. Hence, it's Domain will be All Real Numbers, which is denote by $\mathbb R$, this include $1,2,3,0.1,0.5,\sqrt 2 , \pi , e, 10^{100} \ldots \text{etc.} $ i.e. every possible number.
Now coming to next example $f(x)= \dfrac{1}{x-1}$ Now, this one is  little tricky. You'll have to observe that if  we assign the value $1$ to the variable $x$, the you'll get $0$ in the denominator, which isn't allowed in Mathematics.
So, you kick out $1$ out of all the possible values. Hence, your domain becomes all real values, except $1$, which in a fancy way can be written as $\mathbb R - \{1\}$.
You got a feel for domain now? If yes, read further.
Now we move to understand "Range". It is the set of all values that an expression can produce. 
Let's take the same example, I used before. the function $f(x)=2x+1$ has the power to produce all possible values. 
Let's check. Can we get the output $1$? Just equate the function to the value $1$ and see whether any $x$ exists so that it may give $1$ as output.
$2x+1=1$
Is it solvable? Hell yeah! $x=0$ is the solution. So $1$ is the part of range. Similarly, every number can be equated and we can get every real number as the output.
Let me know in the comment if this is helping you. If yes, then I'll cntinue further.
A: Domain and Codomain are often poorly introduced (the latter term is often skipped over, and related by distinct idea of range is asked about instead). Formally, a function is a specific type of relation. Which motivates us to ask: what is a relation?
This is turn is defined using sets. An easy way to think of sets is to think of them as 'containers' they 'contain' things. A set is nothing more that a collection of specific (mathematical) things, which are called the elements of the set. For example the set $\mathbb{R}$ contains all of the real numbers (that's things like $3,\frac{6}{7},\sqrt{2},\pi,e$, etc.), the set $\mathbb{Z}$ contains all of the integers (such as $-5,0,1,7$, etc.).
Relations can be thought of as an association between elements of a set called the 'domain' and another set called that 'codomain'. These sets need not be different, but they can be (and often are). Formally, a relation is just another set, constructed out of ordered pairs whose left entries are elements of the domain, and whose right entries are elements of the codomain. Which ordered pairs of those that can be constructed are actually in the relation determines the precise association that relation defines between domain and codomain. As an example, consider the relation $\{ (1,2),(3,4),(1,3),(5,5)\} $ between domain=integers and codomain=integers (note that in this case, domain=codomain, but that need not occur in general). The order pairs each denote an association between specific elements. 1 in the domain is associated with 2 in the codomain (3 as well), 3 in the domain is associated with 4 in the codomain, and 5 in the domain is associated with 5 in the codomain. Because of how little is actually required in the definition of relation, relations are extremely general and broad and can have potentially little in the way of mathematically interesting structure. Most of the important relations in mathematics satisfy particular properties, such as the reflex or transitive properties. One such class of relations are known as functions. They are defined by two key properties (for which I will use my own names):
1: Coinjective property: A relation is 'coinjective' if for any two distinct elements, $y_1,y_2$ of the codomain, $Y$, there does not exist an $x$ in the domain, such that, $(x,y_1)$ and $(x,y_2)$ are both in the relation.
2: Cosurjective property: A relation is 'cosurjective' if for every $x$ in the domain, $X$, there exists some $y$ in the codomain, $Y$, such that $(x,y)$ is in the relation.
The first property basically says that: for each element of the domain that relates to something (in the codomain) it relates to only one thing in the codomain. (So for every $x$ in the domain, there is, at most, one thing in the codomain it is related to.) The second property says that every element of the domain relates to something in the codomain (at least 1). Together they imply that a relation that is both coinjective and cosurjective must relate each domain to exactly one thing in the codomain (note however that what that thing is depends on the particular thing in the domain one is considering).
A function then, is a relation which is both coinjective and cosurjective. As a result, we can think of a function as 'transporting us' from the domain to the codomain. It means each element of the domain to exactly one place in the codomain (which depends on the given thing in the domain we are considering). Hence a common synonym for function is 'map' (or 'mapping').
The functions you are encountering are written in a kind of shorthand. This is because they relate infinitely many things and it would impractical (in fact impossible) to write down the complete list of ordered pairs. So instead what is done is that a 'rule of assignment' (typically called a formula) is created to describe, generically, what any element in the domain relates to in the codomain. It is typically implied that the domain is the real numbers, or the largest subset of the real numbers for which the formula is well-defined (or 'makes sense'; for instance, $\frac{1}{x}$ does not make sense when $x=0$, but it does for every other possible real number $x$).
