Spaces:
Runtime error
Runtime error
Delete Artificial_Calc_Teacher_v1.9.ipynb
Browse files
Artificial_Calc_Teacher_v1.9.ipynb
DELETED
@@ -1,198 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "raw",
|
5 |
-
"id": "8c69730d",
|
6 |
-
"metadata": {},
|
7 |
-
"source": [
|
8 |
-
"---\n",
|
9 |
-
"title: Artificial Calculus Teacher\n",
|
10 |
-
"description: Generates Derivative and Integral Expressions\n",
|
11 |
-
"show-code : False\n",
|
12 |
-
"---"
|
13 |
-
]
|
14 |
-
},
|
15 |
-
{
|
16 |
-
"cell_type": "code",
|
17 |
-
"execution_count": null,
|
18 |
-
"id": "c5197005",
|
19 |
-
"metadata": {},
|
20 |
-
"outputs": [],
|
21 |
-
"source": [
|
22 |
-
"# changelog: added spoiler button"
|
23 |
-
]
|
24 |
-
},
|
25 |
-
{
|
26 |
-
"cell_type": "code",
|
27 |
-
"execution_count": 3,
|
28 |
-
"id": "108761f9",
|
29 |
-
"metadata": {
|
30 |
-
"scrolled": false
|
31 |
-
},
|
32 |
-
"outputs": [
|
33 |
-
{
|
34 |
-
"name": "stdout",
|
35 |
-
"output_type": "stream",
|
36 |
-
"text": [
|
37 |
-
"Solve\n"
|
38 |
-
]
|
39 |
-
},
|
40 |
-
{
|
41 |
-
"data": {
|
42 |
-
"text/latex": [
|
43 |
-
"$\\displaystyle \\frac{d}{d x} x^{2} \\left(x + 2\\right)^{2}$"
|
44 |
-
],
|
45 |
-
"text/plain": [
|
46 |
-
"Derivative(x**2*(x + 2)**2, x)"
|
47 |
-
]
|
48 |
-
},
|
49 |
-
"metadata": {},
|
50 |
-
"output_type": "display_data"
|
51 |
-
},
|
52 |
-
{
|
53 |
-
"data": {
|
54 |
-
"text/latex": [
|
55 |
-
"$\\displaystyle \\int e^{\\sqrt[3]{x}}\\, dx$"
|
56 |
-
],
|
57 |
-
"text/plain": [
|
58 |
-
"Integral(exp(x**(1/3)), x)"
|
59 |
-
]
|
60 |
-
},
|
61 |
-
"metadata": {},
|
62 |
-
"output_type": "display_data"
|
63 |
-
},
|
64 |
-
{
|
65 |
-
"data": {
|
66 |
-
"application/vnd.jupyter.widget-view+json": {
|
67 |
-
"model_id": "c2b4df5f615f4ab6a6a36f56511f9205",
|
68 |
-
"version_major": 2,
|
69 |
-
"version_minor": 0
|
70 |
-
},
|
71 |
-
"text/plain": [
|
72 |
-
"interactive(children=(Button(description='Show Solutions', style=ButtonStyle()), Output()), _dom_classes=('wid…"
|
73 |
-
]
|
74 |
-
},
|
75 |
-
"metadata": {},
|
76 |
-
"output_type": "display_data"
|
77 |
-
},
|
78 |
-
{
|
79 |
-
"name": "stdout",
|
80 |
-
"output_type": "stream",
|
81 |
-
"text": [
|
82 |
-
"-----------------------------------------------------------------------------------------------------------\n"
|
83 |
-
]
|
84 |
-
}
|
85 |
-
],
|
86 |
-
"source": [
|
87 |
-
"import ipywidgets as widgets\n",
|
88 |
-
"from ipywidgets import interact, interact_manual, fixed\n",
|
89 |
-
"from sympy.simplify.fu import TR22\n",
|
90 |
-
"from sympy import sin,cos,ln,exp,tan,Function,Derivative,Eq,Integral,Rational\n",
|
91 |
-
"from sympy import factor_terms,simplify, sqrt, cbrt\n",
|
92 |
-
"from sympy.abc import x\n",
|
93 |
-
"import random\n",
|
94 |
-
"f = Function('f')\n",
|
95 |
-
"g = Function('g')\n",
|
96 |
-
"h = Function('h')\n",
|
97 |
-
"def random_math(x):\n",
|
98 |
-
" allowed_values = list(range(2, 6))\n",
|
99 |
-
" random_value = random.choice(allowed_values)\n",
|
100 |
-
" random_value\n",
|
101 |
-
" def power_function(x): \n",
|
102 |
-
" return x**random_value\n",
|
103 |
-
" def scalar_function(x):\n",
|
104 |
-
" return x*random_value\n",
|
105 |
-
" def addSUBTR_function(x): \n",
|
106 |
-
" return x+random_value\n",
|
107 |
-
" funs = [sin,power_function,ln,exp,cos,tan,sqrt,cbrt,\n",
|
108 |
-
" scalar_function,addSUBTR_function] \n",
|
109 |
-
" operations = [f(g(x)),f(x)+g(x),f(x)-g(x),f(x)/g(x),f(x)*g(x), f(x)/g(x)/h(x),f(x)*g(h(x)),\n",
|
110 |
-
" f(g(h(x))),f(h(x))+g(x),f(h(x))-g(x),f(h(x))/g(x),f(x)/g(h(x)),f(h(x))*g(x), f(x)*g(x)*h(x)]\n",
|
111 |
-
" operation = operations[random.randrange(0,len(operations))]\n",
|
112 |
-
" return [[[operation.replace(f, i) for i in funs][random.randrange(0,len(funs))].replace(g, i) for i in funs]\\\n",
|
113 |
-
"[random.randrange(0,len(funs))].replace(h, i) for i in funs][random.randrange(0,len(funs))]\n",
|
114 |
-
"\n",
|
115 |
-
"def random_math2(x):\n",
|
116 |
-
" allowed_values = list(range(2, 6))\n",
|
117 |
-
" random_value = random.choice(allowed_values)\n",
|
118 |
-
" random_value\n",
|
119 |
-
" def power_function(x): \n",
|
120 |
-
" return x**random_value\n",
|
121 |
-
" def scalar_function(x):\n",
|
122 |
-
" return x*random_value\n",
|
123 |
-
" def addSUBTR_function(x): \n",
|
124 |
-
" return x+random_value\n",
|
125 |
-
" funs = [sin,power_function,ln,exp,cos,tan,sqrt,cbrt,\n",
|
126 |
-
" scalar_function,addSUBTR_function] \n",
|
127 |
-
" operations = [f(g(x)),f(x)+g(x),f(x)-g(x),f(x)/g(x),f(x)*g(x)]\n",
|
128 |
-
" operation = operations[random.randrange(0,len(operations))]\n",
|
129 |
-
" return [[operation.replace(f, i) for i in funs][random.randrange(0,len(funs))].replace(g, i) for i in funs]\\\n",
|
130 |
-
"[random.randrange(0,len(funs))]\n",
|
131 |
-
"setup1 = random_math(x)\n",
|
132 |
-
"setup2 = random_math2(x)\n",
|
133 |
-
"practice1 = Derivative(simplify(setup1),x)\n",
|
134 |
-
"practice2 = Integral(simplify(setup2),x)\n",
|
135 |
-
"p1eq = Eq(practice1,practice1.doit(),evaluate=False)\n",
|
136 |
-
"p2eq = Eq(practice2,practice2.doit().simplify(),evaluate=False)\n",
|
137 |
-
"print(\"Solve\")\n",
|
138 |
-
"display(p1eq.lhs)\n",
|
139 |
-
"if str(factor_terms(p2eq.lhs)) != str(p2eq.rhs): \n",
|
140 |
-
" if str(p2eq).find(\"Ei\") == -1 and str(p2eq).find(\"gamma\") == -1 and str(p2eq).find(\"Piecewise\") == -1\\\n",
|
141 |
-
" and str(p2eq).find(\"li\") == -1 and str(p2eq).find(\"erf\") == -1 and str(p2eq).find(\"atan\") == -1\\\n",
|
142 |
-
" and str(p2eq).find(\"Si\") == -1 and str(p2eq).find(\"Ci\") == -1 and str(p2eq).find(\"hyper\") == -1\\\n",
|
143 |
-
" and str(p2eq).find(\"fresnel\") == -1 and str(p2eq).find(\"Li\") == -1: \n",
|
144 |
-
" display(p2eq.lhs)\n",
|
145 |
-
" else:\n",
|
146 |
-
" print(\"Error: Complex Integral\")\n",
|
147 |
-
" pass\n",
|
148 |
-
"\n",
|
149 |
-
"else:\n",
|
150 |
-
" print(\"Error: Impossible Integral\") \n",
|
151 |
-
" pass\n",
|
152 |
-
"\n",
|
153 |
-
"\n",
|
154 |
-
"@widgets.interact.options(manual=True, manual_name=\"Show Solutions\") \n",
|
155 |
-
"def displayer():\n",
|
156 |
-
" display(TR22(p1eq))\n",
|
157 |
-
" display(TR22(p2eq))\n",
|
158 |
-
" \n",
|
159 |
-
"print(\"-----------------------------------------------------------------------------------------------------------\")"
|
160 |
-
]
|
161 |
-
},
|
162 |
-
{
|
163 |
-
"cell_type": "markdown",
|
164 |
-
"id": "b3f5b9fb",
|
165 |
-
"metadata": {},
|
166 |
-
"source": [
|
167 |
-
"If LaTeX display breaks, refresh the page.\n",
|
168 |
-
"\n",
|
169 |
-
"Helpful resources: https://www.derivative-calculator.net/ & https://www.integral-calculator.com/ \n",
|
170 |
-
"\n",
|
171 |
-
"**Made by github.com/nsc9 - MIT License**\n",
|
172 |
-
"\n",
|
173 |
-
"Donate by sending Bitcoin (BTC) to address: **bc1qtawr2gw52ftufzu0r3r20pnj3vmynssxs0mjl4**"
|
174 |
-
]
|
175 |
-
}
|
176 |
-
],
|
177 |
-
"metadata": {
|
178 |
-
"kernelspec": {
|
179 |
-
"display_name": "Python 3 (ipykernel)",
|
180 |
-
"language": "python",
|
181 |
-
"name": "python3"
|
182 |
-
},
|
183 |
-
"language_info": {
|
184 |
-
"codemirror_mode": {
|
185 |
-
"name": "ipython",
|
186 |
-
"version": 3
|
187 |
-
},
|
188 |
-
"file_extension": ".py",
|
189 |
-
"mimetype": "text/x-python",
|
190 |
-
"name": "python",
|
191 |
-
"nbconvert_exporter": "python",
|
192 |
-
"pygments_lexer": "ipython3",
|
193 |
-
"version": "3.8.10"
|
194 |
-
}
|
195 |
-
},
|
196 |
-
"nbformat": 4,
|
197 |
-
"nbformat_minor": 5
|
198 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|