Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Radians Or Degrees?

462 views
Skip to first unread message

Lawrence D'Oliveiro

unread,
Feb 21, 2024, 5:35:50 PMFeb 21
to
What units should be used for angles in trig functions?

Radians are the most natural unit for most trig calculations, and that’s
what the library routines in C and many other languages use. However,
degrees are a more natural unit for humans to input, and to get results
in.

Thus, other languages, but not (yet?) C, provide conversion functions. For
example, Python has math.radians() for converting degrees to radians, and
math.degrees() for going the other way. Java has something similar.

But I think providing conversion functions is an unnecessarily clumsy way
of doing it, because for every alternative angle unit, you need two
functions.

Better to provide just a single conversion factor. E.g.

DEG = π / 180

Now it is easy enough to input angles to a calculation in degrees, e.g.

sin(45 * DEG)

And getting outputs in degrees is equally easy, e.g.

atan2(Y, X) / DEG

Sometimes it is convenient to work in terms of whole circles (360°):

CIRCLE = 2 * π

Thus the examples become:

sin(CIRCLE / 8)

and

atan2(Y, X) / CIRCLE

Anybody remember “gradians”?

GRAD = π / 200

And of course, for completeness, we can have a factor for explicitly
specifying that you are working radians:

RAD = 1.0

James Kuyper

unread,
Feb 21, 2024, 5:55:17 PMFeb 21
to
On 2/21/24 17:35, Lawrence D'Oliveiro wrote:
> What units should be used for angles in trig functions?

The standard specifies that sin, cos, and tan() take arguments measured
in radians. Degrees are mentioned only in the context of the complex
versions of the trig functions, and only for the purpose of mentioning
that they do NOT take arguments in degrees.

fir

unread,
Feb 21, 2024, 6:15:23 PMFeb 21
to
long time i think it should be measured in what you call here circle,
it is rather in "1" not in "360" nor "2PI" ..in my coding hovevver i use
degree360 = 2*PI/360.0

this what you call circle imo wpuld be better and i doubt in a reason to
use PI in mathematics yet defien it as 3.14 instead of 6.28 here if this
value is really needed

also on assembly level i would like if fsin arguments woyld be not on
radians but in "1.0" floats

if someone knows the reason why "6.28" radians are expected to better
than "1.0" 'circkles' in both mathemathics and assembly tell me
- as i dont know the reason

Michael S

