Post Reply 
bc (basic calculator) and libraries of functions
02-09-2018, 03:10 PM (This post was last modified: 02-09-2018 03:11 PM by pier4r.)
Post: #1
bc (basic calculator) and libraries of functions
Follow up of: http://www.hpmuseum.org/forum/thread-101...l#pid90844

In linux, bc is a neat program with arbitrary precision.
https://en.wikipedia.org/wiki/Bc_(programming_language)

The point is that although it seems quite powerful for a possible math programming environment, to my knowledge there is no extensive library of math functions.
https://www.gnu.org/software/bc/manual/h...no/bc.html

Functions:
Quote: If bc is invoked with the -l option, a math library is preloaded and the default scale is set to 20. The math functions will calculate their results to the scale set at the time of their call. The math library defines the following functions:

s (x)
The sine of x, x is in radians.
c (x)
The cosine of x, x is in radians.
a (x)
The arctangent of x, arctangent returns radians.
l (x)
The natural logarithm of x.
e (x)
The exponential function of raising e to the value x.
j (n,x)
The bessel function of integer order n of x.

To my little knowledge the best that I found is the following:
http://phodd.net/gnu-bc/
and then
http://phodd.net/gnu-bc/bcfaq.html

it is a nice project in itself to try to make a library module for bc (that I think it will be worth it. Another fun todo).

Anyway, do you know any better collection (or libraries or repositories) of functions for bc? For example a file with many functions inside?

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
02-09-2018, 03:21 PM
Post: #2
RE: bc (basic calculator) and libraries of functions
Hello!

I vaguely remember "bc" from my unix days (ca. 1989-2000). BTW: Not only Linux has one on board, but every Macintosh running OS X as well.

In one of your linked articles I instantly found this droll piece of explanation:
"bc was preceded by dc, an earlier arbitrary-precision calculator written by the same authors. dc could do arbitrary-precision calculations, but its reverse Polish notation (RPN) syntax was inconvenient for users".

Saluti
Max
Find all posts by this user
Quote this message in a reply
02-10-2018, 03:01 AM
Post: #3
RE: bc (basic calculator) and libraries of functions
(02-09-2018 03:10 PM)pier4r Wrote:  Follow up of: http://www.hpmuseum.org/forum/thread-101...l#pid90844

In linux, bc is a neat program with arbitrary precision.
https://en.wikipedia.org/wiki/Bc_(programming_language)

bc is also available for Windows:

http://gnuwin32.sourceforge.net/packages/bc.htm

Does anyone know if there is a way to save and load files from the interactive mode? Right now, I'm pasting text into the bc window.

Tom L

DM42 SN: 00025 (Beta)
SN: 00221 (Production)
Find all posts by this user
Quote this message in a reply
02-10-2018, 09:39 AM (This post was last modified: 02-10-2018 09:42 AM by Massimo Gnerucci.)
Post: #4
RE: bc (basic calculator) and libraries of functions
(02-10-2018 03:01 AM)toml_12953 Wrote:  
(02-09-2018 03:10 PM)pier4r Wrote:  Follow up of: http://www.hpmuseum.org/forum/thread-101...l#pid90844

In linux, bc is a neat program with arbitrary precision.
https://en.wikipedia.org/wiki/Bc_(programming_language)

bc is also available for Windows:

http://gnuwin32.sourceforge.net/packages/bc.htm

Of course it is; yesterday I used the 1.07 version (bc + dc) available here.

(02-10-2018 03:01 AM)toml_12953 Wrote:  Does anyone know if there is a way to save and load files from the interactive mode? Right now, I'm pasting text into the bc window.

I could not find a way from the interactive mode either.

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
02-10-2018, 10:15 AM
Post: #5
RE: bc (basic calculator) and libraries of functions
(02-10-2018 09:39 AM)Massimo Gnerucci Wrote:  
(02-10-2018 03:01 AM)toml_12953 Wrote:  bc is also available for Windows:

http://gnuwin32.sourceforge.net/packages/bc.htm

Of course it is; yesterday I used the 1.07 version (bc + dc) available here.

Thanks for the tip on the newer version! The site I mentioned has great docs for 1.06 included in the file so it's worth it to me to use those with the newer bc from your site. 1.06 doesn't seem too different from 1.07.1 so most of the information applies. I do notice the transcendental functions s(x), c(x), a(x), etc. are much faster in 1.07.

Tom L

DM42 SN: 00025 (Beta)
SN: 00221 (Production)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)