Best Free C# Math Parser using variables, user defined functions, custom operators
Solution 1
I've found these three as of today, all of which support variables and user defined functions, but only muParser seems to support custom operators:
- NCalc
- Math Parser .NET
- muParser - has a .NET wrapper
- and Google knows even more...
For my little toy project I went with Math Parser .NET since it supports ^
for powers whereas NCalc does not, and muParser somehow didn't appeal to me as much. There is another benefit: Math Parser .NET supports native C# delegates as custom functions! The solutions that the other libraries offer don't look that elegant.
Solution 2
I used IronPython as an expression evaluator.
Solution 3
You should have a look at Jace.NET. Jace is high performing c# math parser that supports all math operations, variables, (custom) functions... It supports all major .NET platforms of Microsoft: .NET 4.x, Windows Phone 7 & 8, Windows Store.
https://www.nuget.org/packages/Jace
https://github.com/pieterderycke/Jace
Solution 4
You could try Mathos Parser (https://mathosparser.codeplex.com/), which allows you to add custom operators, custom variables, and custom functions. It supports almost all operations from Math namespace and has a pre-built set of operators. As the parser does not have that many dependencies, it is very easy to just paste the source code into your project (it is less than 500 lines of code)!
Solution 5
Try Irony (http://irony.codeplex.com). It allows you to parse the expression, which you can do everything with: build a delegate for extremely fast computation, highlight the syntax, or like in my project, converts to Latex and display its representation in math formula.
Ziba Leah
Updated on June 09, 2022Comments
-
Ziba Leah almost 2 years
I'm looking for a .NET Math Parser which uses variables, custom operators and user defined functions... Since today i've used muParser (there's a wrapped version for .NET), but i noticed it is too slow!
Does anybody knows another Math Parser (FREE!) that works pretty good?
I tried NCalc, but it doesn't have variables, so it fails..