1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="utf-8">
|
5 | <title>math.js | basic usage</title>
|
6 | <script src="../../lib/browser/math.js"></script>
|
7 | </head>
|
8 | <body>
|
9 |
|
10 | <script>
|
11 | function print(value) {
|
12 | const precision = 14
|
13 | document.write(math.format(value, precision) + '<br>')
|
14 | }
|
15 |
|
16 |
|
17 | print(math.round(math.e, 3))
|
18 | print(math.atan2(3, -3) / math.pi)
|
19 | print(math.log(10000, 10))
|
20 | print(math.sqrt(-4))
|
21 | print(math.pow([[-1, 2], [3, 1]], 2))
|
22 | print(math.derivative('x^2 + x', 'x'))
|
23 |
|
24 |
|
25 | print(math.evaluate('12 / (2.3 + 0.7)'))
|
26 | print(math.evaluate('12.7 cm to inch'))
|
27 | print(math.evaluate('9 / 3 + 2i'))
|
28 | print(math.evaluate('det([-1, 2; 3, 1])'))
|
29 |
|
30 |
|
31 | const a = math.chain(3)
|
32 | .add(4)
|
33 | .multiply(2)
|
34 | .done()
|
35 | print(a)
|
36 | </script>
|
37 |
|
38 | </body>
|
39 | </html> |
\ | No newline at end of file |