-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
79 lines (74 loc) · 2.42 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://fred-wang.github.io/mathml.css/mspace.js"></script>
<script>
// see https://github.com/fred-wang/mathml.css/pull/9
window.setTimeout(function () {
var link = document.head.querySelector('link[href="http://fred-wang.github.io/mathml.css/mathml.css"]');
if (link != null) {
link.href = 'https://fred-wang.github.io/mathml.css/mathml.css';
}
}, 300);
</script>
<script type="module">
alert()
import {
primeFactor,
nthRoot,
Expression,
toDecimalStringInternal,
NonSimplifiedExpression,
ExpressionParser,
Polynomial,
Matrix,
Condition
} from './index.js'
self.primeFactor = primeFactor;
self.nthRoot = nthRoot;
self.Expression = Expression;
self.toDecimalStringInternal = toDecimalStringInternal;
self.NonSimplifiedExpression = NonSimplifiedExpression;
self.ExpressionParser = ExpressionParser;
self.Polynomial = Polynomial;
self.Matrix = Matrix;
self.Condition = Condition;
document.addEventListener('DOMContentLoaded', function () {
document.querySelector('form').onsubmit = function (event) {
event.preventDefault();
var sourceCode = document.querySelector('textarea').value;
eval(sourceCode);
};
document.querySelector('form').onsubmit(new Event('submit'));
});
</script>
<style>
textarea {
width: 100%;
height: 240px;
}
#output {
text-align: center; /* also fixed <mfrac> for mathml.css */
}
</style>
</head>
<body>
<form>
<textarea wrap="off" autocapitalize="off" autocomplete="off">
var matrix = ExpressionParser.parse('{{1,2,3},{4,5,6},{7,8,9}}').matrix;
var x = Expression.getEigenvalues(matrix);
var multiplicities = x.multiplicities;
var eigenvalues = x.eigenvalues;
var eigenvectors = Expression.getEigenvectors(matrix, x.eigenvalues).eigenvectors;
var y = Expression.getFormaDeJordan(matrix, eigenvalues, multiplicities, eigenvectors);
var po = {useMatrixContainer: false};
document.getElementById("output").innerHTML = "<math>" + new Expression.Matrix(matrix).toMathML(po) + "<mo>=</mo>" + new Expression.Matrix(y.P).toMathML(po) + "<mo>×</mo>" + new Expression.Matrix(y.J).toMathML(po) + "<mo>×</mo>" + new Expression.Matrix(y.P_INVERSED).toMathML(po) + "</math>";
</textarea>
<button type="submit">eval</button>
<div id="output">
</div>
</form>
You could also play with the API in the browser console.
</body>
</html>