0

I'm asking if I need to import some kind of library to perform something like that

echo "cos(1)" | bc

and use BLAS and trigonometric functions in general.

user2485710
  • 9,451
  • 13
  • 58
  • 102
  • `man bc` might help with a lot of queries. – devnull May 12 '14 at 15:57
  • @devnull if focuses more on operators, I was expecting a wider support from the standard math library honestly . – user2485710 May 12 '14 at 15:59
  • [GNU octave](https://www.gnu.org/software/octave/) might help. – devnull May 12 '14 at 16:00
  • @devnull I already have the latest version of Octave customized and compiled from source, I was searching for something more friendly and simple to use for when I just need to check something on the fly. – user2485710 May 12 '14 at 16:02
  • @devnull Python is kind of another approach, `bc` uses arbitrary precision, Python is like standard C or C++ with IEEE754 representation. but thanks, it's 1 idea that I didn't think of. – user2485710 May 12 '14 at 16:06
  • OCaml supports [arbitrary precision arithmetic](http://caml.inria.fr/pub/docs/manual-ocaml/libnum.html). – devnull May 12 '14 at 16:10
  • @devnull I guess that after discovering that awk doesn't support arbitrary precision I'm about to get serious about functional programming . – user2485710 May 12 '14 at 16:39

2 Answers2

2

Load the math library with bc -l; the cosine function is named c in this library:

echo "c(1)" | bc -l

This library only supports sine, cosine, artangent, the natural logarithm, the exponential function, and (strangely enough) the n-th order Bessel function.

chepner
  • 497,756
  • 71
  • 530
  • 681
0

This site may offer an extended library (with code available). Quite interesting.

http://phodd.net/gnu-bc/

If someone knows similar libraries please share them.

Pier A
  • 151
  • 1
  • 4