Jump to content

Trigonometric functions: Difference between revisions

→‎{{header|R}}: Added REBOL example.
m (Fixed lang tags.)
(→‎{{header|R}}: Added REBOL example.)
Line 792:
print( c( acos(C), acosd(C) ) )
print( c( atan(T), atand(T) ) )</lang>
 
=={{header|REBOL}}==
<lang REBOL>REBOL [
Title: "Trigonometric Functions"
Author: oofoe
Date: 2009-12-07
URL: http://rosettacode.org/wiki/Trigonometric_Functions
]
 
radians: pi / 4 degrees: 45.0
 
; Unlike most languages, REBOL's trig functions work in degrees unless
; you specify differently.
 
print [sine/radians radians sine degrees]
print [cosine/radians radians cosine degrees]
print [tangent/radians radians tangent degrees]
 
d2r: func [
"Convert degrees to radians."
d [number!] "Degrees"
][d * pi / 180]
 
arcsin: arcsine sine degrees
print [d2r arcsin arcsin]
 
arccos: arccosine cosine degrees
print [d2r arccos arccos]
 
arctan: arctangent tangent degrees
print [d2r arctan arctan]</lang>
 
Output:
 
<pre>0.707106781186547 0.707106781186547
0.707106781186548 0.707106781186548
1.0 1.0
0.785398163397448 45.0
0.785398163397448 45.0
0.785398163397448 45.0</pre>
 
=={{header|Ruby}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.