This repository has been archived by the owner on Jan 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emgiac.html
115 lines (109 loc) · 4.32 KB
/
emgiac.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
Webxcas
</title>
<style>
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
canvas.emscripten { border: 1px solid black; }
textarea.emscripten { font-family: monospace; width: 80%; }
div.emscripten { text-align: center; }
</style>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>
<body>
<canvas id='canvas' width=1 height=1></canvas>
This is a simple front-end to the emgiac math core (<a href="http://www-fourier.ujf-grenoble.fr/~parisse/giac/emgiac.tgz">Giac/Xcas</a> compiled to JS by emscripten) for testing purposes.
<br>
<b>Examples of input:</b> <br>
<tt> factor(x^4-1); cfactor(x^2+1); normal((x+1)^4)
<br> solve(x^2-3*x+2=0); csolve(x^2=2*i); solve([x+y=1,x-y=3],[x,y])
<br> simplify(sin(3x)/sin(x)); gcd(x^4-1,x^3-1)
<br> f(x):=sin(x^2):; f(sqrt(pi)); f'(2); f'(y)
<br> int(1/(x^4-1)); int(1/(x^4+1)^4,x,0,+infinity)
<br> limit(sin(x)/x,x=0); series(sin(x),x=0,5);
<br> A:=[[1,2],[3,4]]; inv(A); det(A-x*idn(A)); A[0,0]; rref(A); eigenvalues(A); eigenvectors(A);
</tt>
<br>
Build is based on Giac/Xcas, (c) B. Parisse, R. De Graeve, Institut Fourier, Université de Grenoble I., licensed under the GPL3.
<hr>
<form onsubmit="setTimeout(function() {
if(window.worker_ready) {
var to_send = { value: entree.value, load: false };
window.worker.postMessage(JSON.stringify(to_send));
}});
return false;">
Input: <input type="text" name="entree" value="factor(x^4-1)">
<input type="submit" value="Go!">
</form>
<hr/>
<div class="emscripten" id="status">Downloading...</div>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
</div>
<hr/>
<textarea class="emscripten" id="output" rows="8"></textarea>
<hr/>
<hr>
<script type='text/javascript'>
window.worker = false;
window.worker_ready = false;
$(function() {
var element = document.getElementById('output');
element.value = ''; // clear browser cache
var handleResponse = function(message) {
var text = message.value
switch(message.command) {
case 'print':
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/</g, "<");
//text = text.replace(/>/g, ">");
//text = text.replace('\n', '<br>', 'g');
element.value += text + "\n";
element.scrollTop = 99999; // focus on bottom
break;
case 'printErr':
if (0) { // XXX disabled for safety typeof dump == 'function') {
dump(text + '\n'); // fast, straight to the real console
} else {
console.log(text);
}
break;
case 'setStatus':
if(text === '') window.worker_ready = true;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
}
statusElement.innerHTML = text;
break;
}
}
if(typeof(Worker) !== "undefined") {
var useWASM = confirm("Defaulting to the WASM version. Click cancel to use ASM.JS");
window.worker = new Worker("webworker.js");
window.worker.addEventListener("message", function (evt) {
handleResponse(JSON.parse(evt.data));
},false);
var to_send = { load: true, useWASM: useWASM };
window.worker.postMessage(JSON.stringify(to_send));
} else {
alert("Sorry! No Web Worker support.");
}
});
</script>
<!--- <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas> --->
</body>
</html>