Comments (4)
This results from the precedence of unary minus is higher than power operator. I think the list below may be right for us.
Precedence of operators, from highest to lowest.
- parentheses
- pow:
a^b
- unary minus and plus:
-a
,+a
- multiply, divide :
a*b
,a/b
- add, subtract:
a+b
,a-b
from mathnet-symbolics.
I'm actually not entirely sure we can control this (at least when using F# as dsl), since prefix operators have a higher precedence in F# than the power operator (docs). What happens in the Infix parser is a different story (and would also need to be verified).
from mathnet-symbolics.
Yes, I can get right expression by changing the precedence of operators in the Infix parser.
Infix.parseOrUndefined "a*exp(-(x-b)^2/(2*c^2))";; // Gaussian function
val it : Expression = a*exp(-(-b + x)^2/(2*c^2))
a*exp(-(x-b)**2/(2*c**2));;
val it : Expression = a*exp((b - x)^2/(2*c^2))
Workaround we can select now is using "-1*" or "0 - " instead of "-" to get right answer, is it right?
from mathnet-symbolics.
Unlike F#, it is clear that exponentiation has higher precedence than unary minus in the mathematics, and in fact, it is already reflected in Infix.format. However, it is not easy to change the order of operators of F# now. So how about intentionally setting the precedence of operators of F# and the Infix parser differently? If we know this and can use parentheses properly when in doubt, I think it is not a bad idea.
from mathnet-symbolics.
Related Issues (20)
- Processing does not end
- "not supported" exception with divide by zero in equation
- FSI
- Errors parsing and evaluating complex-valued string
- Evaluation of an expression dealing with Vector
- Bug: No control over culture for string formatting HOT 1
- Solving simple equations or HOT 3
- Expression.Zero.Equals() Bug? HOT 2
- Rational.Simplify gets stuck in endless loop HOT 3
- Problem with eager numeric calculation HOT 1
- Automatically escape special LaTeX characters in symbol names HOT 4
- What about cooperation? HOT 3
- Latex HOT 8
- Multiplication signs being removed by Latex.formatvisual function HOT 4
- Simplify a string of variables and numbers - vb HOT 2
- How to use variables in algebra problems using a string? HOT 2
- How to add Parsing and Evaluation of the min and max functions HOT 2
- Approximation.Real vs FloatingPoint.Real
- No effective way to generate large sums
- Order of expressions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mathnet-symbolics.