mathai 0.7.0__tar.gz → 0.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. mathai-0.7.2/PKG-INFO +293 -0
  2. mathai-0.7.2/README.md +278 -0
  3. mathai-0.7.2/mathai/expand.py +175 -0
  4. mathai-0.7.2/mathai.egg-info/PKG-INFO +293 -0
  5. {mathai-0.7.0 → mathai-0.7.2}/setup.py +1 -2
  6. mathai-0.7.0/PKG-INFO +0 -234
  7. mathai-0.7.0/README.md +0 -217
  8. mathai-0.7.0/mathai/expand.py +0 -95
  9. mathai-0.7.0/mathai.egg-info/PKG-INFO +0 -234
  10. {mathai-0.7.0 → mathai-0.7.2}/mathai/__init__.py +0 -0
  11. {mathai-0.7.0 → mathai-0.7.2}/mathai/apart.py +0 -0
  12. {mathai-0.7.0 → mathai-0.7.2}/mathai/base.py +0 -0
  13. {mathai-0.7.0 → mathai-0.7.2}/mathai/bivariate_inequality.py +0 -0
  14. {mathai-0.7.0 → mathai-0.7.2}/mathai/console.py +0 -0
  15. {mathai-0.7.0 → mathai-0.7.2}/mathai/diff.py +0 -0
  16. {mathai-0.7.0 → mathai-0.7.2}/mathai/factor.py +0 -0
  17. {mathai-0.7.0 → mathai-0.7.2}/mathai/fraction.py +0 -0
  18. {mathai-0.7.0 → mathai-0.7.2}/mathai/integrate.py +0 -0
  19. {mathai-0.7.0 → mathai-0.7.2}/mathai/inverse.py +0 -0
  20. {mathai-0.7.0 → mathai-0.7.2}/mathai/limit.py +0 -0
  21. {mathai-0.7.0 → mathai-0.7.2}/mathai/linear.py +0 -0
  22. {mathai-0.7.0 → mathai-0.7.2}/mathai/logic.py +0 -0
  23. {mathai-0.7.0 → mathai-0.7.2}/mathai/matrix.py +0 -0
  24. {mathai-0.7.0 → mathai-0.7.2}/mathai/ode.py +0 -0
  25. {mathai-0.7.0 → mathai-0.7.2}/mathai/parser.py +0 -0
  26. {mathai-0.7.0 → mathai-0.7.2}/mathai/parsetab.py +0 -0
  27. {mathai-0.7.0 → mathai-0.7.2}/mathai/printeq.py +0 -0
  28. {mathai-0.7.0 → mathai-0.7.2}/mathai/simplify.py +0 -0
  29. {mathai-0.7.0 → mathai-0.7.2}/mathai/structure.py +0 -0
  30. {mathai-0.7.0 → mathai-0.7.2}/mathai/tool.py +0 -0
  31. {mathai-0.7.0 → mathai-0.7.2}/mathai/trig.py +0 -0
  32. {mathai-0.7.0 → mathai-0.7.2}/mathai/univariate_inequality.py +0 -0
  33. {mathai-0.7.0 → mathai-0.7.2}/mathai.egg-info/SOURCES.txt +0 -0
  34. {mathai-0.7.0 → mathai-0.7.2}/mathai.egg-info/dependency_links.txt +0 -0
  35. {mathai-0.7.0 → mathai-0.7.2}/mathai.egg-info/requires.txt +0 -0
  36. {mathai-0.7.0 → mathai-0.7.2}/mathai.egg-info/top_level.txt +0 -0
  37. {mathai-0.7.0 → mathai-0.7.2}/setup.cfg +0 -0
