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

Which expressions are available? #39

Closed
jpiabrantes opened this issue Aug 4, 2022 · 5 comments
Closed

Which expressions are available? #39

jpiabrantes opened this issue Aug 4, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@jpiabrantes
Copy link

I am trying to solve a non-linear equation and getting the error:
Error: ExpressionParserException: The given expression cannot be parsed! Make sure that all operators are supported. Make also sure that the product of two values explicitly has the '*' symbol.

How do I find which expressions are available?

Here's my code:

final newton = Newton(function: "0.03606737602222409*x*log(exp((3537.428612970299+x)/287.171070460561)+4914469.74557367)-15.455695470480395", x0: 5);
newton.solve();
@jpiabrantes jpiabrantes added the enhancement New feature or request label Aug 4, 2022
@jpiabrantes
Copy link
Author

this might be a bug, if I replace exp with cos everything works. Why isn't exp working?

@albertodev01
Copy link
Owner

I will investigate this by this weekend, thank you for reporting the issue 🙂

I also should include in the docstring the full operators list

@jpiabrantes
Copy link
Author

I was able to fix it by adding to the ExpressionParser

..wrapper(
      string('exp(').trim(),
      char(')').trim(),
          (_, a, __) => (value) => math.exp(a(value)),
      )

happy to send a PR if the repo is open to that.

@albertodev01
Copy link
Owner

Yeah it looks like I forgot to add the exp function to the grammar! I have to add other features to the package so I will include this fix as well 😄

For now, you can workaround this using e^(...) instead of exp(...)

@albertodev01
Copy link
Owner

I am closing this since this bug is gone and the fix will be part of the next 4.1.0 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants