Re: [Python-ideas] Trigonometry in degrees

Wouldn't sin(45 * DEG) where DEG = 2 * math.pi / 360 be better that sind(45)? This way we woudn't have to introduce new functions. (The problem with nonexact results for nice angles is a separate issue.) Regards, Adam Bartoš

On Fri, Jun 08, 2018 at 10:53:34AM +0200, Adam Bartoš wrote:
But that's not a separate issue, that's precisely one of the motives for having dedicated trig functions for degrees. sind(45) (or dsin(45), as I would prefer) could (in principle) return the closest possible float to sqrt(2)/2, which sin(45*DEG) does not do: py> DEG = 2 * math.pi / 360 py> math.sin(45*DEG) == math.sqrt(2)/2 False Likewise, we'd expect cosd(90) to return zero, not something not-quite zero: py> math.cos(90*DEG) 6.123031769111886e-17 That's how it works in Julia: julia> sind(45) == sqrt(2)/2 true julia> cosd(90) 0.0 and I'd expect no less here. If we can't do that, there probably wouldn't be much point in the exercise. -- Steve

On Fri, Jun 08, 2018 at 10:53:34AM +0200, Adam Bartoš wrote:
But that's not a separate issue, that's precisely one of the motives for having dedicated trig functions for degrees. sind(45) (or dsin(45), as I would prefer) could (in principle) return the closest possible float to sqrt(2)/2, which sin(45*DEG) does not do: py> DEG = 2 * math.pi / 360 py> math.sin(45*DEG) == math.sqrt(2)/2 False Likewise, we'd expect cosd(90) to return zero, not something not-quite zero: py> math.cos(90*DEG) 6.123031769111886e-17 That's how it works in Julia: julia> sind(45) == sqrt(2)/2 true julia> cosd(90) 0.0 and I'd expect no less here. If we can't do that, there probably wouldn't be much point in the exercise. -- Steve
participants (2)
-
Adam Bartoš
-
Steven D'Aprano