3

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..

Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101
Ziba Leah
  • 2,484
  • 7
  • 41
  • 60

5 Answers5

8

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:

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.

Oliver
  • 9,239
  • 9
  • 69
  • 100
5

I used IronPython as an expression evaluator.

Max
  • 19,654
  • 13
  • 84
  • 122
  • More a generic scripting language than a math parser, but have an upvote since the OP didn't specify if he was wanting to do symbolic manipulation. –  Mar 15 '11 at 13:29
  • @Inuyasha Actually when I used it in a project I only needed basic +, - and * calculator, even without variables. So using a scripting engine for it seemed like overkill. But it was just so easy to use, so I went for it. – Max Mar 15 '11 at 13:50
  • I think IronPythons is too slow for my purpose.. I need a parser which compiles the formulas so i didn't need to parse it every time i call for it.. – Ziba Leah Mar 15 '11 at 13:52
  • I didn't do any performance evaluations of IronPython script, because performace wasn't critical for me, so I canot say anything about it. But I believe that you can compile IronPython scripts dynamically and then use the compiled vesions from C#. – Max Mar 15 '11 at 13:56
4

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

MuSTaNG
  • 3,832
  • 2
  • 14
  • 6
3

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)!

Artem
  • 1,000
  • 1
  • 15
  • 30
1

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.

tvbusy
  • 136
  • 5
  • 9