Skip to content

Latest commit

 

History

History
121 lines (106 loc) · 7.83 KB

index.md

File metadata and controls

121 lines (106 loc) · 7.83 KB
layout title
default
Home

An extensive math library for JavaScript and Node.js #

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices. Powerful and easy to use.

Features #

  • Supports numbers, big numbers, bigint, complex numbers, fractions, units, strings, arrays, and matrices.
  • Is compatible with JavaScript's built-in Math library.
  • Contains a flexible expression parser.
  • Does symbolic computation.
  • Comes with a large set of built-in functions and constants.
  • Can be used as a command line application as well.
  • Runs on any JavaScript engine.
  • Is easily extensible.
  • Open source.

Example #

Here some example code demonstrating how to use the library. Click here to fiddle around.

// functions and constants
math.round(math.e, 3)                // 2.718
math.atan2(3, -3) / math.pi          // 0.75
math.log(10000, 10)                  // 4
math.sqrt(-4)                        // 2i
math.derivative('x^2 + x', 'x')      // 2*x+1
math.pow([[-1, 2], [3, 1]], 2)
     // [[7, 0], [0, 7]]

// expressions math.evaluate('1.2 * (2 + 4.5)') // 7.8 math.evaluate('12.7 cm to inch') // 5 inch math.evaluate('sin(45 deg) ^ 2') // 0.5 math.evaluate('9 / 3 + 2i') // 3 + 2i math.evaluate('det([-1, 2; 3, 1])') // -7

// chaining math.chain(3) .add(4) .multiply(2) .done() // 14

Demo #

Try the expression parser below.
See Math Notepad for a full application.

loading...
Shortcut keys:
  • Press S to set focus to the input field
  • Press Ctrl+F11 to toggle full screen
  • Press Tab to autocomplete (repeat to cycle choices)
  • Enter "clear" to clear history
 
<iframe src="https://ghbtns.com/github-btn.html?user=josdejong&repo=mathjs&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
Tweet <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<script src="//platform.linkedin.com/in.js" type="text/javascript"></script> <script type="IN/Share" data-url="https://mathjs.org" data-counter="right"></script>
<script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.4&appId=537047263003274"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
Sponsored by LambdaTest