Trigonometric functions: Difference between revisions
Content added Content deleted
m (markup typo) |
(+Icon+Unicon) |
||
Line 503: | Line 503: | ||
; outputs |
; outputs |
||
; ( 3.16578, 1.95960)</lang> |
; ( 3.16578, 1.95960)</lang> |
||
== Icon and Unicon == |
|||
Icon and Unicon trig functions 'sin', 'cos', 'tan', 'asin', 'acos', and 'atan' operate on angles expressed in radians. Conversion functions 'dtor' and 'rtod' convert between the two systems. The example below uses string invocation to construct and call the functions: |
|||
==={{header|Icon}}=== |
|||
<lang Icon>invocable all |
|||
procedure main() |
|||
d := 30 # degrees |
|||
r := dtor(d) # convert to radians |
|||
every write(f := !["sin","cos","tan"],"(",r,")=",y := f(r)," ",fi := "a" || f,"(",y,")=",x := fi(y)," rad = ",rtod(x)," deg") |
|||
end</lang> |
|||
Sample Output:<pre>sin(0.5235987755982988)=0.4999999999999999 asin(0.4999999999999999)=0.5235987755982988 rad = 30.0 deg |
|||
cos(0.5235987755982988)=0.8660254037844387 acos(0.8660254037844387)=0.5235987755982987 rad = 29.99999999999999 deg |
|||
tan(0.5235987755982988)=0.5773502691896257 atan(0.5773502691896257)=0.5235987755982988 rad = 30.0 deg</pre> |
|||
==={{header|Unicon}}=== |
|||
The Icon solution works in Unicon. |
|||
=={{header|J}}== |
=={{header|J}}== |