This Gist was automatically created by Carbide, a free online programming environment.
Last active
November 12, 2016 16:30
-
-
Save harrysarson/a80cb3778d58accfb61b048ad4513c8c to your computer and use it in GitHub Desktop.
Basic Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const math = require('mathjs'); | |
/// Functions and Constants | |
math.round(math.e, 3); | |
math.atan2(3, -3) / math.pi; | |
math.log(10000, 10); | |
math.sqrt(-4); | |
math.pow([[-1, 2], [3, 1]], 2); | |
/// Expresions | |
math.eval('1.2 * (2 + 4.5)'); | |
math.eval('5.08 cm to inch'); | |
math.eval('sin(45 deg) ^ 2'); | |
math.eval('9 / 3 + 2i'); | |
math.eval('det([-1, 2; 3, 1])'); | |
///Chained Operations | |
math.chain(2.4219) | |
.add(4) | |
.multiply(2) | |
.done(); | |
/// Mixed Types | |
math.add(4, [5, 6]); // number + Array | |
math.multiply(math.unit('5 mm'), 3).toString(); // Unit * number | |
math.subtract([2, 3, 4], 5); // Array - number | |
math.add(math.matrix([2, 3]), [4, 5]).toArray(); // Matrix + Array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment