Trigonometric functions: Difference between revisions
Content deleted Content added
-> IDL |
|||
Line 163: | Line 163: | ||
acos 0.5, toDegrees (acos 0.5), |
acos 0.5, toDegrees (acos 0.5), |
||
atan 0.5, toDegrees (atan 0.5)] |
atan 0.5, toDegrees (atan 0.5)] |
||
=={{header|IDL}}== |
|||
<pre> |
|||
deg = 35 ; arbitrary number of degrees |
|||
rad = !dtor*deg ; system variables !dtor and !radeg convert between rad and deg |
|||
</pre><pre> |
|||
; the trig functions receive and emit radians: |
|||
print, rad, sin(rad), asin(sin(rad)) |
|||
print, cos(rad), acos(cos(rad)) |
|||
print, tan(rad), atan(tan(rad)) ; etc |
|||
; prints the following: |
|||
; 0.610865 0.573576 0.610865 |
|||
; 0.819152 0.610865 |
|||
; 0.700208 0.610865 |
|||
</pre><pre> |
|||
; the hyperbolic versions exist and behave as expected: |
|||
print, sinh(rad) ; etc |
|||
; outputs |
|||
; 0.649572 |
|||
</pre><pre> |
|||
;If the input is an array, the output has the same dimensions etc as the input: |
|||
x = !dpi/[[2,3],[4,5],[6,7]] ; !dpi is a read-only sysvar = 3.1415... |
|||
print,sin(x) |
|||
;outputs: |
|||
; 1.0000000 0.86602540 |
|||
; 0.70710678 0.58778525 |
|||
; 0.50000000 0.43388374 |
|||
</pre><pre> |
|||
; the trig functions behave as expected for complex arguments: |
|||
x = complex(1,2) |
|||
print,sin(x) |
|||
; outputs |
|||
; ( 3.16578, 1.95960) |
|||
</pre> |
|||
=={{header|J}}== |
=={{header|J}}== |