# When is it really neccessary to check for division by zero?

I was reading these notes: https://www.math.usm.edu/lambers/mat169/fall09/lecture23.pdf

The author solves the following system:

$$A = \begin{bmatrix} u_1 & u_2 & u_3 & 0 \\ v_1 & v_2 & v_3 & 0 \\ \end{bmatrix}$$

At some point he mentions: "for simplicity, we assume $$u_1 \neq 0$$", and proceeds with the solving it, but he does not bother addressing the case in which "$$u_1 = 0$$".

I used WolframAlpha to row reduce A. Row reduction results in:

$$R_A = \begin{bmatrix} 1 & 0 & \frac{u_3 v_2 - u_2 v_3}{u_1 v_2 - u_2 v_1} & 0 \\ 0 & 1 & \frac{u_3 v_1 - u_1 v_3}{u_2 v_1 - u_1 v_2} & 0 \\ \end{bmatrix}$$

Lets assume $$u_1 = 0$$:

$$B = \begin{bmatrix} 0 & u_2 & u_3 & 0 \\ v_1 & v_2 & v_3 & 0 \\ \end{bmatrix}$$

Row reducing B results in:

$$R_B = \begin{bmatrix} 1 & 0 & \frac{u_2 v_3 - u_3 v_2}{u_2 v_1} & 0 \\ 0 & 1 & \frac{u_3}{u_2} & 0 \ \end{bmatrix}$$

So in the end $$R_B = R_A$$ when $$u_1 = 0$$. It wouldn't really matter if we didn't check for division by zero. I'm puzzled by this result as to when am I supposed to check for division by zero. Especially in a system like this that is composed of variables only. If we do perform all the necessary checks we will end up multiple nested cases and calculations that may be redundant.

• So if I try to solve the above I will have to check: If $u_1 \neq 0$ then divide by $u_1$ and proceed. If $u_1 = 0$ then check whether $v_1 = 0$. If $v_1 \neq 0$ then divide by $v_1$ and proceed, else if $u_1 = 0$ and $v_1 = 0$ then check whether $u_2 = 0$ etc etc? I was thinking that it could be possible to solve this by saying something like "without loss of generality we assume that $u_1 \neq 0$ – Nick Oct 8 '19 at 8:07
• @Nick You can only say "without loss of generality" if there is, well, no loss of generality. Knowing there will be no loss of generality is different from case to case, and in this case, I don't see a simple way of showing there is no loss of generality if you say $u_1=0$. In fact, there is loss of generality, since $u\neq 0$ excludes the possibility that $A$ is the zero matrix, in which case solutions may not exist. – 5xum Oct 8 '19 at 8:13