MathExt

26 Apr 2010 | By Alex Young | Tags mathematics libraries

MathExt is a JavaScript library for parsing mathematical formulas by Lars Knickrehm. It has a very advanced and flexible API, allowing configuration over accuracy, separators, and the radix character. It supports things like hyperbolic functions, trigonometric functions, and has translations for English and German.

Loading the required files and performing a calculation looks like this:

<script src="MathExt.Actions.min.js"  type="text/javascript"></script>
<script src="MathExt.Class.min.js" type="text/javascript"></script>
<script src="MathExt.Load.min.js" type="text/javascript"></script>
<script type="text/javascript">
    var oMathExt = MathExt.Load();
    oMathExt.Calculate('cos(8) * π');
</script>

It’s clever enough to get the precedence correct:

oMathExt.Calculate('cos 8 * π');

The scientific-calculator interface shown above can be found in the project’s documentation. It uses explorercanvas, which means it works in IE too.


blog comments powered by Disqus