On this page:
Degrees and Radians, Operators DEG and RAD.
Angles can be measured in degrees (a full circle is 360 degrees) or in radians (a full circle is pi times 2, or tau).
Hypatia can use both, but you have to be careful to avoid errors.
By default, Hypatia uses radians. Let's look at the arcsine of 1:
? 1 ASIN
= 1.5707963267949
The commands USE DEG and USE RAD switch the angle mode between degrees and radians:
? USE DEG
Angle mode set to degrees
? 1 ASIN
= 90
Note that to Hypatia the result is just a number, it does not have "degrees" or "radians" attached to it.
If you change the angle mode after a calculation, the result does not change.
This is true for all trigonometric calculations -- you need to decide if you want angles measured in degrees or radians, and have to make sure the angle mode is set correctly before the calculation.
If you want degrees mode to be default, you have to add the line USE DEG to the file hy.ini.
The command USE displays the currently set angle mode.
When you save variables to a file, the line USE DEG will be included in the file if angle mode is set to degrees.
When you retrieve variables from this file, angle mode will be set to degrees!
Do not confuse the DEG and RAD operators with the USE DEG and USE RAD commands!
Independent of the current angle mode, DEG converts radians to degrees, and RAD converts degrees to radians.
For instance, if you want the sine of 30 degrees (which is 0.5) -- as always, ? is the input prompt, you do not type it:
? 30 SIN
= -0.988031624092862
This looks very wrong -- let's check which angle mode we are using:
? USE
Angle mode set to radians
This explains the wrong result. We could change to degrees mode, but instead we could also convert 30 to radians before calculating the sine:
? 30 RAD SIN
= 0.5
It works similarily in the opposite direction:
? 0.5 ASIN
= 0.523598775598299
This is the result in radians, but we can convert it to degrees:
? DEG
= 30
Or we could have entered 0.5 ASIN DEG, or we could have switched to degrees mode before entering 0.5 ASIN, or, of course, the result in radians may be what you want.
Home, Up: Numbers, Prev: Output Format, Next: The Zero Threshold