Trigonometric functions: Difference between revisions
Content added Content deleted
m (→{{header|Ruby}}: Kill a phantom category.) |
(Add Seed7 example) |
||
Line 1,759: | Line 1,759: | ||
(display (* arctan (/ 180 pi))) |
(display (* arctan (/ 180 pi))) |
||
(newline)</lang> |
(newline)</lang> |
||
=={{header|Seed7}}== |
|||
The example below uses the libaray [http://seed7.sourceforge.net/libraries/math.htm math.s7i], |
|||
which defines, besides many other functions, |
|||
[http://seed7.sourceforge.net/libraries/math.htm#sin%28ref_float%29 sin], |
|||
[http://seed7.sourceforge.net/libraries/math.htm#cos%28ref_float%29 cos], |
|||
[http://seed7.sourceforge.net/libraries/math.htm#tan%28ref_float%29 tan], |
|||
[http://seed7.sourceforge.net/libraries/math.htm#asin%28ref_float%29 asin], |
|||
[http://seed7.sourceforge.net/libraries/math.htm#acos%28ref_float%29 acos] and |
|||
[http://seed7.sourceforge.net/libraries/math.htm#atan%28ref_float%29 atan]. |
|||
<lang seed7>$ include "seed7_05.s7i"; |
|||
include "float.s7i"; |
|||
include "math.s7i"; |
|||
const proc: main is func |
|||
local |
|||
const float: radians is PI / 4.0; |
|||
const float: degrees is 45.0; |
|||
begin |
|||
writeln(" radians degrees"); |
|||
writeln("sine: " <& sin(radians) digits 5 <& sin(degrees * PI / 180.0) digits 5 lpad 9); |
|||
writeln("cosine: " <& cos(radians) digits 5 <& cos(degrees * PI / 180.0) digits 5 lpad 9); |
|||
writeln("tangent: " <& tan(radians) digits 5 <& tan(degrees * PI / 180.0) digits 5 lpad 9); |
|||
writeln("arcsine: " <& asin(0.70710677) digits 5 <& asin(0.70710677) * 180.0 / PI digits 5 lpad 9); |
|||
writeln("arccosine: " <& acos(0.70710677) digits 5 <& acos(0.70710677) * 180.0 / PI digits 5 lpad 9); |
|||
writeln("arctangent: " <& atan(1.0) digits 5 <& atan(1.0) * 180.0 / PI digits 5 lpad 9); |
|||
end func;</lang> |
|||
Output: |
|||
<pre> |
|||
radians degrees |
|||
sine: 0.70711 0.70711 |
|||
cosine: 0.70711 0.70711 |
|||
tangent: 1.00000 1.00000 |
|||
arcsine: 0.78540 45.00000 |
|||
arccosine: 0.78540 45.00000 |
|||
arctangent: 0.78540 45.00000 |
|||
</pre> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |