6

If we want to calculate $\sin(x)$ and $\cos(x)$ for very large $x$ , lets say $10^5$ , the usual way is to reduce the number $x$ modulo $2\pi$.

If the number is a large power of a small number, for example $2^{200}$, we could also use $$\cos(2x)=\cos^2x-\sin^2x$$ and $$\sin(2x)=2\sin(x)\cos(x)$$ multiple times.

Do we have any chance, if the power is too high for both methods ? For example, can we calculate $\sin(x)$ and $\cos(x)$ for $x=10^{10^{10^{10}}}$ ?

Note, that the power tower must be calculated from above. So, we have

$$x=10^{(10^{(10^{10))}}}$$

In tetration-notation, we can write $x=10\uparrow\uparrow 4$

Peter
  • 86,576
  • I guess the question should be: "Is it effective to use the trigonometric identities to calculate $\cos,\sin$ for extremely large $x$", no? If you assume that you can use that identity to calculate small numbers, then you can use it to larg $x$, it would only take more time. – Red Banana Oct 06 '16 at 20:39
  • 1
    If I have a small (oldstager) advice, don't ask yourself too artificial questions. There are enough interesting things with "natural" issues. Moreover, the barrier is not of mathematical order : you will reach the computional limit of your machine (machine's epsilon or machine's NaN). – Jean Marie Oct 06 '16 at 20:44
  • 1
    @JeanMarie I don't understand what you're trying to say. – Jam Oct 06 '16 at 20:51
  • A weird thing : I have a table calculator "GENIE 102 SC" which returns the absurd value $2.8\cdot 10^{72}$ for $\cos(10000)$. First, I guessed, $10000$ would be too high because for numbers like $10000.1$ or $10001$, it also gives similar results, bur for $\cos(10003)$ , for instance , is calculated perfectly right. Has anyone any explanation for this behaviour ? – Peter Oct 06 '16 at 20:52
  • 1
    If the direct method on machines has a limit, this does not necessarily mean that there is no way to use mathamtical properties to get beyond that limit. For example, it is possible to calculate $\ln(10^{10^{100000}})$, although the direct method gives an overflow. – Peter Oct 06 '16 at 20:55
  • Three things: 1) Don't take it as a strong criticism, but I am always sad to see (young ?) people loosing time in deadends 2) I have never seen trigonometric functions computed with an argument of the form 10^(10^(10^10...)) 3) On the computational side, which is an interesting side, cos(10^(10^(10^10...))) cannot be computed in a straightforward manner (for machine's precision, see for example https://en.wikipedia.org/wiki/Machine_epsilon) – Jean Marie Oct 06 '16 at 20:58
  • 2
    @JeanMarie $1)$ I am not young, I am $46$ years old. $2)$ I do not think that I lose time if I think about the limits of computability $3)$ Maybe someone knows properties about the trigonometric functions that can actually calculate what I want. In this case, it is not at all a loss of time to ask such a question. From a pragmatical point of view, you are probably right. But impractible mathematical topics are often much more interesting. – Peter Oct 06 '16 at 21:06
  • 1
    @JeanMarie I see what you're saying and while I agree that we shouldn't waste time on dead ends (I, for one, wasted at least a day of my summer when I was 17 trying to integrate $\int e^{\sin x}$ before I learnt that Galois Theory was a thing) but this definitely isn't a completely niche and inapplicable question, I actually wanted to know just a couple of weeks ago what $\sin(10^{10^{10^{10}}})$ was. And like Peter says, if we can calculate $\ln10^{10^{10^{10}}}$, it wouldn't be stupid to wonder if we can calculate $\sin10^{10^{10^{10}}}$, especially given that we know it's in $[-1,1]$. – Jam Oct 06 '16 at 21:07
  • Related: http://math.stackexchange.com/questions/1561713/how-would-you-reduce-roundoff-error-in-mod-when-implementing-a-periodic-functi http://www.csee.umbc.edu/~phatak/645/supl/Ng-ArgReduction.pdf – Ian Oct 06 '16 at 21:18
  • @Peter Dude, you're in the comments from a few months ago of someone asking a duplicate question lol http://math.stackexchange.com/questions/1849541/how-to-compute-the-sine-of-huge-numbers – Jam Oct 06 '16 at 21:24

1 Answers1

3

By computing $\cos(x)$ and $\sin(x)$ (and thus $\exp(ix)$), you are in effect computing the fractional part of $x/(2\pi)$. Any numerical procedure that attempts to do this (approximately) must deal with the fact this is extremely sensitive to small relative errors in $x$, when $x$ is large. Thus if you want to approximate $\cos\left(10^{10^{10}}\right)$ to any accuracy, you'd need to do computations with at least $10^{10}$ significant digits. This might be near the boundary of feasibility with today's computers. But for $\cos\left(10^{10^{10^{10}}}\right)$, you'd need $10^{10^{10}}$ significant digits; the known universe wouldn't be big enough to store that many digits.

Robert Israel
  • 470,583
  • 2
    I agree that the reduction modulo $2\pi$ cannot be done in this case, but there might be completely other approaches. – Peter Oct 06 '16 at 21:12
  • Any formula for $\cos(Nx)$ (where $N$ is a large integer) in terms of $\cos(x)$ and $\sin(x)$ suffers from the same sensitivity problem. You might do $\cos(N x)$ algebraically if $x$ is a rational multiple of $\pi$ (since you just need to know $N$ modulo twice the denominator), but $\pi$ is irrational so this won't help for $x=1$. – Robert Israel Oct 06 '16 at 21:19