A
A
artshelom2019-03-08 19:22:53
C++ / C#
artshelom, 2019-03-08 19:22:53

How to calculate using formulas?

I have a textbox where the formula is entered, but how to make the calculation take place in it, I don’t know how this can be done ??

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Foggy Finder, 2019-03-08
@artshelom

You can use ready-made libraries.
For example, MathNet.Symbolics
The library is written in F#, but you can also use it in a C# project:
Math-NET-Symbolics-with-C-VB-NET-and-C-CLI
As you can see from the example:

using MathNet.Symbolics;
using Expr = MathNet.Symbolics.SymbolicExpression;
...
Expr.Parse("1/(a*b");  // выбросит исключение
Expr.Parse("1/(a*b)").ToString(); // вернет строку "1/(a*b)"

The API is quite convenient.
Simple functions/formulas shouldn't be a problem. If there are not enough opportunities or you find a bug - open an issue (in English) or even a PR - the maintainer accepts them without problems.
And I, in turn, as one of the contributors, will be happy to answer any questions or help with the implementation of the functionality.
There are other libraries, some of which surpass MathNet.Symbolics in terms of capabilities, but since I have not worked with them, I cannot recommend it.

I
Ivan Arxont, 2019-03-09
@arxont

Look at https://github.com/pieterderycke/Jace

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question