September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,16 @@
|
|||
' Trigonometric functions in BaCon use Radians for input values
|
||||
' The RAD() function converts from degrees to radians
|
||||
|
||||
FOR v$ IN "0, 10, 45, 90, 190.5"
|
||||
d = VAL(v$) * 1.0
|
||||
r = RAD(d) * 1.0
|
||||
|
||||
PRINT "Sine: ", d, " degrees (or ", r, " radians) is ", SIN(r)
|
||||
PRINT "Cosine: ", d, " degrees (or ", r, " radians) is ", COS(r)
|
||||
PRINT "Tangent: ", d, " degrees (or ", r, " radians) is ", TAN(r)
|
||||
PRINT
|
||||
PRINT "Arc Sine: ", SIN(r), " is ", DEG(ASIN(SIN(r))), " degrees (or ", ASIN(SIN(r)), " radians)"
|
||||
PRINT "Arc CoSine: ", COS(r), " is ", DEG(ACOS(COS(r))), " degrees (or ", ACOS(COS(r)), " radians)"
|
||||
PRINT "Arc Tangent: ", TAN(r), " is ", DEG(ATN(TAN(r))), " degrees (or ", ATN(TAN(r)), " radians)"
|
||||
PRINT
|
||||
NEXT
|
||||
55
Task/Trigonometric-functions/Bc/trigonometric-functions.bc
Normal file
55
Task/Trigonometric-functions/Bc/trigonometric-functions.bc
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* t(x) = tangent of x */
|
||||
define t(x) {
|
||||
return s(x) / c(x)
|
||||
}
|
||||
|
||||
/* y(y) = arcsine of y, domain [-1, 1], range [-pi/2, pi/2] */
|
||||
define y(y) {
|
||||
/* Handle angles with no tangent. */
|
||||
if (y == -1) return -2 * a(1) /* -pi/2 */
|
||||
if (y == 1) return 2 * a(1) /* pi/2 */
|
||||
|
||||
/* Tangent of angle is y / x, where x^2 + y^2 = 1. */
|
||||
return a(y / sqrt(1 - y * y))
|
||||
}
|
||||
|
||||
/* x(x) = arccosine of x, domain [-1, 1], range [0, pi] */
|
||||
define x(x) {
|
||||
auto a
|
||||
|
||||
/* Handle angle with no tangent. */
|
||||
if (x == 0) return 2 * a(1) /* pi/2 */
|
||||
|
||||
/* Tangent of angle is y / x, where x^2 + y^2 = 1. */
|
||||
a = a(sqrt(1 - x * x) / x)
|
||||
if (a < 0) {
|
||||
return a + 4 * a(1) /* add pi */
|
||||
} else {
|
||||
return a
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
scale = 50
|
||||
p = 4 * a(1) /* pi */
|
||||
d = p / 180 /* one degree in radians */
|
||||
|
||||
"Using radians:
|
||||
"
|
||||
" sin(-pi / 6) = "; s(-p / 6)
|
||||
" cos(3 * pi / 4) = "; c(3 * p / 4)
|
||||
" tan(pi / 3) = "; t(p / 3)
|
||||
" asin(-1 / 2) = "; y(-1 / 2)
|
||||
" acos(-sqrt(2) / 2) = "; x(-sqrt(2) / 2)
|
||||
" atan(sqrt(3)) = "; a(sqrt(3))
|
||||
|
||||
"Using degrees:
|
||||
"
|
||||
" sin(-30) = "; s(-30 * d)
|
||||
" cos(135) = "; c(135 * d)
|
||||
" tan(60) = "; t(60 * d)
|
||||
" asin(-1 / 2) = "; y(-1 / 2) / d
|
||||
" acos(-sqrt(2) / 2) = "; x(-sqrt(2) / 2) / d
|
||||
" atan(sqrt(3)) = "; a(sqrt(3)) / d
|
||||
|
||||
quit
|
||||
|
|
@ -1,23 +1,24 @@
|
|||
#import system.
|
||||
#import system'math.
|
||||
#import extensions.
|
||||
import system'math.
|
||||
import extensions.
|
||||
|
||||
#symbol program =
|
||||
program =
|
||||
[
|
||||
console writeLine:"Radians:".
|
||||
console writeLine:"sin(π/3) = ":((pi_value/3) sin).
|
||||
console writeLine:"cos(π/3) = ":((pi_value/3) cos).
|
||||
console writeLine:"tan(π/3) = ":((pi_value/3) tan).
|
||||
console writeLine:"arcsin(1/2) = ":(0.5r arcsin).
|
||||
console writeLine:"arccos(1/2) = ":(0.5r arccos).
|
||||
console writeLine:"arctan(1/2) = ":(0.5r arctan).
|
||||
console writeLine.
|
||||
console printLine("Radians:").
|
||||
console printLine("sin(π/3) = ",(pi_value/3) sin).
|
||||
console printLine("cos(π/3) = ",(pi_value/3) cos).
|
||||
console printLine("tan(π/3) = ",(pi_value/3) tan).
|
||||
console printLine("arcsin(1/2) = ",0.5r arcsin).
|
||||
console printLine("arccos(1/2) = ",0.5r arccos).
|
||||
console printLine("arctan(1/2) = ",0.5r arctan).
|
||||
console printLine.
|
||||
|
||||
console writeLine:"Degrees:".
|
||||
console writeLine:"sin(60º) = ":(60.0r radian sin).
|
||||
console writeLine:"cos(60º) = ":(60.0r radian cos).
|
||||
console writeLine:"tan(60º) = ":(60.0r radian tan).
|
||||
console writeLine:"arcsin(1/2) = ":(0.5r arcsin degree):"º".
|
||||
console writeLine:"arccos(1/2) = ":(0.5r arccos degree):"º".
|
||||
console writeLine:"arctan(1/2) = ":(0.5r arctan degree):"º".
|
||||
console printLine("Degrees:").
|
||||
console printLine("sin(60º) = ",60.0r radian; sin).
|
||||
console printLine("cos(60º) = ",60.0r radian; cos).
|
||||
console printLine("tan(60º) = ",60.0r radian; tan).
|
||||
console printLine("arcsin(1/2) = ",0.5r arcsin; degree,"º").
|
||||
console printLine("arccos(1/2) = ",0.5r arccos; degree,"º").
|
||||
console printLine("arctan(1/2) = ",0.5r arctan; degree,"º").
|
||||
|
||||
console readChar.
|
||||
].
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
ATAN2(y,x) ! Arctangent(y/x), ''-pi < result <= +pi''
|
||||
SINH(x) ! Hyperbolic sine
|
||||
COSH(x) ! Hyperbolic cosine
|
||||
TANH(x) ! Hyperbolic tangent
|
||||
ATAN2(y,x) ! Arctangent(y/x), ''-pi < result <= +pi''
|
||||
SINH(x) ! Hyperbolic sine
|
||||
COSH(x) ! Hyperbolic cosine
|
||||
TANH(x) ! Hyperbolic tangent
|
||||
|
|
|
|||
|
|
@ -1,10 +1,23 @@
|
|||
fromDegrees :: Floating a => a -> a
|
||||
fromDegrees deg = deg * pi / 180
|
||||
toDegrees rad = rad * 180 / pi
|
||||
|
||||
example = [
|
||||
sin (pi / 6), sin (fromDegrees 30),
|
||||
cos (pi / 6), cos (fromDegrees 30),
|
||||
tan (pi / 6), tan (fromDegrees 30),
|
||||
asin 0.5, toDegrees (asin 0.5),
|
||||
acos 0.5, toDegrees (acos 0.5),
|
||||
atan 0.5, toDegrees (atan 0.5)]
|
||||
toDegrees :: Floating a => a -> a
|
||||
toDegrees rad = rad * 180 / pi
|
||||
|
||||
main :: IO ()
|
||||
main =
|
||||
mapM_
|
||||
print
|
||||
[ sin (pi / 6)
|
||||
, sin (fromDegrees 30)
|
||||
, cos (pi / 6)
|
||||
, cos (fromDegrees 30)
|
||||
, tan (pi / 6)
|
||||
, tan (fromDegrees 30)
|
||||
, asin 0.5
|
||||
, toDegrees (asin 0.5)
|
||||
, acos 0.5
|
||||
, toDegrees (acos 0.5)
|
||||
, atan 0.5
|
||||
, toDegrees (atan 0.5)
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
# v0.6.0
|
||||
|
||||
rad = π / 4
|
||||
deg = 45.0
|
||||
|
||||
@show rad deg
|
||||
@show sin(rad) sin(deg2rad(deg))
|
||||
@show cos(rad) cos(deg2rad(deg))
|
||||
@show tan(rad) tan(deg2rad(deg))
|
||||
@show asin(sin(rad)) asin(sin(rad)) |> rad2deg
|
||||
@show acos(cos(rad)) acos(cos(rad)) |> rad2deg
|
||||
@show atan(tan(rad)) atan(tan(rad)) |> rad2deg
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
// version 1.1.2
|
||||
|
||||
import java.lang.Math.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val radians = Math.PI / 4.0
|
||||
val degrees = 45.0
|
||||
val conv = Math.PI / 180.0
|
||||
val f = "%1.15f"
|
||||
var inverse: Double
|
||||
|
||||
println(" Radians Degrees")
|
||||
println("Angle : ${f.format(radians)}\t ${f.format(degrees)}\n")
|
||||
println("Sin : ${f.format(sin(radians))}\t ${f.format(sin(degrees * conv))}")
|
||||
println("Cos : ${f.format(cos(radians))}\t ${f.format(cos(degrees * conv))}")
|
||||
println("Tan : ${f.format(tan(radians))}\t ${f.format(tan(degrees * conv))}\n")
|
||||
inverse = asin(sin(radians))
|
||||
println("ASin(Sin) : ${f.format(inverse)}\t ${f.format(inverse / conv)}")
|
||||
inverse = acos(cos(radians))
|
||||
println("ACos(Cos) : ${f.format(inverse)}\t ${f.format(inverse / conv)}")
|
||||
inverse = atan(tan(radians))
|
||||
println("ATan(Tan) : ${f.format(inverse)}\t ${f.format(inverse / conv)}")
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
/* REXX ---------------------------------------------------------------
|
||||
* show how the functions can be used
|
||||
* 03.05.2014 Walter Pachl
|
||||
*--------------------------------------------------------------------*/
|
||||
Say 'Default precision:' .locaL~my.rxm~precision()
|
||||
Say 'Default type: ' .locaL~my.rxm~type()
|
||||
Say 'rxmsin(60) ='rxmsin(60) -- use default precision and type
|
||||
Say 'rxmsin(1,21,"R")='rxmsin(1,21,'R') -- precision and type specified
|
||||
Say 'rxmlog(-1) ='rxmlog(-1)
|
||||
Say 'rxmlog( 0) ='rxmlog( 0)
|
||||
Say 'rxmlog( 1) ='rxmlog( 1)
|
||||
Say 'rxmlog( 2) ='rxmlog( 2)
|
||||
.locaL~my.rxm~precision=50
|
||||
.locaL~my.rxm~type='R'
|
||||
Say 'Changed precision:' .locaL~my.rxm~precision()
|
||||
Say 'Changed type: ' .locaL~my.rxm~type()
|
||||
Say 'rxmsin(1) ='rxmsin(1) -- use changed precision and type
|
||||
::requires rxm.cls
|
||||
1037
Task/Trigonometric-functions/OoRexx/trigonometric-functions-2.rexx
Normal file
1037
Task/Trigonometric-functions/OoRexx/trigonometric-functions-2.rexx
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -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,13 @@
|
|||
scalar deg=_pi/180
|
||||
|
||||
display cos(30*deg)
|
||||
display sin(30*deg)
|
||||
display tan(30*deg)
|
||||
|
||||
display cos(_pi/6)
|
||||
display sin(_pi/6)
|
||||
display tan(_pi/6)
|
||||
|
||||
display acos(0.5)
|
||||
display asin(0.5)
|
||||
display atan(0.5)
|
||||
11
Task/Trigonometric-functions/Zkl/trigonometric-functions.zkl
Normal file
11
Task/Trigonometric-functions/Zkl/trigonometric-functions.zkl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(30.0).toRad().sin() //-->0.5
|
||||
(60.0).toRad().cos() //-->0.5
|
||||
(45.0).toRad().tan() //-->1
|
||||
(0.523599).sin() //-->0.5
|
||||
etc
|
||||
|
||||
(0.5).asin() //-->0.523599
|
||||
(0.5).acos() //-->1.0472
|
||||
(1.0).atan() //-->0.785398
|
||||
(1.0).atan().toDeg() //-->45
|
||||
etc
|
||||
Loading…
Add table
Add a link
Reference in a new issue