mathai-0.7.2/PKG-INFO ADDED
@@ -0,0 +1,293 @@
1
+ Metadata-Version: 2.4
2
+ Name: mathai
3
+ Version: 0.7.2
4
+ Summary: Mathematics solving Ai tailored to NCERT
5
+ Home-page: https://github.com/infinity390/mathai4
6
+ Requires-Python: >=3.7
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: lark-parser
9
+ Dynamic: description
10
+ Dynamic: description-content-type
11
+ Dynamic: home-page
12
+ Dynamic: requires-dist
13
+ Dynamic: requires-python
14
+ Dynamic: summary
15
+
16
+ # Math AI Documentation
17
+ ## Source
18
+ Github repository of the code
19
+ https://github.com/infinity390/mathai4
20
+
21
+ ## Philosophy
22
+ I think it is a big realization in computer science and programming to realize that computers can solve mathematics.
23
+ This understanding should be made mainstream. It can help transform education, mathematical research, and computation of mathematical equations for work.
24
+
25
+ ## Societal Implications Of Such A Computer Program And The Author's Comment On Universities Of India
26
+ I think mathematics is valued by society because of education. Schools and universities teach them.
27
+ So this kind of software, if made mainstream, could bring real change.
28
+
29
+ ## The Summary Of How Computer "Solves" Math
30
+ Math equations are a tree data structure (`TreeNode` class).
31
+ We can manipulate the math equations using various algorithms (functions provided by the `mathai` library).
32
+ We first parse the math equation strings to get the tree data structure (`parse` function in `mathai`).
33
+
34
+ ## The Library
35
+ Import the library by doing:
36
+
37
+ ```python
38
+ from mathai import *
39
+ ```
40
+
41
+ ### str_form
42
+ It is the string representation of a `TreeNode` math equation.
43
+
44
+ #### Example
45
+ ```text
46
+ (cos(x)^2)+(sin(x)^2)
47
+ ```
48
+
49
+ Is represented internally as:
50
+
51
+ ```text
52
+ f_add
53
+ f_pow
54
+ f_cos
55
+ v_0
56
+ d_2
57
+ f_pow
58
+ f_sin
59
+ v_0
60
+ d_2
61
+ ```
62
+
63
+ #### Leaf Nodes
64
+
65
+ **Variables** (start with a `v_` prefix):
66
+
67
+ - `v_0` -> x
68
+ - `v_1` -> y
69
+ - `v_2` -> z
70
+ - `v_3` -> a
71
+
72
+ **Numbers** (start with `d_` prefix; only integers):
73
+
74
+ - `d_-1` -> -1
75
+ - `d_0` -> 0
76
+ - `d_1` -> 1
77
+ - `d_2` -> 2
78
+
79
+ #### Branch Nodes
80
+ - `f_add` -> addition
81
+ - `f_mul` -> multiplication
82
+ - `f_pow` -> power
83
+
84
+ ### parse
85
+ Takes a math equation string and outputs a `TreeNode` object.
86
+
87
+ ```python
88
+ from mathai import *
89
+
90
+ equation = parse("sin(x)^2+cos(x)^2")
91
+ print(equation)
92
+ ```
93
+
94
+ #### Output
95
+ ```text
96
+ (cos(x)^2)+(sin(x)^2)
97
+ ```
98
+
99
+ ### solve, simplify
100
+ It simplifies and cleans up a given math equation.
101
+
102
+ ```python
103
+ from mathai import *
104
+
105
+ equation = simplify(parse("(x+x+x+x-1-1-1-1)*(4*x-4)*sin(sin(x+x+x)*sin(3*x))"))
106
+ printeq(equation)
107
+ ```
108
+
109
+ #### Output
110
+ ```text
111
+ ((-4+(4*x))^2)*sin((sin((3*x))^2))
112
+ ```
113
+
114
+ ### Incomplete Documentation, Will be updated and completed later on
115
+
116
+ ### Demonstrations
117
+
118
+ #### Example Demonstration 1 (absolute value inequalities)
119
+ ```python
120
+ from mathai import *
121
+ question_list_from_lecture = [
122
+ "2*x/(2*x^2 + 5*x + 2) > 1/(x + 1)",
123
+ "(x + 2)*(x + 3)/((x - 2)*(x - 3)) <= 1",
124
+ "(5*x - 1) < (x + 1)^2 & (x + 1)^2 < 7*x - 3",
125
+ "(2*x - 1)/(2*x^3 + 3*x^2 + x) > 0",
126
+ "abs(x + 5)*x + 2*abs(x + 7) - 2 = 0",
127
+ "x*abs(x) - 5*abs(x + 2) + 6 = 0",
128
+ "x^2 - abs(x + 2) + x > 0",
129
+ "abs(abs(x - 2) - 3) <= 2",
130
+ "abs(3*x - 5) + abs(8 - x) = abs(3 + 2*x)",
131
+ "abs(x^2 + 5*x + 9) < abs(x^2 + 2*x + 2) + abs(3*x + 7)"
132
+ ]
133
+
134
+ for item in question_list_from_lecture:
135
+ eq = simplify(parse(item))
136
+ eq = dowhile(eq, absolute)
137
+ eq = simplify(factor1(fraction(eq)))
138
+ eq = prepare(eq)
139
+ eq = factor2(eq)
140
+ c = wavycurvy(eq & domain(eq)).fix()
141
+ print(c)
142
+ ```
143
+ #### Output
144
+
145
+ ```
146
+ (-2,-1)U(-(2/3),-(1/2))
147
+ (-inf,0)U(2,3)U{0}
148
+ (2,4)
149
+ (-inf,-1)U(-(1/2),0)U(1/2,+inf)
150
+ {-4,-3,-(3/2)-(sqrt(57)/2)}
151
+ {-1,(5/2)-(sqrt(89)/2),(5/2)+(sqrt(41)/2)}
152
+ (-inf,-sqrt(2))U((2*sqrt(2))/2,+inf)
153
+ (-3,1)U(3,7)U{1,-3,7,3}
154
+ (5/3,8)U{5/3,8}
155
+ (-inf,-(7/3))
156
+ ```
157
+
158
+ #### Example Demonstration 2 (trigonometry)
159
+ ```python
160
+ from mathai import *
161
+ def nested_func(eq_node):
162
+ eq_node = fraction(eq_node)
163
+ eq_node = simplify(eq_node)
164
+ eq_node = trig1(eq_node)
165
+ eq_node = trig0(eq_node)
166
+ return eq_node
167
+ for item in ["(cosec(x)-cot(x))^2=(1-cos(x))/(1+cos(x))", "cos(x)/(1+sin(x)) + (1+sin(x))/cos(x) = 2*sec(x)",\
168
+ "tan(x)/(1-cot(x)) + cot(x)/(1-tan(x)) = 1 + sec(x)*cosec(x)", "(1+sec(x))/sec(x) = sin(x)^2/(1-cos(x))",\
169
+ "(cos(x)-sin(x)+1)/(cos(x)+sin(x)-1) = cosec(x)+cot(x)"]:
170
+ eq = logic0(dowhile(parse(item), nested_func))
171
+ print(eq)
172
+ ```
173
+ #### Output
174
+
175
+ ```
176
+ true
177
+ true
178
+ true
179
+ true
180
+ true
181
+ ```
182
+
183
+ #### Example Demonstration 3 (integration)
184
+ ```python
185
+ from mathai import *
186
+
187
+ eq = simplify(parse("integrate(2*x/(x^2+1),x)"))
188
+ eq = integrate_const(eq)
189
+ eq = integrate_fraction(eq)
190
+ print(simplify(fraction(simplify(eq))))
191
+
192
+ eq = simplify(parse("integrate(sin(cos(x))*sin(x),x)"))
193
+ eq = integrate_subs(eq)
194
+ eq = integrate_const(eq)
195
+ eq = integrate_formula(eq)
196
+ eq = integrate_clean(eq)
197
+ print(simplify(eq))
198
+
199
+ eq = simplify(parse("integrate(x*sqrt(x+2),x)"))
200
+ eq = integrate_subs(eq)
201
+ eq = integrate_const(eq)
202
+ eq = integrate_formula(eq)
203
+ eq = expand(eq)
204
+ eq = integrate_const(eq)
205
+ eq = integrate_summation(eq)
206
+ eq = simplify(eq)
207
+ eq = integrate_const(eq)
208
+ eq = integrate_formula(eq)
209
+ eq = integrate_clean(eq)
210
+ print(simplify(fraction(simplify(eq))))
211
+
212
+ eq = simplify(parse("integrate(x/(e^(x^2)),x)"))
213
+ eq = integrate_subs(eq)
214
+ eq = integrate_const(eq)
215
+ eq = integrate_formula(eq)
216
+ eq = simplify(eq)
217
+ eq = integrate_formula(eq)
218
+ eq = integrate_clean(eq)
219
+ print(simplify(eq))
220
+
221
+ eq = fraction(trig0(trig1(simplify(parse("integrate(sin(x)^4,x)")))))
222
+ eq = integrate_const(eq)
223
+ eq = integrate_summation(eq)
224
+ eq = integrate_formula(eq)
225
+ eq = integrate_const(eq)
226
+ eq = integrate_formula(eq)
227
+ print(factor0(simplify(fraction(simplify(eq)))))
228
+ ```
229
+ #### Output
230
+
231
+ ```
232
+ log(abs((1+(x^2))))
233
+ cos(cos(x))
234
+ ((6*((2+x)^(5/2)))-(20*((2+x)^(3/2))))/15
235
+ -((e^-(x^2))/2)
236
+ -(((8*sin((2*x)))-(12*x)-sin((4*x)))/32)
237
+ ```
238
+
239
+ #### Example Demonstration 4 (derivation of hydrogen atom's ground state energy in electron volts using the variational principle in quantum physics)
240
+ ```python
241
+ from mathai import *;
242
+ def auto_integration(eq):
243
+ for _ in range(3):
244
+ eq=dowhile(integrate_subs(eq),lambda x:integrate_summation(integrate_const(integrate_formula(simplify(expand(x))))));
245
+ out=integrate_clean(copy.deepcopy(eq));
246
+ if "f_integrate" not in str_form(out):return dowhile(out,lambda x:simplify(fraction(x)));
247
+ eq=integrate_byparts(eq);
248
+ return eq;
249
+ z,k,m,e1,hbar=map(lambda s:simplify(parse(s)),["1","8987551787","9109383701*10^(-40)","1602176634*10^(-28)","1054571817*10^(-43)"]);
250
+ pi,euler,r=tree_form("s_pi"),tree_form("s_e"),parse("r");a0=hbar**2/(k*e1**2*m);psi=((z**3/(pi*a0**3)).fx("sqrt"))*euler**(-(z/a0)*r);
251
+ laplace_psi=diff(r**2*diff(psi,r.name),r.name)/r**2;V=-(k*z*e1**2)/r;Hpsi=-hbar**2/(2*m)*laplace_psi+V*psi;
252
+ norm=lambda f:simplify(
253
+ limit3(limit2(expand(TreeNode("f_limitpinf",[auto_integration(TreeNode("f_integrate",[f*parse("4")*pi*r**2,r])),r]))))
254
+ -limit1(TreeNode("f_limit",[auto_integration(TreeNode("f_integrate",[f*parse("4")*pi*r**2,r])),r]))
255
+ );
256
+ print(compute(norm(psi*Hpsi)/(norm(psi**2)*e1)));
257
+ ```
258
+ #### Output
259
+
260
+ ```
261
+ -13.605693122882867
262
+ ```
263
+
264
+ #### Example Demonstration 5 (boolean algebra)
265
+ ```python
266
+ from mathai import *
267
+ print(logic_n(simplify(parse("~(p<->q)<->(~p<->q)"))))
268
+ print(logic_n(simplify(parse("(p->q)<->(~q->~p)"))))
269
+ ```
270
+ #### Output
271
+
272
+ ```
273
+ true
274
+ true
275
+ ```
276
+
277
+ #### Example Demonstration 6 (limits)
278
+ ```python
279
+ from mathai import *
280
+ limits = ["(e^(tan(x)) - 1 - tan(x)) / x^2", "sin(x)/x", "(1-cos(x))/x^2", "(sin(x)-x)/sin(x)^3"]
281
+ for q in limits:
282
+ q = fraction(simplify(TreeNode("f_limit",[parse(q),parse("x")])))
283
+ q = limit1(q)
284
+ print(q)
285
+ ```
286
+ #### Output
287
+
288
+ ```
289
+ 1/2
290
+ 1
291
+ 1/2
292
+ -(1/6)
293
+ ```
mathai-0.7.2/README.md ADDED
@@ -0,0 +1,278 @@
1
+ # Math AI Documentation
2
+ ## Source
3
+ Github repository of the code
4
+ https://github.com/infinity390/mathai4
5
+
6
+ ## Philosophy
7
+ I think it is a big realization in computer science and programming to realize that computers can solve mathematics.
8
+ This understanding should be made mainstream. It can help transform education, mathematical research, and computation of mathematical equations for work.
9
+
10
+ ## Societal Implications Of Such A Computer Program And The Author's Comment On Universities Of India
11
+ I think mathematics is valued by society because of education. Schools and universities teach them.
12
+ So this kind of software, if made mainstream, could bring real change.
13
+
14
+ ## The Summary Of How Computer "Solves" Math
15
+ Math equations are a tree data structure (`TreeNode` class).
16
+ We can manipulate the math equations using various algorithms (functions provided by the `mathai` library).
17
+ We first parse the math equation strings to get the tree data structure (`parse` function in `mathai`).
18
+
19
+ ## The Library
20
+ Import the library by doing:
21
+
22
+ ```python
23
+ from mathai import *
24
+ ```
25
+
26
+ ### str_form
27
+ It is the string representation of a `TreeNode` math equation.
28
+
29
+ #### Example
30
+ ```text
31
+ (cos(x)^2)+(sin(x)^2)
32
+ ```
33
+
34
+ Is represented internally as:
35
+
36
+ ```text
37
+ f_add
38
+ f_pow
39
+ f_cos
40
+ v_0
41
+ d_2
42
+ f_pow
43
+ f_sin
44
+ v_0
45
+ d_2
46
+ ```
47
+
48
+ #### Leaf Nodes
49
+
50
+ **Variables** (start with a `v_` prefix):
51
+
52
+ - `v_0` -> x
53
+ - `v_1` -> y
54
+ - `v_2` -> z
55
+ - `v_3` -> a
56
+
57
+ **Numbers** (start with `d_` prefix; only integers):
58
+
59
+ - `d_-1` -> -1
60
+ - `d_0` -> 0
61
+ - `d_1` -> 1
62
+ - `d_2` -> 2
63
+
64
+ #### Branch Nodes
65
+ - `f_add` -> addition
66
+ - `f_mul` -> multiplication
67
+ - `f_pow` -> power
68
+
69
+ ### parse
70
+ Takes a math equation string and outputs a `TreeNode` object.
71
+
72
+ ```python
73
+ from mathai import *
74
+
75
+ equation = parse("sin(x)^2+cos(x)^2")
76
+ print(equation)
77
+ ```
78
+
79
+ #### Output
80
+ ```text
81
+ (cos(x)^2)+(sin(x)^2)
82
+ ```
83
+
84
+ ### solve, simplify
85
+ It simplifies and cleans up a given math equation.
86
+
87
+ ```python
88
+ from mathai import *
89
+
90
+ equation = simplify(parse("(x+x+x+x-1-1-1-1)*(4*x-4)*sin(sin(x+x+x)*sin(3*x))"))
91
+ printeq(equation)
92
+ ```
93
+
94
+ #### Output
95
+ ```text
96
+ ((-4+(4*x))^2)*sin((sin((3*x))^2))
97
+ ```
98
+
99
+ ### Incomplete Documentation, Will be updated and completed later on
100
+
101
+ ### Demonstrations
102
+
103
+ #### Example Demonstration 1 (absolute value inequalities)
104
+ ```python
105
+ from mathai import *
106
+ question_list_from_lecture = [
107
+ "2*x/(2*x^2 + 5*x + 2) > 1/(x + 1)",
108
+ "(x + 2)*(x + 3)/((x - 2)*(x - 3)) <= 1",
109
+ "(5*x - 1) < (x + 1)^2 & (x + 1)^2 < 7*x - 3",
110
+ "(2*x - 1)/(2*x^3 + 3*x^2 + x) > 0",
111
+ "abs(x + 5)*x + 2*abs(x + 7) - 2 = 0",
112
+ "x*abs(x) - 5*abs(x + 2) + 6 = 0",
113
+ "x^2 - abs(x + 2) + x > 0",
114
+ "abs(abs(x - 2) - 3) <= 2",
115
+ "abs(3*x - 5) + abs(8 - x) = abs(3 + 2*x)",
116
+ "abs(x^2 + 5*x + 9) < abs(x^2 + 2*x + 2) + abs(3*x + 7)"
117
+ ]
118
+
119
+ for item in question_list_from_lecture:
120
+ eq = simplify(parse(item))
121
+ eq = dowhile(eq, absolute)
122
+ eq = simplify(factor1(fraction(eq)))
123
+ eq = prepare(eq)
124
+ eq = factor2(eq)
125
+ c = wavycurvy(eq & domain(eq)).fix()
126
+ print(c)
127
+ ```
128
+ #### Output
129
+
130
+ ```
131
+ (-2,-1)U(-(2/3),-(1/2))
132
+ (-inf,0)U(2,3)U{0}
133
+ (2,4)
134
+ (-inf,-1)U(-(1/2),0)U(1/2,+inf)
135
+ {-4,-3,-(3/2)-(sqrt(57)/2)}
136
+ {-1,(5/2)-(sqrt(89)/2),(5/2)+(sqrt(41)/2)}
137
+ (-inf,-sqrt(2))U((2*sqrt(2))/2,+inf)
138
+ (-3,1)U(3,7)U{1,-3,7,3}
139
+ (5/3,8)U{5/3,8}
140
+ (-inf,-(7/3))
141
+ ```
142
+
143
+ #### Example Demonstration 2 (trigonometry)
144
+ ```python
145
+ from mathai import *
146
+ def nested_func(eq_node):
147
+ eq_node = fraction(eq_node)
148
+ eq_node = simplify(eq_node)
149
+ eq_node = trig1(eq_node)
150
+ eq_node = trig0(eq_node)
151
+ return eq_node
152
+ for item in ["(cosec(x)-cot(x))^2=(1-cos(x))/(1+cos(x))", "cos(x)/(1+sin(x)) + (1+sin(x))/cos(x) = 2*sec(x)",\
153
+ "tan(x)/(1-cot(x)) + cot(x)/(1-tan(x)) = 1 + sec(x)*cosec(x)", "(1+sec(x))/sec(x) = sin(x)^2/(1-cos(x))",\
154
+ "(cos(x)-sin(x)+1)/(cos(x)+sin(x)-1) = cosec(x)+cot(x)"]:
155
+ eq = logic0(dowhile(parse(item), nested_func))
156
+ print(eq)
157
+ ```
158
+ #### Output
159
+
160
+ ```
161
+ true
162
+ true
163
+ true
164
+ true
165
+ true
166
+ ```
167
+
168
+ #### Example Demonstration 3 (integration)
169
+ ```python
170
+ from mathai import *
171
+
172
+ eq = simplify(parse("integrate(2*x/(x^2+1),x)"))
173
+ eq = integrate_const(eq)
174
+ eq = integrate_fraction(eq)
175
+ print(simplify(fraction(simplify(eq))))
176
+
177
+ eq = simplify(parse("integrate(sin(cos(x))*sin(x),x)"))
178
+ eq = integrate_subs(eq)
179
+ eq = integrate_const(eq)
180
+ eq = integrate_formula(eq)
181
+ eq = integrate_clean(eq)
182
+ print(simplify(eq))
183
+
184
+ eq = simplify(parse("integrate(x*sqrt(x+2),x)"))
185
+ eq = integrate_subs(eq)
186
+ eq = integrate_const(eq)
187
+ eq = integrate_formula(eq)
188
+ eq = expand(eq)
189
+ eq = integrate_const(eq)
190
+ eq = integrate_summation(eq)
191
+ eq = simplify(eq)
192
+ eq = integrate_const(eq)
193
+ eq = integrate_formula(eq)
194
+ eq = integrate_clean(eq)
195
+ print(simplify(fraction(simplify(eq))))
196
+
197
+ eq = simplify(parse("integrate(x/(e^(x^2)),x)"))
198
+ eq = integrate_subs(eq)
199
+ eq = integrate_const(eq)
200
+ eq = integrate_formula(eq)
201
+ eq = simplify(eq)
202
+ eq = integrate_formula(eq)
203
+ eq = integrate_clean(eq)
204
+ print(simplify(eq))
205
+
206
+ eq = fraction(trig0(trig1(simplify(parse("integrate(sin(x)^4,x)")))))
207
+ eq = integrate_const(eq)
208
+ eq = integrate_summation(eq)
209
+ eq = integrate_formula(eq)
210
+ eq = integrate_const(eq)
211
+ eq = integrate_formula(eq)
212
+ print(factor0(simplify(fraction(simplify(eq)))))
213
+ ```
214
+ #### Output
215
+
216
+ ```
217
+ log(abs((1+(x^2))))
218
+ cos(cos(x))
219
+ ((6*((2+x)^(5/2)))-(20*((2+x)^(3/2))))/15
220
+ -((e^-(x^2))/2)
221
+ -(((8*sin((2*x)))-(12*x)-sin((4*x)))/32)
222
+ ```
223
+
224
+ #### Example Demonstration 4 (derivation of hydrogen atom's ground state energy in electron volts using the variational principle in quantum physics)
225
+ ```python
226
+ from mathai import *;
227
+ def auto_integration(eq):
228
+ for _ in range(3):
229
+ eq=dowhile(integrate_subs(eq),lambda x:integrate_summation(integrate_const(integrate_formula(simplify(expand(x))))));
230
+ out=integrate_clean(copy.deepcopy(eq));
231
+ if "f_integrate" not in str_form(out):return dowhile(out,lambda x:simplify(fraction(x)));
232
+ eq=integrate_byparts(eq);
233
+ return eq;
234
+ z,k,m,e1,hbar=map(lambda s:simplify(parse(s)),["1","8987551787","9109383701*10^(-40)","1602176634*10^(-28)","1054571817*10^(-43)"]);
235
+ pi,euler,r=tree_form("s_pi"),tree_form("s_e"),parse("r");a0=hbar**2/(k*e1**2*m);psi=((z**3/(pi*a0**3)).fx("sqrt"))*euler**(-(z/a0)*r);
236
+ laplace_psi=diff(r**2*diff(psi,r.name),r.name)/r**2;V=-(k*z*e1**2)/r;Hpsi=-hbar**2/(2*m)*laplace_psi+V*psi;
237
+ norm=lambda f:simplify(
238
+ limit3(limit2(expand(TreeNode("f_limitpinf",[auto_integration(TreeNode("f_integrate",[f*parse("4")*pi*r**2,r])),r]))))
239
+ -limit1(TreeNode("f_limit",[auto_integration(TreeNode("f_integrate",[f*parse("4")*pi*r**2,r])),r]))
240
+ );
241
+ print(compute(norm(psi*Hpsi)/(norm(psi**2)*e1)));
242
+ ```
243
+ #### Output
244
+
245
+ ```
246
+ -13.605693122882867
247
+ ```
248
+
249
+ #### Example Demonstration 5 (boolean algebra)
250
+ ```python
251
+ from mathai import *
252
+ print(logic_n(simplify(parse("~(p<->q)<->(~p<->q)"))))
253
+ print(logic_n(simplify(parse("(p->q)<->(~q->~p)"))))
254
+ ```
255
+ #### Output
256
+
257
+ ```
258
+ true
259
+ true
260
+ ```
261
+
262
+ #### Example Demonstration 6 (limits)
263
+ ```python
264
+ from mathai import *
265
+ limits = ["(e^(tan(x)) - 1 - tan(x)) / x^2", "sin(x)/x", "(1-cos(x))/x^2", "(sin(x)-x)/sin(x)^3"]
266
+ for q in limits:
267
+ q = fraction(simplify(TreeNode("f_limit",[parse(q),parse("x")])))
268
+ q = limit1(q)
269
+ print(q)
270
+ ```
271
+ #### Output
272
+
273
+ ```
274
+ 1/2
275
+ 1
276
+ 1/2
277
+ -(1/6)
278
+ ```