Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

\sqrt seems to have trouble with variables #4

Open
WinstonFassett opened this issue Aug 30, 2013 · 1 comment
Open

\sqrt seems to have trouble with variables #4

WinstonFassett opened this issue Aug 30, 2013 · 1 comment
Assignees

Comments

@WinstonFassett
Copy link

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!

@aantthony
Copy link
Owner

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]); };

@ghost ghost assigned aantthony Sep 3, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants