tan(x) Gap

EnderHorn

New member
Joined
May 25, 2021
Messages
3
I'm messing around with Desmos Graphing Calculator and I plug in f(x) = tan(x) into a box. I then have a point with the coordinates (a, f(a)) with a being a slider I can manipulate. The result of this is a point that goes along the graph of tan(x). I noticed that at some points on the graph, there was a small gap following the graph where f(a) was undefined. After further investigation, I found that this gap had a length, meaning that there was an area rather than a point where it was undefined. The length of this gap was approximately 0.00000000000000022204460492503132 units long. I have no idea where this oddly specific number came from, and I have no idea how to find out. Does anyone know why this number appears here?
 
Do you understand why the tangent is undefined at pi/2? Do you understand that a calculator has limitations on how large a number it can handle? Put these ideas together.

The length of your gap will depend on internal features of the program; can you explain in more detail how you worked out such a precise number?
 
I'm messing around with Desmos Graphing Calculator and I plug in f(x) = tan(x) into a box. I then have a point with the coordinates (a, f(a)) with a being a slider I can manipulate. The result of this is a point that goes along the graph of tan(x). I noticed that at some points on the graph, there was a small gap following the graph where f(a) was undefined. After further investigation, I found that this gap had a length, meaning that there was an area rather than a point where it was undefined. The length of this gap was approximately 0.00000000000000022204460492503132 units long. I have no idea where this oddly specific number came from, and I have no idea how to find out. Does anyone know why this number appears here?
There is nothing more odd about this number than any other number; each number is unique.

Computers and calculators do not compute and calculate exactly. There are numbers that are too big (or too small) for them to code. Any number beyond capacity is going to initiate an error rotine.
 
Dr.Peterson, the reason why the tangent is undefined there is because it is where cos(x) equates to 0, and that cos function is used as a denominator in the tan function, and anything divided by 0 is undefined. Following this logic, the area that is undefined should be a single value, not a gap as I found. As for the calculator's limitations, I'm not entirely sure exactly how it is related to this problem, but I have considered this and eliminated it as a possibility. If it were the problem, then this number would have been something more round like 0.00...01. Also, the way I came to this number was by entering the maximum number in each digit that would still be undefined, therefore resulting in a number right at the border of where it is defined and undefined. I then multiplied that result by 2 to account for me starting at the center rather than the leftmost side of the gap, and that is how I got that number. From this, I have no variables to work with to see where the number originated from, and I feel that it is too specific of a number to have something to do with how the calculator functions.

JeffM, because of how specific it is, I don't think that it has anything to do with the program itself as said before. On top of this, if the calculator had seen this as an error, it wouldn't have sent the tan function in the first place because of how it works, so it can't be an error in the function. As for me calling the number odd, I was referring to how I couldn't trace it back to any known variables.

Also, sorry if I'm being a bit persistent on how the calculator works, I just don't believe it has anything to do with it.
 
True, tanx is undefined at pi/2 since cos(pi/2)=0.
Now how close can the angle get to pi/2 and still be able to (in theory) calculate the tan of that angle? As close as you want! You can calculate the tan (pi/2 + .0000000000000001) and tan(pi/2- .0000000000000001). In fact you can add more zeros and calculate tan (pi/2 + .000000000000000000000000000000001) and tan(pi/2- .00000000000000000000000000001). You can even put in more zeros! There is NO gap!
 
Dr.Peterson, the reason why the tangent is undefined there is because it is where cos(x) equates to 0, and that cos function is used as a denominator in the tan function, and anything divided by 0 is undefined. Following this logic, the area that is undefined should be a single value, not a gap as I found. As for the calculator's limitations, I'm not entirely sure exactly how it is related to this problem, but I have considered this and eliminated it as a possibility. If it were the problem, then this number would have been something more round like 0.00...01. Also, the way I came to this number was by entering the maximum number in each digit that would still be undefined, therefore resulting in a number right at the border of where it is defined and undefined. I then multiplied that result by 2 to account for me starting at the center rather than the leftmost side of the gap, and that is how I got that number. From this, I have no variables to work with to see where the number originated from, and I feel that it is too specific of a number to have something to do with how the calculator functions.

JeffM, because of how specific it is, I don't think that it has anything to do with the program itself as said before. On top of this, if the calculator had seen this as an error, it wouldn't have sent the tan function in the first place because of how it works, so it can't be an error in the function. As for me calling the number odd, I was referring to how I couldn't trace it back to any known variables.

Also, sorry if I'm being a bit persistent on how the calculator works, I just don't believe it has anything to do with it.
It has everything to do with it. The limit of tan(x) as x approaches pi/2 radians is infinite. There will therefore be a band of values on either side of pi/2 where the value of tan(x) exceeds the limitations of the hardware. Those limitations will be defined physically. Of course they will be specific.

Why bother to come to a site, ask a question, get two consistent answers from two different people, and then dispute those answers? There is a discontinuity in the tangent function at (pi/2) + k * pi if and only if k is an integer as you can easily confirm by looking at the definition of the tangent function in terms of the sine and cosine. There is no finite interval of undefined values. What you observed is a spurious result caused by the limits of hardware.

