Why do we use radians in programming?
Asked Answered
S

2

8

I like radians just as much as the next guy, and typically prefer to use them over degrees, but why do we use radians in programming?

To rotate something 180 degrees, you need to rotate it by 3.14159265.... Sure, most languages have some kind of constant for pi, but why do we ever want to use irrational numbers like pi when we can instead use integers, especially for simple programs?

We're relying on the computer to say that 3.14159265 is close enough to pi that functions like sine and cosine return the proper values, but if a computer is too accurate, then the values would be slightly off (sin(3.14159265) = 0.00000000358979303). This isn't an issue when using 180 degrees.

Silencer answered 9/4, 2012 at 4:51 Comment(0)
S
9

It actually is an issue, it just shows up in different ways, especially if you don't stick to 90 degree increments.

Ultimately, it comes down to the mechanisms used to compute trig functions are defined in terms of radians (even when implemented by a CPU's microcode; you might want to examine a numerical methods text for details, but they really do want to be done in radians) and working in degrees then requires constant conversions between the two, leading to cumulative errors. Since floating point (and transcendental numbers in particular) has plenty of error built into it already, adding that additional conversion on top is both slowing things down and adding even more avoidable error.

Soddy answered 9/4, 2012 at 4:59 Comment(1)
I like this answer, but weren't software trig functions in radians long before CPU microcode existed to do trig.Ophthalmic
F
0

Therefore sine is not a base unit system as you consider a base unit system is able to verify his own result by another base unit system.(arithmetics) The error so is to try to count by sine itself.

If there is a circle, you can count to radian as it is equal to itself at turn --> 2pi rad.

https://math.stackexchange.com/questions/1339540/why-does-the-derivative-of-sine-only-work-for-radians

it's about arithmetics itself

https://en.wikipedia.org/wiki/Arithmetic_derivative

With radian we do not need to use extendend rules of arithmetics. We can just use the multiplicative function and not the totally one. The multiplicative function extended we invented for the hypersymetrical decimal number system.

https://en.wikipedia.org/wiki/Multiplicative_function

it's all about primes numbers my friend.

Ferromagnetic answered 6/6, 2022 at 20:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.