Calculate values of Sine(sin), Cosine(cos), Tangent(tan), Cotangent(cot), Secant(sec), Cosecant(csc), Arc Sine(asin), Arc Cosine(acos), Arc Tangent(atan), Arc Cotangent(acot), Arc Secant(asec), Arc Cosecant(acsc).
To put everything in separate script will need creation of too many files .Hence best thing to do is make them functions and place it in your '.bashrc' file in your home folder.Copy the entire codes below (either radian or degree according to your need) and paste it in your .bashrc file.The codes below uses command line tool bc. Hence make sure that you have installed bc.
RADIANS
-------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
#trignometry
sin ()
{
echo "scale=5;s($1)" | bc -l
}
cos ()
{
echo "scale=5;c($1)" | bc -l
}
tan ()
{
echo "scale=5;s($1)/c($1)" | bc -l
}
csc ()
{
echo "scale=5;1/s($1)" | bc -l
}
sec ()
{
echo "scale=5;1/c($1)" | bc -l
}
ctn ()
{
echo "scale=5;c($1)/s($1)" | bc -l
}
asin ()
{
if (( $(echo "$1 == 1" | bc -l) ));then
echo "90"
elif (( $(echo "$1 < 1" | bc -l) ));then
echo "scale=3;a(sqrt((1/(1-($1^2)))-1))" | bc -l
elif (( $(echo "$1 > 1" | bc -l) ));then
echo "error"
fi
}
acos ()
{
if (( $(echo "$1 == 0" | bc -l) ));then
echo "90"
elif (( $(echo "$1 <= 1" | bc -l) ));then
echo "scale=3;a(sqrt((1/($1^2))-1))" | bc -l
elif (( $(echo "$1 > 1" | bc -l) ));then
echo "error"
fi
}
atan ()
{
echo "scale=3;a($1)" | bc -l
}
acot ()
{
echo "scale=5;a(1/$1)" | bc -l
}
asec ()
{
echo "scale=5;a(sqrt(($1^2)-1))" | bc -l
}
acsc ()
{
echo "scale=5;a(1/(sqrt($1^2)-1))" | bc -l
}
-------------------------------------------------------------------------------------------------------------------------------------------------
DEGREES
-------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
#trignometry
sin ()
{
echo "scale=5;s($1*0.017453293)" | bc -l
}
cos ()
{
echo "scale=5;c($1*0.017453293)" | bc -l
}
tan ()
{
echo "scale=5;s($1*0.017453293)/c($1*0.017453293)" | bc -l
}
csc ()
{
echo "scale=5;1/s($1*0.017453293)" | bc -l
}
sec ()
{
echo "scale=5;1/c($1*0.017453293)" | bc -l
}
ctn ()
{
echo "scale=5;c($1*0.017453293)/s($1*0.017453293)" | bc -l
}
asin ()
{
if (( $(echo "$1 == 1" | bc -l) ));then
echo "90"
elif (( $(echo "$1 < 1" | bc -l) ));then
echo "scale=3;a(sqrt((1/(1-($1^2)))-1))/0.017453293" | bc -l
elif (( $(echo "$1 > 1" | bc -l) ));then
echo "error"
fi
}
acos ()
{
if (( $(echo "$1 == 0" | bc -l) ));then
echo "90"
elif (( $(echo "$1 <= 1" | bc -l) ));then
echo "scale=3;a(sqrt((1/($1^2))-1))/0.017453293" | bc -l
elif (( $(echo "$1 > 1" | bc -l) ));then
echo "error"
fi
}
atan ()
{
echo "scale=3;a($1)/0.017453293" | bc -l
}
acot ()
{
echo "scale=5;a(1/$1)/0.017453293" | bc -l
}
asec ()
{
echo "scale=5;a(sqrt(($1^2)-1))/0.017453293" | bc -l
}
acsc ()
{
echo "scale=5;a(1/(sqrt($1^2)-1))/0.017453293" | bc -l
}
-------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
After saving it. Run ". .bashrc" (without quotes) in your terminal.
To find value of Sine of 45 , run sin 45 in terminal. Similarly for
Cosine .. cos 45
Tangent .. tan 45
Cotangent .. cot 45
Secant .. sec 45
Cosecant .. csc 45
Arc Sine .. asin .73
Arc Cosine .. acos .73
Arc Tanget .. atan .75
Arc Cotangent .. acot .73
Arc Secant .. asec 45
Arc Cosecant .. acsc 45
Enjoy Linux !!





