Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Created November 18, 2022 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hermann-SW/51b9a30d0060a5f2b521886dcd0c77b2 to your computer and use it in GitHub Desktop.
Save Hermann-SW/51b9a30d0060a5f2b521886dcd0c77b2 to your computer and use it in GitHub Desktop.
more trigonomic functions and definitions
pi=4*a(1)
d=pi/180
define sin(x){return s(x)}
define cos(x){return c(x)}
define atan(x){return a(x)}
define tan(x) {
if (c(x)==0) return pi/2
return s(x)/c(x)
}
define acos(x) {
if (x==0) return pi/2
return a(sqrt(1/x^2-1))
}
define asin(x) {
if (x==1) return pi/2
return a(sqrt(1/(1-x^2)-1))
}
@Hermann-SW
Copy link
Author

Hermann-SW commented Nov 18, 2022

pi@pi400-64:~ $ bc -ql trig.bc
sin(60*d)
.86602540378443864648
cos(60*d)
.50000000000000000047
tan(45*d)
.99999999999999999916
atan(1)/d
45.00000000000000002349
asin(sqrt(3)/2)/d
60.00000000000000003093
acos(0.5)/d
60.00000000000000003151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment