NSC9 commited on
Commit
0d357ca
1 Parent(s): 929fd2d

Delete Artificial_Calc_Teacher_v7.8.ipynb

Browse files
Files changed (1) hide show
  1. Artificial_Calc_Teacher_v7.8.ipynb +0 -340
Artificial_Calc_Teacher_v7.8.ipynb DELETED
@@ -1,340 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "eefbb211",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import mercury as mr\n",
11
- " \n",
12
- "# set Application parameters\n",
13
- "app = mr.App(title=\"Calculus Problem Generator\",\n",
14
- " description=\"Generates expressions which students can apply differential and integral calculus to.\",\n",
15
- " show_code=False,\n",
16
- " show_prompt=False,\n",
17
- " continuous_update=True,\n",
18
- " static_notebook=False,\n",
19
- " show_sidebar=True,\n",
20
- " full_screen=True,\n",
21
- " allow_download=False)"
22
- ]
23
- },
24
- {
25
- "cell_type": "code",
26
- "execution_count": null,
27
- "id": "9258ca84",
28
- "metadata": {},
29
- "outputs": [],
30
- "source": [
31
- "equation_count = 0"
32
- ]
33
- },
34
- {
35
- "cell_type": "code",
36
- "execution_count": null,
37
- "id": "81f9af3c",
38
- "metadata": {},
39
- "outputs": [],
40
- "source": [
41
- "generate = mr.Button(label=\"New equation\")"
42
- ]
43
- },
44
- {
45
- "cell_type": "code",
46
- "execution_count": 1,
47
- "id": "c5197005",
48
- "metadata": {},
49
- "outputs": [],
50
- "source": [
51
- "# changelog: updated code to work with updated Mercury. (button works again!)"
52
- ]
53
- },
54
- {
55
- "cell_type": "markdown",
56
- "id": "6bdf2faf",
57
- "metadata": {},
58
- "source": [
59
- "# Solve with pen and paper:"
60
- ]
61
- },
62
- {
63
- "cell_type": "code",
64
- "execution_count": 28,
65
- "id": "108761f9",
66
- "metadata": {
67
- "scrolled": false
68
- },
69
- "outputs": [
70
- {
71
- "data": {
72
- "text/latex": [
73
- "$\\displaystyle \\frac{d}{d \\theta} \\left(\\sin{\\left(\\theta \\right)} + \\tan{\\left(\\theta \\right)} + 2\\right) = ?$"
74
- ],
75
- "text/plain": [
76
- "Eq(Derivative(sin(theta) + tan(theta) + 2, theta), ?)"
77
- ]
78
- },
79
- "metadata": {},
80
- "output_type": "display_data"
81
- },
82
- {
83
- "data": {
84
- "text/latex": [
85
- "$\\displaystyle \\int \\left(- \\sqrt{y} + e^{y}\\right)\\, dy = ?$"
86
- ],
87
- "text/plain": [
88
- "Eq(Integral(-sqrt(y) + exp(y), y), ?)"
89
- ]
90
- },
91
- "metadata": {},
92
- "output_type": "display_data"
93
- },
94
- {
95
- "name": "stdout",
96
- "output_type": "stream",
97
- "text": [
98
- "\n",
99
- "\n",
100
- "\n",
101
- "\n",
102
- "\n",
103
- "\n",
104
- "\n",
105
- "\n",
106
- "\n",
107
- "\n",
108
- "Possible answers:\n"
109
- ]
110
- },
111
- {
112
- "data": {
113
- "text/latex": [
114
- "$\\displaystyle \\frac{d}{d \\theta} \\left(\\sin{\\left(\\theta \\right)} + \\tan{\\left(\\theta \\right)} + 2\\right) = \\cos{\\left(\\theta \\right)} + \\sec^{2}{\\left(\\theta \\right)}$"
115
- ],
116
- "text/plain": [
117
- "Eq(Derivative(sin(theta) + tan(theta) + 2, theta), cos(theta) + sec(theta)**2)"
118
- ]
119
- },
120
- "metadata": {},
121
- "output_type": "display_data"
122
- },
123
- {
124
- "data": {
125
- "text/latex": [
126
- "$\\displaystyle \\int \\left(- \\sqrt{y} + e^{y}\\right)\\, dy = - \\frac{2 y^{\\frac{3}{2}}}{3} + e^{y}$"
127
- ],
128
- "text/plain": [
129
- "Eq(Integral(-sqrt(y) + exp(y), y), -2*y**(3/2)/3 + exp(y))"
130
- ]
131
- },
132
- "metadata": {},
133
- "output_type": "display_data"
134
- }
135
- ],
136
- "source": [
137
- "from sympy.simplify.fu import TR22,TR2i\n",
138
- "from sympy import *\n",
139
- "from sympy.abc import theta\n",
140
- "import random\n",
141
- "f = Function('f')\n",
142
- "g = Function('g')\n",
143
- "h = Function('h')\n",
144
- "theta = Symbol('theta')\n",
145
- "i = 0\n",
146
- "dkeywords = {\"polylog\",\"Ei\",\"gamma\",\"Piecewise\",\"li\",\"erf\",\"Si\",\"Ci\",\"hyper\",\"fresnel\",\"Li\",\"expint\",\"zoo\",\n",
147
- "\"nan\",\"oo\",\"abs\",\"re\",\"EulerGamma\", \"sinh\",\"tanh\", \"cosh\",'sign','abs','atan','csc','asin'} \n",
148
- "ikeywords = {\"polylog\",\"Ei\",\"gamma\",\"Piecewise\", \"li\", \"erf\", \"atan\", \"Si\", \"Ci\", \"hyper\", \"fresnel\", \"Li\", \n",
149
- "\"expint\",\"zoo\", \"nan\", \"oo\",\"EulerGamma\",\"sinh\",\"csc\",\"asin\"}\n",
150
- "keywords2 = {\"sin\",\"cos\",\"tan\"}\n",
151
- "def random_variable(i):\n",
152
- " return Symbol(random.choice([i for i in ['v','t','x','z','y']]), real=True)\n",
153
- "def random_value(i):\n",
154
- " return random.choice([i for i in range(-10,10) if i not in [0]])\n",
155
- "def power(a): \n",
156
- " return random_value(i)*a**int(random_value(i)/2)\n",
157
- "def scalar(a): \n",
158
- " return a*random_value(i) + random_value(i)\n",
159
- "def addSUBTR(a): \n",
160
- " return a+random_value(i)\n",
161
- "def dmain(a):\n",
162
- " def random_math(a): \n",
163
- " funs = [power,scalar,addSUBTR,power,scalar,addSUBTR,ln,exp,sin,cos,tan,sqrt] \n",
164
- " operations = [f(a)+g(a)+h(a),\n",
165
- " f(a)+g(a)-h(a),\n",
166
- " f(a)+g(a)*h(a),\n",
167
- " f(a)+g(a)/h(a),\n",
168
- " \n",
169
- " f(a)-g(a)+h(a),\n",
170
- " f(a)-g(a)-h(a),\n",
171
- " f(a)-g(a)*h(a),\n",
172
- " f(a)-g(a)/h(a),\n",
173
- "\n",
174
- " f(a)*g(a)+h(a),\n",
175
- " f(a)*g(a)-h(a),\n",
176
- " f(a)*g(a)*h(a),\n",
177
- " f(a)*g(a)/h(a), \n",
178
- " \n",
179
- " f(a)/g(a)+h(a),\n",
180
- " f(a)/g(a)-h(a),\n",
181
- " f(a)/g(a)*h(a),\n",
182
- " f(a)/g(a)/h(a), \n",
183
- "\n",
184
- " f(a)* ( g(a)+h(a) ),\n",
185
- " f(a)* ( g(a)-h(a) ),\n",
186
- " f(a)/ ( g(a)+h(a) ),\n",
187
- " f(a)/ ( g(a)-h(a) ),\n",
188
- " \n",
189
- " f(g(h(a))),\n",
190
- " f(h(a))+g(a),\n",
191
- " f(h(a))-g(a),\n",
192
- " f(h(a))*g(a),\n",
193
- " f(h(a))/g(a),\n",
194
- " f(a)/g(h(a))]\n",
195
- " operation = operations[random.randrange(0,len(operations))]\n",
196
- " return [[[operation.replace(f, i) for i in funs][random.randrange(0,len(funs))].replace(g, i) for i in funs]\\\n",
197
- " [random.randrange(0,len(funs))].replace(h, i) for i in funs][random.randrange(0,len(funs))]\n",
198
- " return random_math(a)\n",
199
- "def imain(a):\n",
200
- " def random_math2(a): \n",
201
- " funs = [power,scalar,addSUBTR,power,scalar,addSUBTR,ln,exp,sin,cos,tan,sqrt] \n",
202
- " operations = [f(g(a)),f(a)+g(a),f(a)-g(a),f(a)/g(a),f(a)*g(a)]\n",
203
- " operation = operations[random.randrange(0,len(operations))]\n",
204
- " return [[operation.replace(f, i) for i in funs][random.randrange(0,len(funs))].replace(g, i) for i in funs]\\\n",
205
- " [random.randrange(0,len(funs))]\n",
206
- " return random_math2(a)\n",
207
- "derror = True\n",
208
- "def dtest():\n",
209
- " global setup1\n",
210
- " global derror\n",
211
- " global practice1\n",
212
- " a = random_variable(i)\n",
213
- " setup1 = dmain(a)\n",
214
- " practice1 = Derivative(setup1,a) \n",
215
- " p1eq = TR22(Eq(practice1,practice1.doit(),evaluate=False))\n",
216
- " if any(kw in str(setup1) for kw in keywords2):\n",
217
- " setup1 = setup1.replace(a,theta)\n",
218
- " practice1 = Derivative(setup1,theta) \n",
219
- " p1eq = TR22(Eq(practice1,practice1.doit(),evaluate=False))\n",
220
- " if p1eq.rhs != 0 and not any(kw in str(p1eq) for kw in dkeywords):\n",
221
- " derror = False\n",
222
- " return p1eq\n",
223
- "while derror == True: \n",
224
- " output1 = dtest()\n",
225
- "ierror = True\n",
226
- "def itest():\n",
227
- " global ierror\n",
228
- " global practice2\n",
229
- " global setup2\n",
230
- " a = random_variable(i)\n",
231
- " setup2 = imain(a)\n",
232
- " practice2 = Integral(setup2,a) \n",
233
- " p2eq = TR22(Eq(practice2,practice2.doit(),evaluate=False))\n",
234
- " if str(factor_terms(p2eq.lhs)) != str(factor_terms(p2eq.rhs)) and not any(kw in str(p2eq) for kw in ikeywords)\\\n",
235
- " and str(p2eq.lhs) != str(-p2eq.rhs): \n",
236
- " if any(kw in str(setup2) for kw in keywords2):\n",
237
- " setup2 = setup2.replace(a,theta)\n",
238
- " practice2 = Integral(setup2,theta) \n",
239
- " p2eq = TR22(Eq(practice2,practice2.doit(),evaluate=False))\n",
240
- " ierror = False\n",
241
- " return p2eq\n",
242
- "while ierror == True:\n",
243
- " output2 = itest()\n",
244
- "questionmark = Symbol('?')\n",
245
- "def lhs():\n",
246
- " return display(Eq(nsimplify(output1.lhs),questionmark),Eq(nsimplify(output2.lhs),questionmark)) \n",
247
- "def rhs():\n",
248
- " return display(Eq(nsimplify(output1.lhs),nsimplify(output1.rhs)),Eq(nsimplify(output2.lhs),nsimplify(output2.rhs)))\n",
249
- "lhs()\n",
250
- "print(\"\\n\")\n",
251
- "print(\"\\n\")\n",
252
- "print(\"\\n\")\n",
253
- "print(\"\\n\")\n",
254
- "print(\"\\n\")\n",
255
- "print(\"Possible answers:\")\n",
256
- "rhs()\n",
257
- "if generate.clicked:\n",
258
- " equation_count += 1\n",
259
- " print(f\"Equation count {equation_count}\")"
260
- ]
261
- },
262
- {
263
- "cell_type": "markdown",
264
- "id": "2393180e",
265
- "metadata": {},
266
- "source": [
267
- "# Donate Bitcoin (BTC) to address: **bc1qtrjmtsfxhmjmu4wwdh03u92gpy662rnt3drlm7**\n",
268
- "\n",
269
- "**Created by https://github.com/NSC9 - Live @ https://nsc9.github.io/ - MIT License - v7.8**\n",
270
- "\n",
271
- "**Powered by https://huggingface.co & https://runmercury.com/**\n",
272
- "\n",
273
- "Latest version source code: https://github.com/NSC9/Sample_of_Work/tree/Main/Artificial_Calculus_Teacher\n",
274
- "\n",
275
- "**Below are the expressions in plain text format for easy copy/pasting into these calculus calculator websites if you get stuck:**"
276
- ]
277
- },
278
- {
279
- "cell_type": "code",
280
- "execution_count": 30,
281
- "id": "15c3f34f",
282
- "metadata": {},
283
- "outputs": [
284
- {
285
- "name": "stdout",
286
- "output_type": "stream",
287
- "text": [
288
- "Differentiate: sin(theta) + tan(theta) + 2\n",
289
- "Integrate: -sqrt(y) + exp(y)\n"
290
- ]
291
- }
292
- ],
293
- "source": [
294
- "keywords3 = {\"theta\"}\n",
295
- "if any(kw in str(nsimplify(output1.lhs)) for kw in keywords3):\n",
296
- " print(\"Differentiate:\",str(nsimplify(output1.lhs))[11:-8])\n",
297
- " p1 = \" \"+str(nsimplify(output1.lhs))[11:-8]\n",
298
- "else:\n",
299
- " print(\"Differentiate:\",str(nsimplify(output1.lhs))[11:-4])\n",
300
- " p1 = \" \"+str(nsimplify(output1.lhs))[11:-4]\n",
301
- " \n",
302
- "if any(kw in str(nsimplify(output2.lhs)) for kw in keywords3):\n",
303
- " print(\"Integrate:\",str(nsimplify(output2.lhs))[9:-8])\n",
304
- " p2 = \" \"+str(nsimplify(output2.lhs))[9:-8]\n",
305
- "else:\n",
306
- " print(\"Integrate:\",str(nsimplify(output2.lhs))[9:-4]) \n",
307
- " p2 = \" \"+str(nsimplify(output2.lhs))[9:-4]\n"
308
- ]
309
- },
310
- {
311
- "cell_type": "markdown",
312
- "id": "30b55c90",
313
- "metadata": {},
314
- "source": [
315
- "**https://www.derivative-calculator.net/ -- https://www.integral-calculator.com/**"
316
- ]
317
- }
318
- ],
319
- "metadata": {
320
- "kernelspec": {
321
- "display_name": "Python 3 (ipykernel)",
322
- "language": "python",
323
- "name": "python3"
324
- },
325
- "language_info": {
326
- "codemirror_mode": {
327
- "name": "ipython",
328
- "version": 3
329
- },
330
- "file_extension": ".py",
331
- "mimetype": "text/x-python",
332
- "name": "python",
333
- "nbconvert_exporter": "python",
334
- "pygments_lexer": "ipython3",
335
- "version": "3.10.6"
336
- }
337
- },
338
- "nbformat": 4,
339
- "nbformat_minor": 5
340
- }