Created
February 27, 2017 10:52
-
-
Save scriptum/b2cb5a8706078fd6c46433a7c7b0eaf7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bc with trigonometry and useful functions | |
bc() { | |
/usr/bin/bc -qli <(echo ' | |
scale=32 | |
pi=4*a(1) | |
e=e(1) | |
scale=20 | |
define sin(x) { | |
return (s(x)) | |
} | |
define cos(x) { | |
return (c(x)) | |
} | |
define atan(x) { | |
return (a(x)) | |
} | |
define arctg(x){ | |
return (a(x)) | |
} | |
define tan(x) { | |
return (s(x)/c(x)) | |
} | |
define tg(x) { | |
return (s(x)/c(x)) | |
} | |
define asin(x) { | |
if(x==1) return(pi/2) | |
if(x==-1) return(-pi/2) | |
return(a(x/sqrt(1-(x^2)))) | |
} | |
define arcsin(x) { | |
return (asin(x)) | |
} | |
define acos(x) { | |
if(x==1) return(0) | |
if(x==-1) return(pi) | |
return(pi/2-a(x/sqrt(1-(x^2)))) | |
} | |
define arccos(x) { | |
return (acos(x)) | |
} | |
define cot(x) { | |
return(c(x)/s(x)) | |
} | |
define ctg(x) { | |
return(c(x)/s(x)) | |
} | |
define acot(x) { | |
return(pi/2-a(x)) | |
} | |
define arcctg(x) { | |
return(pi/2-a(x)) | |
} | |
define sec(x) { | |
return(1/c(x)) | |
} | |
define cosec(x) { | |
return(1/s(x)) | |
} | |
define csc(x) { | |
return(1/s(x)) | |
} | |
define asec(x) { | |
return(acos(1/x)) | |
} | |
define acosec(x) { | |
return(asin(1/x)) | |
} | |
define acsc(x) { | |
return(asin(1/x)) | |
} | |
/************************/ | |
define ln(x) { | |
return(l(x)) | |
} | |
define log(x) { | |
return(l(x)/l(10)) | |
} | |
define pow(x,y) { | |
return(e(y*l(x))) | |
}') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment