-
Notifications
You must be signed in to change notification settings - Fork 66
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
SymbolicExpression.Parse freeze for "29^11^7" #64
Comments
I think it's just trying to calculate: "29^(11^7)" that's very big number. So, put a parentheses is a good idea. |
Yes. Exponentiation is right-associative, which means that it is evaluated right-to-left. This is because (29^11)^7 can be written as 29^(11*7) while the other cannot be easily simplified. |
I think large number detection can be done to avoid hangs. (Using power rules while calculating instead of expanding to a very big number) |
Yes, it sounds reasonable. |
Evaluate asynchronously, show an activity indicator and provide a cancel button? |
This is not possible, because my code is in web service invoked by other applications. |
Setting a default timeout so that each request will not take too much time? |
This is not an option too, because I have to return meaningful result in short time. |
I guess we could have a global Control instance like in Numerics to control how a few operations like power behave on very large input (or expected very large output or expensive operation). Ugly, but usually good enough. Any proposals on what good rules would be for power? Should the limitation be opt-in or opt-out? |
Instead of a default timeout, there should be
Using a Example let expression = 9Q ** (9Q ** 9Q);
expression ==> "9^(9^9)" use cts = new CancellationTokenSource (TimeSpan.FromSeconds 5)
try
Expression.simplifyAsync expression cts.Token
with
| :? TaskCanceledException as e => // ... |
Using C# nuget package MathNet.Symbolics, ver 0.20.0
Parsing this expression "29^11^7" leads to freeze.
Tried with
Infix.ParseOrUndefined("29^11^7");
and
SymbolicExpression.Parse("29^11^7")
When tried to put parenthesis it works fine
"(29^11)^7"
The text was updated successfully, but these errors were encountered: