Skip to content
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

can't parse "(3/4)nrt(5)" #18

Open
DXie123 opened this issue Sep 20, 2019 · 2 comments
Open

can't parse "(3/4)nrt(5)" #18

DXie123 opened this issue Sep 20, 2019 · 2 comments
Labels
enhancement Indicates new feature requests

Comments

@DXie123
Copy link

DXie123 commented Sep 20, 2019

Parser p = new Parser();
Expression exp = p.parse('(3/4)nrt(5)');

Such code throw an error:
type 'Divide' is not a subtype of type 'Number' in type cast

@fkleon
Copy link
Owner

fkleon commented Oct 4, 2019

Thanks for the report!

The parser is in need of an overhaul, and there is at least one other outstanding bug (#10).
Will make sure to add this to the test cases for the rewrite.

@fkleon
Copy link
Owner

fkleon commented Mar 8, 2020

Hi, I'm currently revisiting this as part of another fix.

The n-th root is only implemented for the simple case \sqrt[n]{x} where the index n is an integer and the radicant x is a real number. In that case, the correct syntax for the parser would be nrt(n,x).

If I understand your original report correctly, you are trying to evaluate the n-th root with a non-integer index, i.e. \sqrt[\frac{3}{4}]{5} = 5^{\frac{1}{(\frac{3}{4})}} = 5 \cdot \sqrt[3]{5}

This could easily be implemented by allowing non-integer index values (arbitrary expressions). The library is already converting the n-th root to its power form internally as above to evaluate and differentiate the expression.

@fkleon fkleon added the enhancement Indicates new feature requests label Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

2 participants