Under what circumstances can one divide by a variable? In light of recent responses to my other questions, I would like to know when it is mathematically acceptable to undergo division by a variable or a function of a variable, i.e., $x$ or $\cos x$. From what I sort of understand, it is only acceptable to divide by $x$ when $x$ is known not to be $0$. For all other cases, division cannot be undergone. In addition, I believe my Precalculus teacher said diving by $\cos x$ also should not occur because $\cos x$ can equal $0$ at $x=\frac{(2n-1)\pi}2$ where $n\in \mathbb{Z}$. How can I avoid dividing by $0$? Under what other circumstances could I accidentally divide by $0$?
 A: First things first: I think you meant $n \in \mathbb{Z}$ instead of $n \in \mathbb{R}$ for $x= \frac{(2n-1)\pi}{2}$. $\mathbb{R}$ stands for real numbers. This are numbers like 1 and 2, but also $\frac{2}{3}$ and $\pi$. $\mathbb{Z}$ stands for integers. So $1 \in \mathbb{Z}$ and $1 \in \mathbb{R}$, but $\pi \notin \mathbb{Z}$ while $\pi \in \mathbb{R}$.
Now for the real question.
$\cos$ is essentially a function, just like $f(x)$.
Say you want to divide by a function $f(x)$ (where $f(x)$ can be any function). You can do this for any value of $x$ for which $f(x) \neq 0$ (as far as I know at least for $x \in \mathbb{R}$).
Say for example $f(x) = x - 5$. You can divide by $f(x)$ if $x \neq 5$.
The same holds for $\cos$. So let's say we have $\cos(x)$ (or $f(x) = \cos(x)$ if you like). $\cos(x) = 0$ if, as you pointed out, $x=\frac{(2n-1)\pi}{2}$ with $n \in \mathbb{Z}$. Since we want to devide by $\cos(x)$, we must be sure that $x \neq \frac{(2n-1)\pi}{2}$.
More general, if we want to devide by $f(g(x))$, we calculate $f(a) = 0$ and set this $a$ equal to $g(x)$ (so we calculate $g(x) = a$). The resulting value(s) of $x$ is for which we can't devide by $f(g(x))$.
As a concrete example, say we have $$g(x) = x^2 + 6x$$ and $$f(g(x)) = g(x) + 5$$ and we want to determine for which values of $x$ we can calculate $$h(x) = \frac{1}{f(g(x))}$$
First, we set $g(x) = a$, so $f(g(x))$ becomes $$f(g(x)) = f(a) = a + 5$$ Setting $f(a)$ equal to zero we get $a = -5$. Now we set $g(x)$ equal to $a = -5$ and solve for $x$:
$$g(x) = a$$
$$x^2 + 6x = -5$$
$$x^2 + 6x + 5 = 0$$
$$(x+1)(x+5) = 0$$
$$x = -1 \text{ or } x= -5$$
So we can calculate the value of $h(x)$ except for $x = -1$ or $x = -5$, where it is undefined.
Hope it helped you a bit. Please not that I'm not a professional mathematician, so please ask someone else too. The last thing I want is you getting a bad grade because of my answer (I'm not responsible for that. $:)$). If someone from the community notices something wrong or wants to add something, please edit this question. I would be thankful.
A: I think the most thorough way to think about is this: under what circumstances can you multiply by the inverse of $x$?
This also works in cases when division isn't defined, but inverses exist (more advanced mathematical contexts like groups and matrices). 
