mathjs/test/test.html
2013-03-19 20:34:21 +01:00

45 lines
1.4 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 Complex = math.Complex;
var Unit = math.Unit;
var complex1 = new 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 = new math.parser.Parser();
var workspace = new math.parser.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(new Unit('0.01m').toString());
console.log(new Unit('1m').toString());
console.log(new Unit('10m').toString());
console.log(new Unit('100m').toString());
console.log(new Unit('500m').toString());
console.log(new Unit('800m').toString());
console.log(new Unit('1000m').toString());
console.log(new Unit('1100m').toString());
</script>
</body>
</html>