I need to calculate arccos()in a bash script.gawk can calculate cos(theta)and sin(theta)how to calculate arccos()in linux?
arccos()
cos(theta)
sin(theta)
Using the command line tool bcand referring to the Advantage Bash , the arccosine function is shown below, and $1is the first argument to the function arccos().
bc
$1
arccos () { scale=3 if (( $(echo "$1 == 0" | bc -l) )); then echo "a(1)*2" | bc -l elif (( $(echo "(-1 <= $1) && ($1 < 0)" | bc -l) )); then echo "scale=${scale}; a(1)*4 - a(sqrt((1/($1^2))-1))" | bc -l elif (( $(echo "(0 < $1) && ($1 <= 1)" | bc -l) )); then echo "scale=${scale}; a(sqrt((1/($1^2))-1))" | bc -l else echo "input out of range" return 1 fi }
You can do what you want by calling, for example, perl:
acos_05=`perl -E 'use Math::Trig; say acos(0.5)'`
, , bash? - , , bash - . , , , , ( ) - .
( ) : Python, Ruby, Tcl, Perl,...; - , bash.
Source: https://habr.com/ru/post/1532016/More articles:Combine sorting implementation in C ++ - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1532012/drawerlayout-prevents-touch-events-on-edittext&usg=ALkJrhg9mENewu6p0IhkogTOj9XDorcK-gAutofac: register generic type with unrelated interface - genericsRendering vectors in a sphere with better perception - pythonMaximum munch in Text.ParserCombinators.ReadP - parsingUITableViewCell text style using UIAppearance - iosMQTT over WebSockets using Netty? - javaText box as search bar - iosHow do I pass an object manager to an embed form in Symfony? - phpApache Karaf client output fails - io-redirectionAll Articles