You can use the -e option to just eval a lisp expression (from man emacsclient):
-e, --eval
Do not visit files but instead evaluate the arguments as Emacs Lisp expressions.
E.g.
$ emacsclient -e '(calc-eval "solve(x^2 +x = 23, x)")'
"x = 4.3218"
I suppose that can be made easier via a shell function. E.g.
$ calc() { emacsclient -e "(calc-eval \"$@\")" | xargs; }
$ calc 'inv(
[1, 2, 3, 4;
6, 5, 4, 3;
7, 12, 3, 4;
5, 6, 3, 2])'
((-0.28571 0.71429 0.16667 -0.83333) (0.071429 -0.42857 1.1351e-14 0.5) (0.28571 -0.71429 -0.5 1.5) (0.071429 0.57143 0.33333 -1.1667))
I use the pipe through xargs here to get rid of the quotes (which implies passing the output as arguments to echo), which seems to work fine, but let me know if you see any adverse side effects.