mathjs/test/test.min.html

40 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>mathjs test</title>
<script src="../math.min.js" type="text/javascript"></script>
</head>
<body>
<p>
Use the mathjs library from the console...
</p>
<script>
function print (args) {
for (var i = 0; i < arguments.length; i++) {
document.write(arguments[i] + '');
}
document.write('<br>');
}
var complex1 = math.complex(3, -4);
print(complex1.toString());
print('sqrt(25) = ' + math.sqrt(25));
print('sqrt(' + complex1.toString() + ') = ' + math.sqrt(complex1));
print('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');
print('a = ' + workspace.getResult(id0));
print('a + 2 = ' + workspace.getResult(id1));
workspace.replace('a=5/2', id0);
print('a = ' + workspace.getResult(id0));
print('a + 2 = ' + workspace.getResult(id1));
</script>
</body>
</html>