13
$\begingroup$

Consider:

Sin[Pi/5]

which returns: $$\sqrt{\frac58-\frac{\sqrt5}{8}}$$

Does anyone know how to figure out the trigonometric identities used by Mathematica to produce this answer?

I gave this a try:

WolframAlpha["sin(pi/5)"]

but it did not provide any steps.

$\endgroup$
5
  • 1
    $\begingroup$ How Mathematica itself calculates it is only known to its developers. How one might calculate it with pen and paper belongs on Math.SE, I think. $\endgroup$
    – Szabolcs
    Commented Jan 16, 2016 at 16:39
  • 9
    $\begingroup$ Have a look here $\endgroup$ Commented Jan 16, 2016 at 16:46
  • 1
    $\begingroup$ According to Goldstine, Ptolemy started with Sin[Pi/5] and Sin[Pi/3] when constructing his "table of chords," probably from Eu. XIII.10. $\endgroup$
    – Michael E2
    Commented Jan 16, 2016 at 17:13
  • $\begingroup$ See also http://functions.wolfram.com/ $\endgroup$
    – user9660
    Commented Jan 16, 2016 at 17:34
  • 1
    $\begingroup$ @Szabolcs I don't think you need to be a developer to guess that it works by a simple lookup. $\endgroup$ Commented Jan 18, 2016 at 20:32

1 Answer 1

17
$\begingroup$

In the course of answering this question, I ran into a little bit of weirdness that doesn't square with my experience with previous versions of Mathematica. I think writing this answer is as good a time as any to bring it up.

Firstly, there is this tantalizing line from the internal implementation notes:

FunctionExpand uses an extension of Gauss's algorithm to expand trigonometric functions with arguments that are rational multiples of $\pi$.

Indeed, in the old versions of Mathematica, FunctionExpand[] certainly was able to convert trigonometric values at rational multiples of $\pi$ to the corresponding radical values (possibly involving complex numbers). This hinged on the function Developer`TrigToRadicals[], and in fact one could use this directly instead of FunctionExpand[].

Now, however, FunctionExpand[] no longer seems to perform this conversion. Using Developer`TrigToRadicals[] throws an error message saying that it is obsolete, and that one should now use ToRadicals[] instead. The kicker is that ToRadicals[] and Developer`TrigToRadicals[] return different-looking (but numerically equivalent) results, which means the internal algorithms have been changed somewhat.

Quite a mystery.


Now, "Gauss's algorithm" is not terribly informative, considering that Gauss was a rather prodigious producer of mathematical results. However, there is a section in Gauss's Disquisitiones Arithmeticae (sorry, I couldn't find a free English translation) that relates to a number-theoretic view of the roots of unity (and thus, trigonometric functions). In particular, he outlines in one section a recursive method for determining explicit radical expressions of roots of unity.

There is, however, a more modern method that improves on the asymptotic complexity of Gauss's algorithm. In this paper, A. Weber presents an improvement of Gauss's original algorithm that hinges on an efficient way to evaluate the "recursive step" in the original method. A Maple implementation of this improved method is presented in the paper; I will wager that this method, with possibly a few proprietary extensions, is the guts behind Developer`TrigToRadicals[]. (It should be noted that Weber's paper also points to alternative algorithms for explicitly producing radical expressions; I have not been able to find those references, so I cannot say much about them. Maybe an expert can chime in.)

As for the original question, although $\sin(\pi/5)$ is automatically converted to a radical result in the current version of Mathematica, it is likely that the improved Gauss algorithm was used to produce the radical expression in the first place.

$\endgroup$
2
  • $\begingroup$ ToRadicals[Cos[Pi/257]] fails to give the correct answer. Developer`TrigToRadicals is slower, but is correct. $\endgroup$
    – btwiuse
    Commented Jan 13, 2017 at 0:43
  • 3
    $\begingroup$ The current code (V12) may be inspected with Simplify`TrigToRealRadicals; System`TrigToRadicalsDump`sin // DownValues or PrintDefinitions. $\endgroup$
    – Michael E2
    Commented Oct 30, 2021 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.