mathjs/test/test.html

42 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>mathjs test</title>
<script src="../math.js" type="text/javascript"></script>
</head>
<body>
<p>
Use the mathjs library from the console...
</p>
<script>
var complex1 = math.complex(3, -4);
console.log(complex1.toString());
console.log('sqrt(25) = ' + math.sqrt(25));
console.log('sqrt(' + complex1.toString() + ') = ' + math.sqrt(complex1));
console.log('sqrt(-4) = ' + math.sqrt(-4));
var parser = math.parser();
var workspace = math.workspace();
var id0 = workspace.append('a = 3/4');
var id1 = workspace.append('a + 2');
console.log('a = ' + workspace.getResult(id0));
console.log('a + 2 = ' + workspace.getResult(id1));
workspace.replace('a=5/2', id0);
console.log('a = ' + workspace.getResult(id0));
console.log('a + 2 = ' + workspace.getResult(id1));
console.log(math.unit('0.01m').toString());
console.log(math.unit('1m').toString());
console.log(math.unit('10m').toString());
console.log(math.unit('100m').toString());
console.log(math.unit('500m').toString());
console.log(math.unit('800m').toString());
console.log(math.unit('1000m').toString());
console.log(math.unit('1100m').toString());
</script>
</body>
</html>