I appreciate your engagement. All those errors come under a single class of input, some of which I did handle in iq-1.62. But not all those cases.
The thorough checks needed to cull out nonsense inputs, slow down every function immensely. I think such checks belong in a more user-oriented, interactive front-end, where one might also have an expression evaluator, which would handle stuff like this ( num + ( num / num ) ). In iq+ there is the 'isnum' function which covers some of those input errors, but creative users can easily find ways to fool nearly any amount of checks.
As it is, each public function is a compromise between assuming completely sane, sensible inputs, and accepting sensible inputs which are mostly sane. The alternative was to put the real meat of each function into a sub-function and have a set of front-end functions -which still slows things down -and creates more inter-function dependencies.
A glaring error would be when one of the functions output looked like those inputs, or if you tried "iq div /user/bin/ls / 3 " (or worse), and something actually happened besides seeing: iq: 80: [: Illegal number: /user/bin/ls0. What I'm trying to achieve is real, correct answers to real math problems. For that I need functions that first work correctly and efficiently among themselves. Just that has been a pretty steep hill, as you can see.
Code: Select all
echo $(( blabla / blabla ))
bash: blabla / blabla : division by 0 (error token is "blabla ")
iq returns '1.0' because it checks early if 'mod' equals 'dvsr', other wise you'd see the above error directly from the math unit. Notice that it also doesn't correctly identify the problem.
Code: Select all
echo "blabla / blabla" |bc
Runtime error (func=(main), adr=5): Divide by zero
What I want is stuff like this to work:
Code: Select all
iq+ nroot -s7 1.1569821 10
1.0146883
iq+ pow -s7 1.0146883 -4.6
0.9351252
#and especially the ai functions:
sigmoid_real -s4 0.935
0.718
sigmoid_tanh -s4 0.935
0.718
And it does work -I'm optimistic that other such valid inputs produce correct results -to the precision requested. I'm under no illusions that iq might become the next bc or awk. But if it could serve as a usable alternative to them, under some circumstances, then I will be happy. The whole goal was to be able to solve:
or similar equations, and their derivatives -with only simple shell language. The fact that it can do so in usable times was a surprise -once it happened. I'm hoping that div is finally working correctly -although I'm still working on the performance.