Trigonometric functions: Difference between revisions

Content added Content deleted
m (Fixed lang tags.)
(→‎{{header|R}}: Added REBOL example.)
Line 792: Line 792:
print( c( acos(C), acosd(C) ) )
print( c( acos(C), acosd(C) ) )
print( c( atan(T), atand(T) ) )</lang>
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}}==
=={{header|Ruby}}==