All Projects → mdibaiee → Equation

mdibaiee / Equation

Licence: MIT license
Solve Math expressions, create equations, define operators and constants

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Equation

latex in word
LaTeX equation edition in a macro-enabled Word document
Stars: ✭ 29 (-21.62%)
Mutual labels:  equation
chem
Chemical Equation Balancing
Stars: ✭ 17 (-54.05%)
Mutual labels:  equation
Symbolic-Regression
predicting equations from raw data with deep learning
Stars: ✭ 48 (+29.73%)
Mutual labels:  equation
notion-page-to-html
NodeJS tool to convert public Notion pages to HTML from page ID
Stars: ✭ 109 (+194.59%)
Mutual labels:  equation
mathconverter
Converts from AsciiMath, LaTeX, MathML to LaTeX, MathML
Stars: ✭ 35 (-5.41%)
Mutual labels:  equation
MathImprove
Modify and Improve math expressions.
Stars: ✭ 13 (-64.86%)
Mutual labels:  math-expression
Mathquill
Easily type math in your webapp
Stars: ✭ 1,968 (+5218.92%)
Mutual labels:  equation
keisan
A Ruby-based expression parser, evaluator, and programming language
Stars: ✭ 48 (+29.73%)
Mutual labels:  equation
stiff3
Adaptive solver for stiff systems of ODEs using semi-implicit Runge-Kutta method of third order
Stars: ✭ 13 (-64.86%)
Mutual labels:  equation
split-ease
The JavaScript Easing function with a beginning, middle and end
Stars: ✭ 55 (+48.65%)
Mutual labels:  equation
tex-equation-to-svg
Convert a TeX or LaTeX string to an SVG.
Stars: ✭ 34 (-8.11%)
Mutual labels:  equation
Equation and Codebox
Microsoft Word VSTO Add-In,可以插入带编号的公式和代码
Stars: ✭ 27 (-27.03%)
Mutual labels:  equation
Fluid Simulation
Self advection, external force and pressure solve to a velocity field represented by a MaC grid.
Stars: ✭ 107 (+189.19%)
Mutual labels:  equation
klatexformula
Generate images from LaTeX equations that you can drag and drop, copy and paste or save to disk.
Stars: ✭ 70 (+89.19%)
Mutual labels:  equation
eqn
A gem to evaluate mathematical equations.
Stars: ✭ 32 (-13.51%)
Mutual labels:  equation
string-math
Evaluates a math expression from a string. Supports variables and custom operators.
Stars: ✭ 14 (-62.16%)
Mutual labels:  math-expression

Equation Build Status

Solve math expressions or create equations for repeated and complex Math tasks.

To use in browser, download equation.min.js.

A similar library I wrote in Haskell is also available mathexpr

Install using npm:

npm install equations

Examples:

//import

const Equation = require('equations').default

// solve
console.log(Equation.solve('4 * lg(4) ^ 3')); // 32

// equation
let sphereArea = Equation.equation('4 * PI * r^2');
console.log(sphereArea(5)); // 314.1592653589793

let test = Equation.equation('2x + 6y');
console.log(test(4, 3)).to.equal(8 + 18);

You can also register your own operators and constants.

// these options are explained in [`operators.js`](https://github.com/mdibaiee/Equation/blob/master/lib/operators.js).
Equation.registerOperator('$', {
  fn: a => 1/a,
  format: '10',
  precedence: 2
});

Equation.solve('$2'); // 0.5
Equation.solve('$5'); // 0.2

Equation.registerConstant('N', () => {
  return Math.random() * 10 + 10
});

Equation.solve('N'); // a number between 10 and 20

// Complex operators
Equation.solve('sigma(0, 5, 2@ + 5)'); // 60

For a list of operators and constants see operators.js and constants.js.

API

solve(expression: String)

Takes a math expression and evaluates it, returning the result.

equation(expression: String)

Takes a math expression containing variables, returning a function which replaces the variables with given arguments, and solves the expression.

registerOperator(key: String, options: Object)

Registers a new operator.

Options:

fn

The function which is run on arguments and returns the result

format

The format which specifies how arguments are placed relative to operator, this is a string in which 1 represents the operator and zeroes represent arguments.

For example + has the format 010 and factorial has 01.

precedence

Specifies the precedence of operator. The less the value, the higher the precedence, resulting in sooner execution.

registerConstant(key: String, value: Function/Number)

Registers a new constant. value can be a function (takes no arguments), or a constant number.

That's right, we have named these constants, but they actually can change, that's why we can use functions to define them. An example is the RAND constant which calls Math.random.

Contributing

The code is commented and I hope you don't have a hard time contributing, anyway, some tips about contributing:

The source code is in lib directory and is then transpiled into dist.

#####Grunt Tasks ######default Transpiles lib to dist ######build Transpiles, browserifies, uglifies ######eslint Runs ESLint on lib and tests ######test Runs the tests


Please make sure to run grunt eslint before commiting.

If you're adding something new, please add a test, too.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].