unread,
Feb 21, 2024, 6:59:37 PMFeb 21
to
The latest version of IEEE-754 Standard (or, may be, the one that is
still in preparation? I don't remember), specifiies additional set of
trig routines for which argument=1.0 corresponds to 180 degrees (pi
Radians). The names are SinPi, CosPi etc...
I find this choice somewhat less logical than 1.0 corresponding to 360
degrees, but that's a matter of personal taste.

Lawrence D'Oliveiro

unread,
Feb 21, 2024, 8:55:29 PMFeb 21
to
On Thu, 22 Feb 2024 00:15:47 +0100, fir wrote:

> if someone knows the reason why "6.28" radians are expected to better
> than "1.0" 'circkles' in both mathemathics and assembly tell me - as i
> dont know the reason

It’s because trig calculations are most naturally done in radians. E.g.
the approximation

sin x ≅ tan x ≅ x as x → 0

works only if x is in radians. Also the Euler identity

ix
e = cos x + i sin x

only holds if x is in radians. And so on and so on.

Lawrence D'Oliveiro

unread,
Feb 21, 2024, 8:56:08 PMFeb 21
to
On Thu, 22 Feb 2024 01:59:20 +0200, Michael S wrote:

> The latest version of IEEE-754 Standard (or, may be, the one that is
> still in preparation? I don't remember), specifiies additional set of
> trig routines for which argument=1.0 corresponds to 180 degrees (pi
> Radians). The names are SinPi, CosPi etc...
> I find this choice somewhat less logical than 1.0 corresponding to 360
> degrees, but that's a matter of personal taste.

Also quite unnecessary to invent a whole set of parallel functions just
for a different angle unit.

Malcolm McLean

unread,
Feb 22, 2024, 2:17:39 AMFeb 22
to
On 21/02/2024 22:35, Lawrence D'Oliveiro wrote:
> What units should be used for angles in trig functions?
>
The derivative of the sine is the cosine and vice versa, but only if you
measure in radians. And for some mathematical calculations this is an
important property, and so you really must use radians. And so if we
wish to support that type of mathematics with C, we must provide
functions which take radians.


--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

David Brown

unread,
Feb 22, 2024, 3:07:08 AMFeb 22
to
This all sounds reasonable to me. I would not bother with GRAD unless
you are writing code for the French military - despite being common on
calculators for a while, it's extremely rare to see it in use.

If you want a third unit, I'd pick the "Furman", scale factor 2π / 2^16.
It's the kind of thing you see in embedded systems where you want to
do your trig with fixed point numbers, integers, table lookups, splines,
etc., rather than floating point and slow, unnecessarily accurate
library functions. But it's not so common to see the name, and the
power of two is not always 16.

Maybe just TURN = 2π would be more useful?



Message has been deleted

David Brown

unread,
Feb 22, 2024, 3:32:56 AMFeb 22
to
From a mathematical standpoint, clearly radians are a far more natural
choice of unit than anything else for trig. But it is not as certain
that they are a good choice for programming.

For implementing "sin", you first have to reduce the value modulo 2π. I
would have thought it would easier to do that if the units were turns,
as the modulo reduction would then simply be taking the fractional part
of the number. You may also want to reduce to a 0°-90°, or 0-π/2 range
for the main calculation.

If you are doing with main calculation by Taylor series, radians are the
nicest units. But I believe it is more common to use Chebyshev
polynomials, and for that there is no great advantage in radians. It's
a very long time since I looked at Chebyshevs, but I think your most
efficient method would be to map 0°-90° to the range -1 to 1 - i.e.,
centred around 45°. This brings you to an ideal unit of an eighth of a
turn.

Turns divided by some power of two would also be ideal for faster but
less accurate implementations, such as Cordic or tables with linear or
cubic interpolation.

From the user viewpoint, radians are a natural unit for a lot of
applications - as are degrees. Turns, or turns divided by a power of
two, are also very useful for many applications, but there is no
consensus about what power of two to use.

And the user viewpoint is the important one here - the value can be
scaled before doing the calculations.

So choice number one for programming languages should be radians, except
perhaps for languages aimed at beginners or kids, where degrees might be
more appropriate. And if you have a second set, degrees would be the
choice, then followed by turns. (Half turns - SinPi and CosPi - seems
odd to me.)


Malcolm McLean

unread,
Feb 22, 2024, 4:39:08 AMFeb 22
to
On 22/02/2024 08:32, David Brown wrote:
>
> For implementing "sin", you first have to reduce the value modulo 2π.

For an efficient implentation yes. But applying the formula to values
outside the range of 0 - 2PI also produces the correct result if you go
on for long enough.

David Brown

unread,
Feb 22, 2024, 5:04:43 AMFeb 22
to
On 22/02/2024 10:38, Malcolm McLean wrote:
> On 22/02/2024 08:32, David Brown wrote:
>>
>> For implementing "sin", you first have to reduce the value modulo 2π.
>
> For an efficient implentation yes. But applying the formula to values
> outside the range of 0 - 2PI also produces the correct result if you go
> on for long enough.
>

Assuming that "the formula" you are referring to is one of the infinite
polynomials for sin, then yes - I think anyone who knows about such
maths will be aware of that. However, it is pretty much entirely
irrelevant in the context of computing values for trig functions.

David Brown

unread,
Feb 22, 2024, 5:10:05 AMFeb 22
to
On 22/02/2024 09:27, Blue-Maned_Hawk wrote:
>
> Radians is the only angle unit which is not arbitrary.
>
>

No, it is not. "Turns" are also not arbitrary, and are also
mathematically fundamental.

And while degrees were created by people, rather than something
fundamental in the mathematics, the number of divisions was picked
carefully for particular properties (lots of divisors). And since
degrees are a well-established and commonly known angle unit, using them
is not arbitrary. Even gradians were defined that way for good reasons.
So these units are not arbitrary - even though they were defined by
humans and not mathematics.

Malcolm McLean

unread,
Feb 22, 2024, 8:48:23 AMFeb 22
to
We did have a lengthy and of course totally off topic discussion about
this over in comp.theory. I said that the Babylonians thought that
having 360 degrees was an inherent property of a circle, whilst others
said not.

Ben Bacarisse

unread,
Feb 22, 2024, 9:29:00 AMFeb 22
to
Lawrence D'Oliveiro <l...@nz.invalid> writes:

> On Thu, 22 Feb 2024 00:15:47 +0100, fir wrote:
>
>> if someone knows the reason why "6.28" radians are expected to better
>> than "1.0" 'circkles' in both mathemathics and assembly tell me - as i
>> dont know the reason
>
> It’s because trig calculations are most naturally done in radians. E.g.
> the approximation
>
> sin x ≅ tan x ≅ x as x → 0
>
> works only if x is in radians.

No, that applies to lots of angle measures. Radians are the natural
angle measure because we want sin' x = cos x and cos' x = -sin x. sin
and cos are the unique solution to that pair of differential equations
(with initial conditions sin 0 = 0 and cos 0 = 1).

> Also the Euler identity
>
> ix
> e = cos x + i sin x
>
> only holds if x is in radians. And so on and so on.

Yes, and there's another nod to the calculus here because just as sin an
cos are (with a minus sign) derivatives of each other, e^x is the
derivative of itself.

--
Ben.
0 new messages