I have a new project called IQ4sh or simply 'iq'. It's a calculator written to replace calls to 'bc', 'awk', etc., from within scripts. It also can be used from the CLI as a one-shot calculator or sourced into you shell session for interactive use anytime.
I need testers and folks eager to try something light and easy on your system. This calculator is not only ~for~ the shell -it's written in shell. It has been tested under dash, zsh, posh and bash, where it all works fine.
You can get iq from github at:
https://github.com/math-for-shell/iq4sh
I know that puppians first question will be: "Will it work with Puppy?" That's where I need the testers, as I can't answer that question. I don't know how posix-compatible the busybox shell is theses days(I know BB has several shells).
I started this project about 18 months ago because I wanted to try programming some 'real AI' from within the shell. I found only one example on github(https://github.com/justinstaines/neuralnetwork) -and it didn't really work 100%. It created a very simple neural-network with 2 inputs, 3 hidden nodes/neurons and a single output. But, I could see that it was learning. The trouble was that, on nearly every line of the script it was calling 'bc' or 'awk'. In 69 lines of code, it called bc 42 times and awk 4 times. Worse, since most of the script was a loop, so that running 10 iterations of 'learning', it called bc 420 times, awk 40 times (and 'cut' 9 times).
I thought to myself, surely there's a way to reduce or eliminate those external calls. Looking on the web for calculators written in the shell-language, I found fp.sh by Vidar Holen(github-koalaman), but it was not a usable calculator at all -but an impressive demo of what might be possible. I set out to write my own calculator -and it's not quite as easy as it might sound. In the end, IQ4sh is the result.
iq of course includes the basic operations of add, subtract, multiply and divide. But that doesn't really get us very far -when we want to calculate the 'logistic' or sigmoid function. So, iq also has functions for exp(), pow(), log(2/n/10), nthroot and many more. In a companion file called 'iq+' there are many functions which can be tried in conjunction with 'iq'.
A quick way to test if iq is working on your system is to run this command:
./iq pow -s5 3.1416 ^ -2.2
which should give this answer: 0.08058
Yes, it will take a second to return the answer, since the above problem involves quite a lot calculations. 'pow' is the slowest function of all and used as above it calls nearly every other function in iq.
Let's try another example:
./iq nthrt -s7 5 2.7182 ( 5th root of 2.7182 to precision=7)
returns: 1.2213954
And, to illustrate a bit more speed:
./iq mul -s20 1.61803398874989484820458683436 3.141592653589793238462643383279
which (quickly) returns: 5.08320369231525981580
After downloading or cloning, make the files iq and iq+ executable and run the program like this:
./iq liqhelp
to see the opening help page. There you'll see a listing of the available functions. Running './iq iqhelp funcname' will show the help for the name of the function you give(funcname).
If you want to try the more advanced functions from iq+, it can be run the same as iq:
./iq+ tanh_pade -s6 3.75 returns: 0.998762
There is no help for the functions from iq+, so you'll want to open the file and look over the functions to see what is there.
I hope that a few of you will try the program and let me know what you think of it, what you miss about it or what could be improved.
I have succesfully used iq to replace all the calls to bc and awk in the above-mentioned 'neural-network' project and started another couple of projects which put iq to the test.