# is sin(x) / sin(x) = 1?

I tested this in python using:

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 10*2*np.pi, 10000)
y = np.sin(x)
plt.plot(y/y)
plt.plot(y)


Which produces:

The blue line representing sin(x)/sin(x) appears to be y=1

However, I don't know if the values at the point where sin(x) crosses the x-axis really equals 1, 0, infinity or just undefined.

• When $\sin x\ne0$ – J. W. Tanner Jul 10 at 22:16
• When $\sin(x)=0,$ $\frac{\sin(x)}{\sin(x)}$ is undefined. – Thomas Andrews Jul 10 at 22:16
• Can you post the whole script with the import statements? – peter.petrov Jul 10 at 23:06

Let's ask a simpler question: is $$\frac{x}{x} = 1$$ ?

The answer (which follows from the axioms for a field) is that $$y = \frac{x}{x} = x \cdot x^{-1}$$ is undefined if $$x = 0$$, so while $$\frac{x}x = 1$$ for $$x \ne 0$$, for $$x = 0$$ it's not even defined.

What about $$y = \frac{x-a}{x-a}$$? Once again, that's equal to $$1$$ for $$x \ne a$$, and undefined for $$x = a$$.

Now let's bring computers into it. The way we draw plots on a computer is to take a sequence of points $$x_1 < x_2 < x_3 < \ldots < x_n$$, and plot them with their corresponding $$y$$-values. In between these points, we, as authors of naive plotting programs, often connect the dots with a line segment because...well, because that's usually right, for nice-enough functions. When your functions have discontinuities, though, it's definitely not right.

In the case of $$y = \frac{x}{x}$$, if the $$x_i$$ are all nonzero, then the corresponding $$y_i$$ are all $$1$$, and we connect-the-dots to get a horizontal line at $$y = 1$$, which is correct everywhere except where $$x = 0$$, which should be a hole in the graph, but won't be. Of course, if one of your $$x_i$$ actually is zero, then when your computer attempts to compute $$\frac{x_i}{x_i} = \frac{0}{0}$$, it'll probably produce NaN, a special value meaning "not a number," and the graphics-plotting part of the program will perhaps ignore it (bad) or perhaps try to use it to plot something (which will be nonsense).

In short, in this case, mathematics and computing have diverged from one another.

What about the $$\frac{x-a}{x-a}$$ case? The answer's the same: your $$y_i$$ values will all be $$1$$, unless some $$x_i = a$$. But what if $$a$$ is a number that cannot be represented on a computer, something like $$a = \pi$$? Then you're guaranteed that the $$y_i$$ values will all be $$1$$, and you'll see a horizontal line, even though you should see a line with a hole in it. In short, the plot is guaranteed to be wrong (unless the software is much more subtle than the sort of thing you showed).

Key idea: Computer numbers and real numbers are not the same, and for subtle stuff like well-defined-ness and limits, pretending that they are the same can lead to some bad results, and often deep misunderstandings.

• @SeverinSchraven Agreed. It's what I suspected - the graphing library won't plot "holes". Additioanally, the series I'm plotting probably contains no "holes" anyway, as the x axis is discretely sampled in non-pi intervals. – Tobi Akinyemi Jul 10 at 23:04
• I'm not sure plotting holes in a graph of "y=1 except at discontinuities" would be correct anyway, since the holes would be infinitely thin, and should be rounded to zero in terms of how many pixels they occupy on your screen. – Brilliand Jul 11 at 6:49
• Every feature, including the curve itself, is infinitely thin. We make choices in our pictorial (and "sampled" or "discretized") representations. The challenge, for the person making those choices, is to do so wisely, so as to communicate the important details (and "discontinuities" are often among these) and elide others. The first four stanzas of the second fit of "The Hunting of the Snark" (literaturepage.com/…) says all this better than I ever could. – John Hughes Jul 11 at 10:50
• @TobiAkinyemi pyplot will plot holes, in the sense that if the arrays contain NaNs the corresponding points ignored, and the lines cut (if you are plotting lines). In your example you cannot see it, but the first point is not plotted because it is NaN. – fqq Jul 11 at 11:30
• @Brilliand there are plotters that inserts circles representing holes, as opposed to inserting a "gap" which you suggest – Tobi Akinyemi Jul 11 at 12:33

The function

$$f(x)=\frac{\sin(x)}{\sin(x)}$$

has an infinite number of what are called removable singularities. If we consider the singularity at $$x=0$$, we can see that

$$\lim_{x\to0}f(x)=1$$

and thus we are able to "redefine" $$f(x)$$ so that it takes a value at all points. It is very important that you understand that the function is undefined at these singularities, but it is also very convenient and often very important to have a function which is defined for all values. What python is actually plotting is

$$g(x)=\begin{cases}\frac{\sin(x)}{\sin(x)},\quad\text{if x\neq n\pi}\\ 1,\qquad \text{ otherwise}\end{cases}$$

where $$n$$ is an integer. Without the explanation that we are removing removable singularities, you might see many authors write $$f(x)=1$$.

As another example, if you are familiar with integration, you may see someone (or you yourself) write $$\int_{-\infty}^\infty x dx=0$$

in any number of contexts, but this is actually the Cauchy principal value of the integral. The actual integral diverges.

I agree with the other answer to this question, but it seems to really discuss how computing and mathematics disagree, while I would say that you should expect these implicit evaluations beyond just computing, as we ourselves do them frequently as well.

There are few misconceptions regarding the rational functions. For example, if $$f(x) = \frac{x^2 -1}{x-1}$$ Then, we usually find that people write it out as $$f(x) = x+1$$ But they are not equivalent, they differ from each other at $$x=1$$ where the former is undefined while the latter have the value as $$1$$. Let's start with $$f(x) = x+1$$ and try to get $$\frac{x^2 -1}{x-1}$$.

$$f(x) = x+1 \\ f(x) = x+1 \times \frac{x-1}{x-1} \\ f(x)= \frac{x^2-1}{x-1}$$ We can justify the second step by saying "well, $$\frac{x-1}{x-1}$$ is basically 1, we got a division by itself" but we forget two things, first $$x-1$$ is not a constant like real numbers it's a changing quantity, second the at $$x=1$$ we will get $$x-1$$ as 0. Now, will the argument "we got a division by itself" work? No, because 0 is something which doesn't have a property "itself". You can read division by zero here

So, in the case $$\frac{\sin x}{\sin x}$$ we get $$\sin x$$ as 0 for $$x= 2\pi n$$, $$n= 0, 1 \cdots$$. Therefore, functions $$f(x) = \frac{\sin x}{\sin x} \\ g(x) =1\\$$ are equivalent, except at points $$x=0, 2\pi, 4\pi, 6\pi \cdots$$.

Hope it helps!

• Your $f$ is undefined at $x=1$ and not $x=0$. – Gary Jul 11 at 11:15
• @Gary Thank you for that. – Knight Jul 11 at 11:17