Skip to content

Roots of unity of order 5 and 6 come back with an unevaluated sin/cos in them #743

Description

@Rafael-SOWNet

Found while measuring #272, and not fixed by it.

x^n - c = 0 is answered by inverting x^n = c, which gives the roots in a + bi form. For n = 5 and n = 6 some of those parts are left as an unevaluated trigonometric call rather than as the exact value they have:

solve  x^6 - 1 = 0
  { 1, 1/2 + i * 1/2 * sqrt(3), -1/2 + i * 1/2 * sqrt(3), -1,
    -1/2 + i * 1/2 * sqrt(3) * (-1), 1/2 + i * sin(5/3 * pi) }
                                              ^^^^^^^^^^^^^^

solve  x^5 - 1 = 0
  { 1, 1/4 * (sqrt(5) - 1) + i * 1/4 * sqrt(10 + 2 * sqrt(5)),
    cos(4/5 * pi) + i * 1/4 * sqrt(10 - 2 * sqrt(5)), ...,
    ^^^^^^^^^^^^^
    1/4 * (sqrt(5) - 1) + i * sin(8/5 * pi) }
                              ^^^^^^^^^^^^^

sin(5/3 * pi) is -sqrt(3)/2 and cos(4/5 * pi) is -(1 + sqrt(5))/4, so these are exact answers wearing an unevaluated form. The other roots of the same equation are written out, so the output is not even internally consistent: x^6 - 1 gives its second root as 1/2 + i * 1/2 * sqrt(3) and its last as 1/2 + i * sin(5/3 * pi), which are conjugates.

This is the same complaint as #272 ("awful responses for 3+ degree polynomials"), and it survives the fix for it in #742 — two-term polynomials are deliberately left to the inversion route there, because for x^3 - 8 that route gives the better answer.

Fixing it means either evaluating the sin/cos of these rational multiples of pi where an exact value exists, or having the inversion route produce the value directly. The exact-value table for inverse trig constants added earlier (#569/#179) is the neighbouring machinery.

Measured on 40ce1093.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions