New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling `toTex` on node that contains call to `derivative()` causes exception #1103

ovk opened this Issue May 12, 2018 · 2 comments


None yet
3 participants

ovk commented May 12, 2018

Derivative function cannot be converted to TeX expression. When calling toTex on node that contains a call to derivative function the following exception is thrown

TypeError: Unexpected type of argument in function _derivTex (expected: SymbolNode, actual: ConstantNode, index: 1)

Here's a minimal example that reproduces this issue:

joelhoover added a commit to joelhoover/mathjs that referenced this issue May 13, 2018


This comment has been minimized.


joelhoover commented May 13, 2018

I've investigated this issue, and I believe it is fixed with #1104.

The issue here is that math.parse('derivative("x", "x")') will parse derivative as a function and create a ConstantNode with valueType = 'string' for both instances of "x", and derivative.toTex() simply calls _derivTex with those ConstantNodes. However, _derivTex expects that it's arguments are the Nodes that the strings represent (two SymbolNodes in this case), and so throws a TypeError because those types mismatch. This can be fixed by simply adding overloads to _derivTex that check if the arguments are ConstantNodes representing strings, and then parsing the string contents.


This comment has been minimized.


josdejong commented Jun 10, 2018

This issue is fixed now by Joel, the fix will be available in the first next release, v5.0.0 (expected to be released within a week)

@josdejong josdejong closed this in d2164c4 Jun 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment