How to compute correctly rounded trigonometric functions in degrees?

前端 未结 4 1500
轻奢々
轻奢々 2021-01-02 18:32

How could I define trigonometric functions that take arguments in degrees instead of the usual radians, and compute correctly rounded results for these arguments?

Mu

4条回答
  •  不知归路
    2021-01-02 18:50

    The only rationals q for which cosdeg(360q) is rational have 1, 2, 3, 4, or 6 as the denominator. This paper by Joerg Jahnel contains a short and beautiful proof using field theory in section 6. (Indeed, the author characterises the degree of the algebraic number cosdeg(360q) using Euler's totient function.) So there is no floating-point q such that cosdeg(360q) is halfway between two adjacent floating-point numbers.

    So I guess the answer is "about the same way you implement sin and friends for radians," though @gnasher729 makes the excellent point that argument reduction for degrees is much, much nicer.

提交回复
热议问题