Cheat sheet of the bc calculator

Using an opensource app, Sensi -Shake to open app, my terminal emulator is opened each time I shake my smartphone, there I run the bc command since I like bc more than the smartphone calculator.

In order to use bc as a scientific calculator, just run it as:

bc -l

It only works in radians, so you should learn how to convert radians to degrees. You may use a simple rule of three.

Consider that 180 degrees equals to 4*a(1)

Variables

You can declare a variable straightforwardly:

a=5

Do not confuse with the following expression:

a==5 which is a logical evaluation that may return true or false.

Scientific notation

I improvised the scientific notation with the following code in bc:

a=0

if (x>10000) {

while (x>=10) {

x=x/10

a=a+1 }

x; a

}

if (x<0.0001) {

while (x<1) {

x=x*10

a=a+1 }

x; -a

}

The basic

π4*a(1)
ee(1)
 nth(y) root:e(l(x)/y)
Square root:sqrt(x)

Transcendental functions

Natural logarithml(x)
Common logarithml(x)/l(10)

Trigonometric functions:

sins(x)
cosc(x)
tans(x)/c(x)
sec1/c(x)
ctgc(x)/s(x)
csc1/s(x)

 

arctga(x)
arcctg2*a(1)-a(x)
arccsca(1/x)

Arccosine:

if (x== 0) {
90 } else {
a(sqrt(1/(x^2)-1))
}

Arcsine:

if (x==1) {
90 } else {
a(sqrt(1/(1-(x^2))-1))
}

Arc secant:

There is not an integrated function for arcsine, so use the following formula:

2*a(1)-arcsin(1/x)

Factorial function:

In a bash shell run the following and substitute 500 with the desired number:

seq -s "*" 1 500 | bc

 

These bottons respect your privacy