Determining if the following sets are an equivalence relation I am trying to determine if the following sets are equivalence relations:

Set: $B=\mathbb{R}$
Relation: $x \sim y$ if $|x-y|\leq 1$

Reflexive property: For $x \sim x$, we have $|x-x|\leq 1=|0|=0\leq1$ so this is true.
Symmetry property: We need to ensure that if $x \sim y$ then $y \sim x$. This is also true since we have $|y-x|=|-(x-y)|=|x-y|$ and we know that $|x-y|\leq1$ so symmetry is satisfied.
Transitive property: I always struggle with this part. I think what I need to show is that if $|x-y|\leq1$ and $|y-z|\leq1$, then $|x-z|\leq1$. If my assumption is right, how would I go about doing this? My idea was to write $|x-z|\leq1$ as $|(x-y)+(y-z)||\leq1$. Since $(x-y)$ and $(y-z)$ could both potentially equal something that adds to a value larger than 1, transitivity is NOT satisfied so this is not an equivalence relation. However, I am not sure if this is the right approach...

Set: $B=M_n(\mathbb{R})$, the set of $n \times n$ matrices with real entries, where $n$ is some fixed positive integer.
Relation: $X \sim Y$ if $Tr(X-Y) \in\mathbb{Z}$

Reflexive property: For $x \sim x$ we have $Tr(X-X)=0\in \mathbb{Z}$ so the reflexive property is satisfied.
Symmetry property: We need to ensure that if $x \sim y$ then $y \sim x$. We have $Tr(Y-X)=-Tr(X-Y)$ which is still in $\mathbb{Z}$ so symmetry is satisfied
Transitivity: Again, this is what I struggle with. I believe that here, we need to check that if $Tr(X-Y)\in \mathbb{Z}$ and $Tr(Y-Z)\in \mathbb{Z}$, then we need to show that $Tr(X-Z)\in \mathbb{Z}$.
My idea was to write $Tr(X-Z)$ as $Tr(X)-Tr(Z)$. However, I am not sure if this implies that $Tr(X)\in \mathbb{Z}$ and $Tr(Z)\in \mathbb{Z}$ which implies transitivity.
Any guidance on this would be very much appreciated! Also, is my work on the other properties right?
 A: I'll answer this in two parts, as you have asked.

$B = \mathbb R$, and $\sim$ is such that $x\sim y$ if $|x-y| \le 1$. The relation $\sim$ is reflexive and symmetric as you've shown. However, it is not transitive.
To see this, consider $0,1,2\in\mathbb R$. $0\sim 1$ since $|0-1| = 1 \le 1$. Also, $1\sim 2$ since $|1-2| = 1 \le 1$. Sadly, $0 \not\sim 2$, since $|0-2| = 2 > 1$.

$B = M_n(\mathbb R)$, and $\sim$ is such that $X\sim Y$ if $\text{trace}(X-Y) \in \mathbb Z$. Once again, you're right about the reflexivity and symmetry parts. I shall show transitivity. Suppose $X\sim Y$ and $Y\sim Z$. Thus, $\text{trace}(X-Y) \in\mathbb Z$ and $\text{trace}(Y-Z) \in \mathbb Z$. Since the sum of two integers is an integer, we have $\text{trace}(X-Y) + \text{trace}(Y-Z) \in \mathbb Z$. Note that in general, for any two square matrices $A$ and $B$ of the same order, $\text{trace}(A+B) = \text{trace}(A) + \text{trace}(B)$. So,
$$\text{trace}(X-Y) + \text{trace}(Y-Z) = \text{trace}(X) - \text{trace}(Y) + \text{trace}(Y) - \text{trace}(Z)\\=\text{trace}(X) - \text{trace}(Z) = \text{trace}(X-Z)$$
Hence, $\text{trace}(X-Z)\in\mathbb Z$ and $X\sim Z$ as required. Thus, $\sim$ is an equivalence relation (reflexive, symmetric and transitive).
