/
algebrite4test.html
246 lines (242 loc) · 8.51 KB
/
algebrite4test.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Algebrite - CAS Editor</title>
<link rel='stylesheet' href='css/bootstrap.css'>
<link rel='stylesheet' href='css/bootstrap-theme.css'>
<link rel='stylesheet' href='css/app.css'>
<script src="js/algebrite4browser.js"></script>
<script src="js/jquery.js"></script>
<script src="js/plotly.js"></script>
<script src="js/closingbracket.js"></script>
<script src="./mathjax/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script>
<script src="js/jsoneditor.min.js"></script>
<script type="text/javascript">
JSONEditor.defaults.theme = 'bootstrap3';
JSONEditor.defaults.iconlib = 'icons4menu';
</script>
</head>
<body>
<h1>JSON Editor: Algebrite for Browser</h1>
<div>Using this editor you can test the algebraic computation within the JSON editor. You can check available algebra commmands on <a href="http://algebrite.org/" target="_blank">Algebrite</a>.</div>
<div id='editor_holder'></div>
<button id='submit'>Submit (console.log)</button>
<script>
// Initialize the editor with a JSON schema
var editor = new JSONEditor(document.getElementById('editor_holder'),{
"schema": {
"type": "cas",
"title": "Algebrite Demo",
"options":{
"enable_search":true,
"enable_preview_edit_button":true,
"enable_preview":true,
"enable_execute_button": true,
"title4functions": "Definierte Funktionen",
"title4variables": "Definierte Variablen"
},
"default":{
"castype": "maxima",
"commands": [
{
"cmdtitle": "Define a Constant",
"cmd": "c1:=12!",
"result4cmd": ""
},
{
"cmdtitle": "Define Function f(x):=x^2",
"cmd": "f(x):=x^2 + c1",
"result4cmd": "f(x):=x^2"
},
{
"cmdtitle": "Evaluate Function f(4)",
"cmd": "f(4)",
"result4cmd": "f(4)"
},
{
"cmdtitle": "Plot plot2d(f(x)",
"cmd": "plot2d(f(x),x[-5,5])",
"result4cmd": "PLOT2D f(x)"
},
{
"cmdtitle": "Plot plot2d(h(x)",
"cmd": "plot2d(h(x),x[-5,5])",
"result4cmd": "PLOT2D h(x)"
},
{
"cmdtitle": "Plot plot2d(f(x),h(x))",
"cmd": "plot2d(f(x),h(x),x[-5,5])",
"result4cmd": "PLOT2D"
},
{
"cmdtitle": "Define Function g(x,y)",
"cmd": "g(x,y):=x^2+y^2",
"result4cmd": "g(x,y):=x^2+y^2"
},
{
"cmdtitle": "Plot plot3d(g(x,y)",
"cmd": "plot3d(g(x,y),x[-5,5],y[-4,6])",
"result4cmd": "PLOT3D"
},
{
"cmdtitle": "Plot curve2d() - Spiral",
"cmd": "curve2d([t*cos(t),t*sin(t),t],t[0,16],color[green],linewidth[3])",
"result4cmd": "CURVE2D"
},
{
"cmdtitle": "Plot curve3d() - cur(t)",
"cmd": "curve3d(cur(t),t[0,15],color[blue],linewidth[5])",
"result4cmd": "PLOT3D"
},
{
"cmdtitle": "Plot curve3d() with term",
"cmd": "curve3d([cos(t),sin(t),t],[sin(t),cos(t),t],t[0,15],color[#78AC54])",
"result4cmd": "PLOT3D"
},
{
"cmdtitle": "Expand Function g(3,4):=(5)^2+(4)^2",
"cmd": "g(3,4)",
"result4cmd": "\\mbox{expand to }3^2+4^2 \\mbox{ compute solution.}"
},
{
"cmdtitle": "Expand nested Function g(f(5),b):=(5^2)^2+b^2",
"cmd": "g(f(5),b)",
"result4cmd": "\\mbox{expand to }5^2\\mbox{ compute solution.}"
},
{
"cmdtitle": "Plot plot3d(g(x,y)",
"cmd": "plot3d(g(x,y),x[-5,5],y[-3,8])",
"result4cmd": "PLOT3D"
},
{
"cmdtitle": "Sum of two integer",
"cmd": "3+4*5",
"result4cmd": ""
},
{
"cmdtitle": "Symbolic Caluculation x+x",
"cmd": "x+x",
"result4cmd": "2 \cdot x"
},
{
"cmdtitle": "Faculty 11! with comments",
"cmd": "11! # gets long after 50000!",
"result4cmd": ""
},
{
"cmdtitle": "Evaluate/Expand Function f(5):=5^2",
"cmd": "f(5)",
"result4cmd": "\\mbox{expand to }5^2\\mbox{ compute solution.}"
},
{
"cmdtitle": "factorize 100!",
"cmd": "factor(100!)",
"result4cmd": ""
},
{
"cmdtitle": "Fraction Calculations",
"cmd": "13579/99999 + 13580/100000\nnumerator(1/a+1/b)\ndenominator(1/(x-1)/(x-2))\nrationalize(a/b+b/a)",
"result4cmd": ""
},
{
"cmdtitle": "Calculation complex functions",
"cmd": "A=1+i\nB=sqrt(2)*exp(i*pi/8)\nA-B\nrect",
"result4cmd": ""
},
{
"cmdtitle": "simplify functions",
"cmd": "simplify(cos(x)^2 + sin(x)^2)\nsimplify(a*b+a*c)\nsimplify(n!/(n+1)!)",
"result4cmd": ""
},
{
"cmdtitle": "expand (x-1)*(x-2)",
"cmd": "(x-1)*(x-2)^3",
"result4cmd": ""
},
{
"cmdtitle": "solve equations",
"cmd": "roots(3 x + 12 + y = 24) # first degree (in x)\nroots(a*x^2+b*x+c) # second degree",
"result4cmd": ""
},
{
"cmdtitle": "Roots of Polnomials",
"cmd": "nroots(x^16+x^15+2)",
"result4cmd": ""
},
{
"cmdtitle": "# Define a Tensor",
"cmd": "# Define a tensor function\nF=[x+2y,3x+4y]\n# now the gradient\nd(F,[x,y])",
"result4cmd": ""
},
{
"cmdtitle": "Gradients and derivatives",
"cmd": "d(x^2)\n# gradients are derivatives on vectors\nr=sqrt(x^2+y^2)\nd(r,[x,y])",
"result4cmd": ""
},
{
"cmdtitle": "Integrals",
"cmd": "integral(x^2)\nintegral(x*y,x,y)",
"result4cmd": ""
},
{
"cmdtitle": "Integrals with limits",
"cmd": "# compute integrals\ndefint(x^2,y,0,sqrt(1-x^2),x,-1,1)",
"result4cmd": ""
},
{
"cmdtitle": "Calculations in exponential domain",
"cmd": "#calculating in an exponential domain\nf=sin(t)^4-2*cos(t/2)^3*sin(t)\nf=circexp(f)\ndefint(f,t,0,2*pi)",
"result4cmd": ""
}
],
"casfunctions": [
{
"name":"g",
"args":"x,y",
"def":"x^3+y^4"
},
{
"name":"f",
"args":"x",
"def":"x^5"
},
{
"name":"h",
"args":"x",
"def":"1000*sin(x)"
},
{
"name":"cur",
"args":"t",
"def":"[cos(t),sin(t),t]"
}
],
"casvariables": [
{
"name":"c1",
"def":"x^3+y^4"
},
{
"name":"c2",
"def":"23^5-4+sin(13)"
},
{
"name":"c3",
"def":"f1(x)"
}
]
}
}
});
// Hook up the submit button to log to the console
document.getElementById('submit').addEventListener('click',function() {
// Get the value from the editor
console.log(JSON.stringify(editor.getValue(),null,4));
});
document.addEventListener('load', function(){
MathJax.typeset()
})
</script>
</body>
</html>