\sqrt seems to have trouble with variables
Hi! Thanks for this handy library! I'm trying to wire it up to some LaTex coming from MathQuill (http://jsbin.com/eCiNOGU/2/edit) and have run into a couple of issues.
Maybe there is a way to get around this, but the following expression will not compile():
\\sqrt{x}
I've tried a few variations, and these work:
x
\\sqrt{1}
Anytime I combine the \sqrt function with a variable, it fails with the following error:
error parsing Error: Use real(), imag(), or abs(), or arg() first.
Any suggestions? Thanks!
The problem here is that I haven't yet implemented the functionality that allows functions to map to complex numbers. The square root has to do this for negative numbers, but it has no way of knowing it will get negative numbers so it has to do it anyway.
A workaround would be to override the built in sqrt function:
M.Global.sqrt.default = function (x) { return new M.Expression.List.Real([M.Global.sqrt, x]); };