https://github.com/bomberus/mathparser
A simple C# library to calculate a Math Equation
https://github.com/bomberus/mathparser
Last synced: over 1 year ago
JSON representation
A simple C# library to calculate a Math Equation
- Host: GitHub
- URL: https://github.com/bomberus/mathparser
- Owner: Bomberus
- License: mit
- Created: 2015-09-29T16:01:55.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-05T10:35:47.000Z (over 10 years ago)
- Last Synced: 2025-01-21T05:11:28.009Z (over 1 year ago)
- Language: C#
- Size: 145 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MathParser
A simple C# library to calculate a Math Equation
## How initialize it
Import the Parser.cs into your Project and add the namespace MathParser then initialize the MathParser
```
Parser parser = new Parser(null);
```
## How to use it
Get the result of the library
```
double result = parser.calculate("2*x^4"); //32
```
## Add Variables to the Parser
To use Variables in your expression create an List of the Type Variable and define your Variables
```
List variable = new List();
variable.Add(new Variable("x", 10));
Parser parser = new Parser(variable);
double result = parser.calculate("2*x"); //20
```
In this example the variable x has the value 10.
Be careful when using the Variable x because the function Integral uses it to define the functions x- value.
## List of supported functions
- sin(x)
- sqrt(x)
- log(x,y) = log{y}(x)
- abs(x) = |x|
- fac(x) = x!
- integral -> uses a numeric algorithm to get the result, but
be careful to use the right order of the parameters:
integral(f(x),min,max,count of iteration steps (the higher the better the result but uses more cpu time)
Example: integral(x^2,2,4,20) ~ 18,87