mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
48 lines
1.5 KiB
HTML
48 lines
1.5 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 Matrix = math.Matrix;
|
|
var Vector = math.Vector;
|
|
var Range = math.Range;
|
|
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> |