Code Monkey home page Code Monkey logo

mathexpressionevaluator's Introduction

Math Expression Evaluator

A lightweight C# math expression evaluator with lazy parsing and solving during runtime, designed to be simple and easy to use, with support for standard order of operations and commonly used functions such as logarithms, trigonometry and factorials.

Examples

// Area of a circle
var expression = new MathExpression("pi * 2^2");
var evaluation = expression.Evaluate();
// Quadratic Formula
var expression = new MathExpression("(-5 + sqrt(5^2 - 4*1*6)) / (2*1)");
var evaluation = expression.Evaluate();
// Pythagoras Theorem
var expression = new MathExpression("sqrt(3^2 + 4^2)");
var evaluation = expression.Evaluate();
// Trigonometry
var expression = new MathExpression("arccos(5/7) * 180/pi");
var evaluation = expression.Evaluate();
// Change of base
var expression = new MathExpression("log(4) / log($e)");
var evaluation = expression.Evaluate();

Supported Constants

Name Symbol
Pi pi
Euler's number $e

Supported Functions

Unary Functions

Name Symbol
Log2 lg
Log10 log
Natural Log ln
Factorial !
Sine sin
Cosine cos
Tangent tan
Inverse Sine arcsin
Inverse Cosine arccos
Inverse Tangent arctan
Hyperbolic Sine sinh
Hyperbolic Cosine cosh
Hyperbolic Tangent tanh
Square Root sqrt

Binary functions

Name Symbol
Addition +
Subtraction -
Multiplication *
Division /
Exponentiation ^
Modulo %

Supported Order of Operations

Name Symbol
Open Parentheses (
Close Parentheses )

mathexpressionevaluator's People

Contributors

agabani avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

bubdm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.