Trigonometric functions: Difference between revisions
Content added Content deleted
m (→{{header|IDL}}: IDL has highlighting) |
m (Using lang tags now.) |
||
Line 59: | Line 59: | ||
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}} |
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}} |
||
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}} |
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}} |
||
<lang algol> |
|||
<pre> |
|||
main:( |
main:( |
||
REAL pi = 4 * arc tan(1); |
REAL pi = 4 * arc tan(1); |
||
Line 82: | Line 82: | ||
print((temp, " ", temp * 180 / pi, new line)) |
print((temp, " ", temp * 180 / pi, new line)) |
||
) |
) |
||
</ |
</lang> |
||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 185: | Line 185: | ||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
<lang forth> 45e pi f* 180e f/ \ radians |
|||
cr fdup fsin f. \ also available: fsincos ( r -- sin cos ) |
cr fdup fsin f. \ also available: fsincos ( r -- sin cos ) |
||
Line 192: | Line 192: | ||
cr fdup fasin f. |
cr fdup fasin f. |
||
cr fdup facos f. |
cr fdup facos f. |
||
cr fatan f. \ also available: fatan2 ( r1 r2 -- atan[r1/r2] ) |
cr fatan f. \ also available: fatan2 ( r1 r2 -- atan[r1/r2] )</lang> |
||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
Line 224: | Line 224: | ||
0.785398 45.0000 |
0.785398 45.0000 |
||
The following trigonometric functions are also available |
The following trigonometric functions are also available |
||
<lang fortran> ATAN2(y,x) ! Arctangent(y/x), ''-pi < result <= +pi'' |
|||
SINH(x) ! Hyperbolic sine |
SINH(x) ! Hyperbolic sine |
||
COSH(x) ! Hyperbolic cosine |
COSH(x) ! Hyperbolic cosine |
||
TANH(x) ! Hyperbolic tangent |
TANH(x) ! Hyperbolic tangent</lang> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
Line 284: | Line 284: | ||
Sine, cosine, and tangent of a single angle, indicated as pi-over-four radians and as 45 degrees: |
Sine, cosine, and tangent of a single angle, indicated as pi-over-four radians and as 45 degrees: |
||
>,:(1&o. ; 2&o. ; 3&o.) (4%~o. 1), 180%~o. 45 |
<lang j> >,:(1&o. ; 2&o. ; 3&o.) (4%~o. 1), 180%~o. 45</lang> |
||
0.707107 0.707107 |
0.707107 0.707107 |
||
0.707107 0.707107 |
0.707107 0.707107 |
||
1 1 |
1 1 |
||
Arcsine, arccosine, and arctangent of one-half, in radians and degrees: |
Arcsine, arccosine, and arctangent of one-half, in radians and degrees: |
||
>,:([ , 180p_1&*)&.> (_1&o. ; _2&o. ; _3&o.) 0.5 |
<lang j> >,:([ , 180p_1&*)&.> (_1&o. ; _2&o. ; _3&o.) 0.5</lang> |
||
0.523599 30 |
0.523599 30 |
||
1.0472 60 |
1.0472 60 |
||
Line 360: | Line 360: | ||
=={{header|Logo}}== |
=={{header|Logo}}== |
||
[[UCB Logo]] has sine, cosine, and arctangent; each having variants for degrees or radians. |
[[UCB Logo]] has sine, cosine, and arctangent; each having variants for degrees or radians. |
||
<lang logo> print sin 45 |
|||
print cos 45 |
print cos 45 |
||
print arctan 1 |
print arctan 1 |
||
Line 366: | Line 366: | ||
print radsin :pi / 4 |
print radsin :pi / 4 |
||
print radcos :pi / 4 |
print radcos :pi / 4 |
||
print 4 * radarctan 1 |
print 4 * radarctan 1</lang> |
||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
Line 437: | Line 437: | ||
flag to 'true' arguments are in radians. |
flag to 'true' arguments are in radians. |
||
<lang pop11> |
|||
<pre> |
|||
sin(30) => |
sin(30) => |
||
cos(45) => |
cos(45) => |
||
Line 453: | Line 453: | ||
arccos(0.7) => |
arccos(0.7) => |
||
arctan(0.7) => |
arctan(0.7) => |
||
</ |
</lang> |
||
=={{header|Python}}== |
=={{header|Python}}== |