For reducing such input from a range (-infinity; +infinity) to the target interval (-π; +π] on which trigonometric functions shall operate, the original input must be taken modulo 2π. Performance of such a modulo reduction on limited hardware systems depends on the number of digits you provide for 2π. Said number may be in the order of some hundred to some thousand. How can I specify this number for WolframAlpha?
WolframAlpha understands my request to give me, e.g., 700 digits of 2π and returns them properly. But if and when I try to compute a given real number modulo (700 digits of 2π) it fails to decode my wish and, alas, doesn’t advise me what to do instead. Any hint in this matter is appreciated. Thanks in advance.
Is there any chance that this might do what you want
mod(239,floor(2 pi,10^-700))
That tries to do mod on 239, over the first 700 digits of 2 pi.
I just randomly picked 239 and chose 700 digits because you mentioned 700 digits above.
Before you trust this I urge you to try this with much smaller numbers and see if you get exactly the result that you are expecting. Please test this multiple different ways to try to make sure this is correct. The limited testing that I have done seems like it is doing this correctly.
Thank you! Seems to work. What’s irritating, however, is that the result of mod( r, floor(2π, 10^(-n))) for r being some 10^260 stays constant from n = 300 to 1100 digits of 2π. Looks like a precision limit in WA to me. Do you have an idea?
Could you come up with one specific value for r and two specific values for n where the result should be different for those two values of n and why those two results should be different instead of the same? With that I can try to pound on this and see if I can reproduce your result and try to understand why there should be two when we only get one.
The number 5.319372648326541416707296656673541083813*10^255 is a floating point number, with an accuracy of something like 10^216. For such a number it makes no sense to ask mod(x,2Pi), if it is divisible by 6, its cosine, or similar things.
You can’t rely on W|A treating input like Mathematica does. Just what it does is a mystery to me, and I wouldn’t trust it to check a high-precision algorithm.
While 5.319372648326541416707296656673541083813×Power[10,255] is a floating-point number in WL and the following code fails in Mathematica, W|A treats the input differently:
What’s confusing for the most precise reduction modulo 2π, however, is that WA returns 0…×10^201 immediately, then 0…×10^135, then 0…×10^64, and then 3.7227… - you have to press [more digits] three times to get the “true” result, and the previous zeros are just misleading.
Furthermore, the number line is completely off: no idea what the programmer meant here:
I was pointing out to Gianluca why I think W|A is not using floating-point numbers in this case. A four-year-old does not know what floating-point numbers are — I didn’t know until sometime after high school. Nor is a 4yo likely to be able to run WL code, but I think Gianluca can. I guess I’d tell the 4yo not to worry about it. (?)
The number line plot represents what is obtained when the calculation is performed with floating-point numbers. I guess that’s how the number line was computed. Perhaps this is what Gianluca was referring to. (I had ignored it until you brought it to my attention.)
Wonder why WA displays a number line which is definitly wrong - it shows a dot in an entirely different ballpark. They should at least update it when the numeric result is updated.