Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
35
Task/Trigonometric-functions/Ada/trigonometric-functions.adb
Normal file
35
Task/Trigonometric-functions/Ada/trigonometric-functions.adb
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
with Ada.Numerics.Elementary_Functions;
|
||||
use Ada.Numerics.Elementary_Functions;
|
||||
with Ada.Float_Text_Io; use Ada.Float_Text_Io;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Trig is
|
||||
Degrees_Cycle : constant Float := 360.0;
|
||||
Radians_Cycle : constant Float := 2.0 * Ada.Numerics.Pi;
|
||||
Angle_Degrees : constant Float := 45.0;
|
||||
Angle_Radians : constant Float := Ada.Numerics.Pi / 4.0;
|
||||
procedure Put (V1, V2 : Float) is
|
||||
begin
|
||||
Put (V1, Aft => 5, Exp => 0);
|
||||
Put (" ");
|
||||
Put (V2, Aft => 5, Exp => 0);
|
||||
New_Line;
|
||||
end Put;
|
||||
begin
|
||||
Put (Sin (Angle_Degrees, Degrees_Cycle),
|
||||
Sin (Angle_Radians, Radians_Cycle));
|
||||
Put (Cos (Angle_Degrees, Degrees_Cycle),
|
||||
Cos (Angle_Radians, Radians_Cycle));
|
||||
Put (Tan (Angle_Degrees, Degrees_Cycle),
|
||||
Tan (Angle_Radians, Radians_Cycle));
|
||||
Put (Cot (Angle_Degrees, Degrees_Cycle),
|
||||
Cot (Angle_Radians, Radians_Cycle));
|
||||
Put (ArcSin (Sin (Angle_Degrees, Degrees_Cycle), Degrees_Cycle),
|
||||
ArcSin (Sin (Angle_Radians, Radians_Cycle), Radians_Cycle));
|
||||
Put (Arccos (Cos (Angle_Degrees, Degrees_Cycle), Degrees_Cycle),
|
||||
Arccos (Cos (Angle_Radians, Radians_Cycle), Radians_Cycle));
|
||||
Put (Arctan (Y => Tan (Angle_Degrees, Degrees_Cycle)),
|
||||
Arctan (Y => Tan (Angle_Radians, Radians_Cycle)));
|
||||
Put (Arccot (X => Cot (Angle_Degrees, Degrees_Cycle)),
|
||||
Arccot (X => Cot (Angle_Degrees, Degrees_Cycle)));
|
||||
end Trig;
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
(defun rad_to_deg (rad)(* 180.0 (/ rad PI)))
|
||||
(defun deg_to_rad (deg)(* PI (/ deg 180.0)))
|
||||
|
||||
(defun asin (x)
|
||||
(cond
|
||||
((and(> x -1.0)(< x 1.0)) (atan (/ x (sqrt (- 1.0 (* x x))))))
|
||||
((= x -1.0) (* -1.0 (/ pi 2)))
|
||||
((= x 1) (/ pi 2))
|
||||
)
|
||||
)
|
||||
|
||||
(defun acos (x)
|
||||
(cond
|
||||
((and(>= x -1.0)(<= x 1.0)) (-(* pi 0.5) (asin x)))
|
||||
)
|
||||
)
|
||||
|
||||
(list
|
||||
(list "cos PI/6" (cos (/ pi 6)) "cos 30 deg" (cos (deg_to_rad 30)))
|
||||
(list "sin PI/4" (sin (/ pi 4)) "sin 45 deg" (sin (deg_to_rad 45)))
|
||||
(list "tan PI/3" (tan (/ pi 3))"tan 60 deg" (tan (deg_to_rad 60)))
|
||||
(list "asin 1 rad" (asin 1.0) "asin 1 rad (deg)" (rad_to_deg (asin 1.0)))
|
||||
(list "acos 1/2 rad" (acos (/ 1 2.0)) "acos 1/2 rad (deg)" (rad_to_deg (acos (/ 1 2.0))))
|
||||
(list "atan pi/12" (atan (/ pi 12)) "atan 15 deg" (rad_to_deg(atan(deg_to_rad 15))))
|
||||
)
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. Trig.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 Pi-Third USAGE COMP-2.
|
||||
01 Degree USAGE COMP-2.
|
||||
|
||||
01 60-Degrees USAGE COMP-2.
|
||||
|
||||
01 Result USAGE COMP-2.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
COMPUTE Pi-Third = FUNCTION PI / 3
|
||||
|
||||
DISPLAY "Radians:"
|
||||
DISPLAY " Sin(π / 3) = " FUNCTION SIN(Pi-Third)
|
||||
DISPLAY " Cos(π / 3) = " FUNCTION COS(Pi-Third)
|
||||
DISPLAY " Tan(π / 3) = " FUNCTION TAN(Pi-Third)
|
||||
DISPLAY " Asin(0.5) = " FUNCTION ASIN(0.5)
|
||||
DISPLAY " Acos(0.5) = " FUNCTION ACOS(0.5)
|
||||
DISPLAY " Atan(0.5) = " FUNCTION ATAN(0.5)
|
||||
|
||||
COMPUTE Degree = FUNCTION PI / 180
|
||||
COMPUTE 60-Degrees = Degree * 60
|
||||
|
||||
DISPLAY "Degrees:"
|
||||
DISPLAY " Sin(60°) = " FUNCTION SIN(60-Degrees)
|
||||
DISPLAY " Cos(60°) = " FUNCTION COS(60-Degrees)
|
||||
DISPLAY " Tan(60°) = " FUNCTION TAN(60-Degrees)
|
||||
COMPUTE Result = FUNCTION ASIN(0.5) / 60
|
||||
DISPLAY " Asin(0.5) = " Result
|
||||
COMPUTE Result = FUNCTION ACOS(0.5) / 60
|
||||
DISPLAY " Acos(0.5) = " Result
|
||||
COMPUTE Result = FUNCTION ATAN(0.5) / 60
|
||||
DISPLAY " Atan(0.5) = " Result
|
||||
|
||||
GOBACK
|
||||
.
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
local fmt = require "fmt"
|
||||
|
||||
local d = 30
|
||||
local r = d * math.pi / 180
|
||||
local s = 0.5
|
||||
local c = math.sqrt(3) / 2
|
||||
local t = 1 / math.sqrt(3)
|
||||
|
||||
fmt.print("sin(%9.6f deg) = %f", d, math.sin(d * math.pi / 180))
|
||||
fmt.print("sin(%9.6f rad) = %f", r, math.sin(r))
|
||||
fmt.print("cos(%9.6f deg) = %f", d, math.cos(d * math.pi / 180))
|
||||
fmt.print("cos(%9.6f rad) = %f", r, math.cos(r))
|
||||
fmt.print("tan(%9.6f deg) = %f", d, math.tan(d * math.pi / 180))
|
||||
fmt.print("tan(%9.6f rad) = %f", r, math.tan(r))
|
||||
fmt.print("asin(%f) = %9.6f deg", s, math.asin(s) * 180 / math.pi)
|
||||
fmt.print("asin(%f) = %9.6f rad", s, math.asin(s))
|
||||
fmt.print("acos(%f) = %9.6f deg", c, math.acos(c) * 180 / math.pi)
|
||||
fmt.print("acos(%f) = %9.6f rad", c, math.acos(c))
|
||||
fmt.print("atan(%f) = %9.6f deg", t, math.atan(t) * 180 / math.pi)
|
||||
fmt.print("atan(%f) = %9.6f rad", t, math.atan(t))
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
$rad = [Math]::PI / 4
|
||||
$deg = 45
|
||||
'{0,10} {1,10}' -f 'Radians','Degrees'
|
||||
'{0,10:N6} {1,10:N6}' -f [Math]::Sin($rad), [Math]::Sin($deg * [Math]::PI / 180)
|
||||
'{0,10:N6} {1,10:N6}' -f [Math]::Cos($rad), [Math]::Cos($deg * [Math]::PI / 180)
|
||||
'{0,10:N6} {1,10:N6}' -f [Math]::Tan($rad), [Math]::Tan($deg * [Math]::PI / 180)
|
||||
$temp = [Math]::Asin([Math]::Sin($rad))
|
||||
'{0,10:N6} {1,10:N6}' -f $temp, ($temp * 180 / [Math]::PI)
|
||||
$temp = [Math]::Acos([Math]::Cos($rad))
|
||||
'{0,10:N6} {1,10:N6}' -f $temp, ($temp * 180 / [Math]::PI)
|
||||
$temp = [Math]::Atan([Math]::Tan($rad))
|
||||
'{0,10:N6} {1,10:N6}' -f $temp, ($temp * 180 / [Math]::PI)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
$radians = [Math]::PI / 4
|
||||
$degrees = 45
|
||||
|
||||
[PSCustomObject]@{Radians=[Math]::Sin($radians); Degrees=[Math]::Sin($degrees * [Math]::PI / 180)}
|
||||
[PSCustomObject]@{Radians=[Math]::Cos($radians); Degrees=[Math]::Cos($degrees * [Math]::PI / 180)}
|
||||
[PSCustomObject]@{Radians=[Math]::Tan($radians); Degrees=[Math]::Tan($degrees * [Math]::PI / 180)}
|
||||
|
||||
[double]$tempVar = [Math]::Asin([Math]::Sin($radians))
|
||||
[PSCustomObject]@{Radians=$tempVar; Degrees=$tempVar * 180 / [Math]::PI}
|
||||
|
||||
[double]$tempVar = [Math]::Acos([Math]::Cos($radians))
|
||||
[PSCustomObject]@{Radians=$tempVar; Degrees=$tempVar * 180 / [Math]::PI}
|
||||
|
||||
[double]$tempVar = [Math]::Atan([Math]::Tan($radians))
|
||||
[PSCustomObject]@{Radians=$tempVar; Degrees=$tempVar * 180 / [Math]::PI}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
Rebol [
|
||||
Title: "Trigonometric Functions"
|
||||
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]
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
radians: pi / 4
|
||||
print ["asin sin:" asin sin :radians]
|
||||
print ["acos cos:" acos cos :radians]
|
||||
print ["atan tan:" atan tan :radians]
|
||||
Loading…
Add table
Add a link
Reference in a new issue