You clearly know nothing about the trigonometric functions or the physical limitations on hardware. But, because you clearly want to argue, I suggest you ask the manufacturer of the calculator or application why it gives provably erroneous results.
 
Dr.Peterson, the reason why the tangent is undefined there is because it is where cos(x) equates to 0, and that cos function is used as a denominator in the tan function, and anything divided by 0 is undefined. Following this logic, the area that is undefined should be a single value, not a gap as I found. As for the calculator's limitations, I'm not entirely sure exactly how it is related to this problem, but I have considered this and eliminated it as a possibility. If it were the problem, then this number would have been something more round like 0.00...01. Also, the way I came to this number was by entering the maximum number in each digit that would still be undefined, therefore resulting in a number right at the border of where it is defined and undefined. I then multiplied that result by 2 to account for me starting at the center rather than the leftmost side of the gap, and that is how I got that number. From this, I have no variables to work with to see where the number originated from, and I feel that it is too specific of a number to have something to do with how the calculator functions.
First, you clearly know that the tangent is undefined at a discrete value, so the "gap" must be an artifact of how it is being calculated.

The reason the tangent is undefined at that point is that as x approaches it, the value becomes infinite. A program can't possibly calculate every number less than infinity, so there has to be some point away from that point where it would stop returning a value and report it as undefined. Software can't represent the theoretical reality of the function.

There is a lot going on inside a program (in this case, Desmos). The issue will be something inside their calculation of the tangent, either an actual overflow, or quite likely an arbitrary value within the algorithm at which they choose to call it undefined.

As for this, I suppose you are assuming the code would have to be choosing some simple value in decimal as the cutoff point. But the calculation is actually done in binary, and the decision to call it undefined may well be somewhere deeper in the code than the input to the tangent function itself. I know enough about software to know I can't exclude that possibility because of my guess as to how it might work!

Your question is interesting -- where does that number come from? -- and if we knew what they use to do the calculation, it's just possible that someone could actually figure out the answer.

Your method of finding the cutoff is also interesting, and I've replicated it. I've determined that it isn't something as simple as the tangent reaching a value too large to store; but in order to give an answer to your question, I'd need to know more than I know about their code. You could write to the makers of Desmos; but I doubt they would make the effort to find out. (Or maybe someone there is curious and bored ...)
 
First, you clearly know that the tangent is undefined at a discrete value, so the "gap" must be an artifact of how it is being calculated.

The reason the tangent is undefined at that point is that as x approaches it, the value becomes infinite. A program can't possibly calculate every number less than infinity, so there has to be some point away from that point where it would stop returning a value and report it as undefined. Software can't represent the theoretical reality of the function.

There is a lot going on inside a program (in this case, Desmos). The issue will be something inside their calculation of the tangent, either an actual overflow, or quite likely an arbitrary value within the algorithm at which they choose to call it undefined.

As for this, I suppose you are assuming the code would have to be choosing some simple value in decimal as the cutoff point. But the calculation is actually done in binary, and the decision to call it undefined may well be somewhere deeper in the code than the input to the tangent function itself. I know enough about software to know I can't exclude that possibility because of my guess as to how it might work!

Your question is interesting -- where does that number come from? -- and if we knew what they use to do the calculation, it's just possible that someone could actually figure out the answer.

Your method of finding the cutoff is also interesting, and I've replicated it. I've determined that it isn't something as simple as the tangent reaching a value too large to store; but in order to give an answer to your question, I'd need to know more than I know about their code. You could write to the makers of Desmos; but I doubt they would make the effort to find out. (Or maybe someone there is curious and bored ...)
Dr. Peterson

You are too kind.

From all I have heard from this poster, he either does not believe that there are only point discontinuities in the tangent function because some calculator says so, or else he believes that the reason for the erroneous results is not related, either through hardware or software, to the limitations of finite-bit, floating-point arithmetic.

You are of course correct that the software may avoid overflow errors from ever arising and, if that is so, the immediate cause of the gap is related to software, but the proximate cause is related to the limitations of hardware. Because software is frequently designed to run on many types of hardware, it may have cut-offs that seem arbitrary without detailed knowledge of what hardware and operating systems the software is warranted to run on.

The fact is that this particular system is not able to evaluate tan(x) when it is close to but not equal to a point of discontinuity. There is no mystery. Any system will encounter the same problem, but probably not at the same values. I do not think the OP has a clue what we are talking about.
 
No, I know what you guys are talking about now. I was just a bit confused because I found multiple definitions for tan, and I was kind of jumping between definitions where some were right for this post and some weren't. Regardless, I still think that it's interesting that the number would show up here from a hardware perspective too. Being a programmer myself, I can confirm that it is very weird for this number to show up like this, but that has probably got to go on another board. I was also just a bit hesitant to throw 3 hours of work away because of a hardware issue. Regardless, thanks for helping with this!

(Also, "You clearly know nothing about the trigonometric functions or the physical limitations on hardware. " and "I do not think the OP has a clue what we are talking about. " kind of hurt...)
 
Top