The best thing would be to have the shell have a syntax for arithmetic, but then call out to bc to do the actual handling (because then you get trigonometry and literally everything that bc knows how to do, with only a minimal modification to the shell). Syntactic sugar for a heredoc to bc itself.
And in the code attached to the original post, what's the outer "if" for? No-one is ever going to call it with anything other than two args. But I'm nitpicking. Maybe protection is better than readability. Stuart