math-parser
math-parser copied to clipboard
PHP parser for mathematical expressions
…arccsch arcsech, arcsind, arccosd, arctand, arccotd, arccscd, arcsecd, arccsc, arcsec, todeeg, torad
If you supply a variable named e, the number e is used instead of the supplied value. Maybe throw an exception when a variable named e is supplied?
Hi, I've added _hasInstance_ as described in ReadMe because I'd like to use it for a Math test system for testing whether the answer supplied by a student has a...
Is there a simple way to add custom constants similar to 'pi' such as epsilon_o = 8.8541878128e-12 speed_of_light = 299792458.0 electron_mass = 9.1e-31 ... so they can be utilized? "0.148*speed_of_light^2"
Hi, can u please add Maximum, Minimum Functions? For Example: max(1,3) + 7 // return 10 min(5,0) + 10 //return 10 or if possible: max(1,2,3,4,5) + 1 //return 6 //x=1...
I would like to run my own functions in evaluations. E.g.: ``` function doSomething($x) { ... return $answer; } ``` ``` $AST = $parser->parse('doSomething(x)'); $evaluator->setVariables([ 'x' => 2 ]); $value...
Hello and thank you for publishing the package. I've been trying [pow()](https://www.php.net/manual/fr/function.pow.php) and [log()](https://www.php.net/manual/fr/function.log.php) with two parameters but the , returned the Unknown token exception. The [**](https://www.php.net/manual/en/language.operators.arithmetic.php) operator returned a...
`"1+.1"` (or `".1"`) triggers an exception saying `Unknown token 0 encountered`. Maybe add some parsing logic to say "if period, assume a zero to the left"? So that `"1+.1"` is...
I have added some more code / test to make the library support boolean operators and comparison operators: !, &&, ||, =, = These operators are required for one of...
I needed something like the expression tree in math.js (https://mathjs.org/docs/expressions/expression_trees.html) to extract all variables from an expression. Like: ```php $formula = '(a+b)*c'; $variables = magic($formula); print_r($variables); // ['a','b','c'] ``` Unfortunately,...