UNPKG

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