1 | <!DOCTYPE html>
|
2 | <html>
|
3 | <head>
|
4 | <title>mathjs test</title>
|
5 |
|
6 | <script src="../dist/math.js" type="text/javascript"></script>
|
7 | </head>
|
8 | <body>
|
9 | <p>
|
10 | Use the mathjs library from the console...
|
11 | </p>
|
12 | <script>
|
13 |
|
14 | math.config({
|
15 | number: 'BigNumber'
|
16 | });
|
17 |
|
18 | function print (args) {
|
19 | for (var i = 0; i < arguments.length; i++) {
|
20 | document.write(arguments[i] + '');
|
21 | }
|
22 | document.write('<br>');
|
23 | }
|
24 |
|
25 | var complex1 = math.complex(3, -4);
|
26 | print(complex1.toString());
|
27 |
|
28 | print('sqrt(25) = ' + math.sqrt(25));
|
29 | print('sqrt(' + complex1.toString() + ') = ' + math.sqrt(complex1));
|
30 | print('sqrt(-4) = ' + math.sqrt(-4));
|
31 |
|
32 | var parser = math.parser();
|
33 |
|
34 | print(math.unit('0.01m').toString());
|
35 | print(math.unit('1m').toString());
|
36 | print(math.unit('10m').toString());
|
37 | print(math.unit('100m').toString());
|
38 | print(math.unit('500m').toString());
|
39 | print(math.unit('800m').toString());
|
40 | print(math.unit('1000m').toString());
|
41 | print(math.unit('1100m').toString());
|
42 |
|
43 | print(parser.eval('a=[1,2,3;4,5,6]'));
|
44 | var a = parser.get('a');
|
45 |
|
46 | print(parser.eval('a[2,1:2]'));
|
47 | print(parser.eval('b=2.3'));
|
48 | print(parser.eval('b + 2'));
|
49 | print(parser.eval('0.1 + 0.2'));
|
50 |
|
51 | </script>
|
52 | </body>
|
53 | </html> |
\ | No newline at end of file |