mathai 0.2.1__tar.gz → 0.2.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 (31) hide show
  1. mathai-0.2.2/PKG-INFO +231 -0
  2. mathai-0.2.2/README.md +214 -0
  3. {mathai-0.2.1 → mathai-0.2.2}/mathai/limit.py +2 -2
  4. mathai-0.2.2/mathai.egg-info/PKG-INFO +231 -0
  5. {mathai-0.2.1 → mathai-0.2.2}/setup.py +1 -1
  6. mathai-0.2.1/PKG-INFO +0 -24
  7. mathai-0.2.1/README.md +0 -7
  8. mathai-0.2.1/mathai.egg-info/PKG-INFO +0 -24
  9. {mathai-0.2.1 → mathai-0.2.2}/mathai/__init__.py +0 -0
  10. {mathai-0.2.1 → mathai-0.2.2}/mathai/apart.py +0 -0
  11. {mathai-0.2.1 → mathai-0.2.2}/mathai/base.py +0 -0
  12. {mathai-0.2.1 → mathai-0.2.2}/mathai/console.py +0 -0
  13. {mathai-0.2.1 → mathai-0.2.2}/mathai/diff.py +0 -0
  14. {mathai-0.2.1 → mathai-0.2.2}/mathai/expand.py +0 -0
  15. {mathai-0.2.1 → mathai-0.2.2}/mathai/factor.py +0 -0
  16. {mathai-0.2.1 → mathai-0.2.2}/mathai/fraction.py +0 -0
  17. {mathai-0.2.1 → mathai-0.2.2}/mathai/integrate.py +0 -0
  18. {mathai-0.2.1 → mathai-0.2.2}/mathai/inverse.py +0 -0
  19. {mathai-0.2.1 → mathai-0.2.2}/mathai/linear.py +0 -0
  20. {mathai-0.2.1 → mathai-0.2.2}/mathai/logic.py +0 -0
  21. {mathai-0.2.1 → mathai-0.2.2}/mathai/parser.py +0 -0
  22. {mathai-0.2.1 → mathai-0.2.2}/mathai/printeq.py +0 -0
  23. {mathai-0.2.1 → mathai-0.2.2}/mathai/simplify.py +0 -0
  24. {mathai-0.2.1 → mathai-0.2.2}/mathai/structure.py +0 -0
  25. {mathai-0.2.1 → mathai-0.2.2}/mathai/tool.py +0 -0
  26. {mathai-0.2.1 → mathai-0.2.2}/mathai/trig.py +0 -0
  27. {mathai-0.2.1 → mathai-0.2.2}/mathai.egg-info/SOURCES.txt +0 -0
  28. {mathai-0.2.1 → mathai-0.2.2}/mathai.egg-info/dependency_links.txt +0 -0
  29. {mathai-0.2.1 → mathai-0.2.2}/mathai.egg-info/requires.txt +0 -0
  30. {mathai-0.2.1 → mathai-0.2.2}/mathai.egg-info/top_level.txt +0 -0
  31. {mathai-0.2.1 → mathai-0.2.2}/setup.cfg +0 -0
mathai-0.2.2/PKG-INFO ADDED
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.2
2
+ Name: mathai
3
+ Version: 0.2.2
4
+ Summary: Mathematics solving Ai tailored to NCERT
5
+ Home-page: https://github.com/infinity390/mathai4
6
+ Author: educated indians are having a low iq and are good for nothing
7
+ Requires-Python: >=3.7
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: lark-parser
10
+ Dynamic: author
11
+ Dynamic: description
12
+ Dynamic: description-content-type
13
+ Dynamic: home-page
14
+ Dynamic: requires-dist
15
+ Dynamic: requires-python
16
+ Dynamic: summary
17
+
18
+ # Math AI Documentation
19
+
20
+ ## Philosophy
21
+ I think it is a big realization in computer science and programming to realize that computers can solve mathematics.
22
+ This understanding should be made mainstream. It can help transform education, mathematical research, and computation of mathematical equations for work.
23
+
24
+ ## Societal Implications Of Such A Computer Program And The Author's Comment On Universities Of India
25
+ I think mathematics is valued by society because of education. Schools and universities teach them.
26
+ So this kind of software, if made mainstream, could bring real change.
27
+
28
+ ### The Author's Comments On The Universities In His Country
29
+ > Educated Indians are having a low IQ and are good for nothing.
30
+ > The Indian Institute of Technology (IITs) graduates are the leader of the fools.
31
+ > Every educated Indian is beneath me.
32
+ > Now learn how this Python library can solve the math questions of your exams.
33
+
34
+ ## The Summary Of How Computer "Solves" Math
35
+ Math equations are a tree data structure (`TreeNode` class).
36
+ We can manipulate the math equations using various algorithms (functions provided by the `mathai` library).
37
+ We first parse the math equation strings to get the tree data structure (`parse` function in `mathai`).
38
+
39
+ ## The Library
40
+ Import the library by doing:
41
+
42
+ ```python
43
+ from mathai import *
44
+ ```
45
+
46
+ ### str_form
47
+ It is the string representation of a `TreeNode` math equation.
48
+
49
+ #### Example
50
+ ```text
51
+ (cos(x)^2)+(sin(x)^2)
52
+ ```
53
+
54
+ Is represented internally as:
55
+
56
+ ```text
57
+ f_add
58
+ f_pow
59
+ f_cos
60
+ v_0
61
+ d_2
62
+ f_pow
63
+ f_sin
64
+ v_0
65
+ d_2
66
+ ```
67
+
68
+ #### Leaf Nodes
69
+
70
+ **Variables** (start with a `v_` prefix):
71
+
72
+ - `v_0` → x
73
+ - `v_1` → y
74
+ - `v_2` → z
75
+ - `v_3` → a
76
+
77
+ **Numbers** (start with `d_` prefix; only integers):
78
+
79
+ - `d_-1` → -1
80
+ - `d_0` → 0
81
+ - `d_1` → 1
82
+ - `d_2` → 2
83
+
84
+ #### Branch Nodes
85
+ - `f_add` → addition
86
+ - `f_mul` → multiplication
87
+ - `f_pow` → power
88
+
89
+ ### parse
90
+ Takes a math equation string and outputs a `TreeNode` object.
91
+
92
+ ```python
93
+ from mathai import *
94
+
95
+ equation = parse("sin(x)^2+cos(x)^2")
96
+ print(equation)
97
+ ```
98
+
99
+ #### Output
100
+ ```text
101
+ (cos(x)^2)+(sin(x)^2)
102
+ ```
103
+
104
+ ### printeq, printeq_str, printeq_log
105
+ Prints math equations in a more readable form than usual `print`.
106
+
107
+ ```python
108
+ from mathai import *
109
+
110
+ equation = simplify(parse("(x+1)/x"))
111
+ print(equation)
112
+ printeq(equation)
113
+ ```
114
+
115
+ #### Output
116
+ ```text
117
+ (1+x)*(x^-1)
118
+ (1+x)/x
119
+ ```
120
+
121
+ ### solve, simplify
122
+ `simplify` performs what `solve` does and more.
123
+ It simplifies and cleans up a given math equation.
124
+
125
+ ```python
126
+ from mathai import *
127
+
128
+ equation = simplify(parse("(x+x+x+x-1-1-1-1)*(4*x-4)*sin(sin(x+x+x)*sin(3*x))"))
129
+ printeq(equation)
130
+ ```
131
+
132
+ #### Output
133
+ ```text
134
+ ((-4+(4*x))^2)*sin((sin((3*x))^2))
135
+ ```
136
+
137
+ ### Incomplete Documentation, Will be updated and completed later on
138
+
139
+ ### Example Demonstration [limits questions can also be solved other than this these, try limit()]
140
+ ![pip-install-mathai-mathematics-solving-ai-system-in-python-v0-xcg3c22k51sf1](https://github.com/user-attachments/assets/799f576f-27d0-4d7c-86e9-ad55ff221bcc)
141
+ ```python
142
+ import sys, os, time
143
+ from mathai import *
144
+
145
+ sys.setrecursionlimit(10000)
146
+
147
+ def integration_byparts(item): return simplify(fraction(simplify(byparts(simplify(parse(item)))[0])))
148
+ def integration_apart(item): return simplify(fraction(integrate(apart(factor2(simplify(parse(item)))))[0]))
149
+ def integration_direct(item): return simplify(fraction(simplify(integrate(simplify(parse(item)))[0])))
150
+ def integration_trig(item): return simplify(trig0(integrate(trig1(simplify(parse(item))))[0]))
151
+ def algebra(item): return logic0(simplify(expand(simplify(parse(item)))))
152
+ def trig_basic(item): return logic0(simplify(expand(trig3(simplify(parse(item))))))
153
+ def trig_advanced(item): return logic0(simplify(trig0(trig1(trig4(simplify(fraction(trig0(simplify(parse(item))))))))))
154
+
155
+ all_tasks = [
156
+ *[(item, trig_advanced) for item in [
157
+ "cos(x)/(1+sin(x)) + (1+sin(x))/cos(x) = 2*sec(x)",
158
+ "(1+sec(x))/sec(x) = sin(x)^2/(1-cos(x))"]],
159
+ *[(item, integration_byparts) for item in ["sin(x)*x","x*sin(3*x)","x*log(abs(x))","arctan(x)"]],
160
+ *[(item, integration_apart) for item in ["x/((x+1)*(x+2))","1/(x^2-9)"]],
161
+ *[(item, integration_direct) for item in [
162
+ "x*sqrt(x+2)","sin(cos(x))*sin(x)","2*x/(1+x^2)","sqrt(a*x+b)","cos(sqrt(x))/sqrt(x)","e^(arctan(x))/(1+x^2)","sqrt(sin(2*x))*cos(2*x"]],
163
+ *[(item, integration_trig) for item in ["sin(2*x+5)^2","sin(x)^4","cos(2*x)^4"]],
164
+ *[(item, algebra) for item in ["(x+1)^2 = x^2+2*x+1","(x+1)*(x-1) = x^2-1"]],
165
+ *[(item, trig_basic) for item in ["2*sin(x)*cos(x)=sin(2*x)"]],
166
+ ]
167
+
168
+ def run_task(task):
169
+ item, func = task
170
+ try: result = func(item)
171
+ except Exception as e: result = str(e)
172
+ return item, result
173
+
174
+ if __name__=="__main__":
175
+ print(f"Solving {len(all_tasks)} math questions...\n")
176
+ start_time = time.time()
177
+ for task in all_tasks:
178
+ item, result = run_task(task)
179
+ print(f"{item} => {result}\n")
180
+ print(f"All tasks completed in {time.time()-start_time:.2f} seconds")
181
+ ```
182
+ ### Output
183
+
184
+ ```
185
+ Running 21 tasks asynchronously on 8 cores...
186
+
187
+ x*log(abs(x)) => ((-2*(x^2))+(4*log(abs(x))*(x^2)))*(8^-1)
188
+
189
+ arctan(x) => (log((abs((1+(x^2)))^-1))+(2*arctan(x)*x))*(2^-1)
190
+
191
+ sin(cos(x))*sin(x) => cos(cos(x))
192
+
193
+ 1/(x^2-9) => (log(abs((-3+x)))+log((abs((3+x))^-1)))*(6^-1)
194
+
195
+ x/((x+1)*(x+2)) => log((abs((1+x))^-1))+log(((2+x)^2))
196
+
197
+ x*sin(3*x) => ((-9*cos((3*x))*x)+(3*sin((3*x))))*(27^-1)
198
+
199
+ (1+sec(x))/sec(x) = sin(x)^2/(1-cos(x)) => true
200
+
201
+ e^(arctan(x))/(1+x^2) => e^arctan(x)
202
+
203
+ cos(sqrt(x))/sqrt(x) => 2*sin((x^(2^-1)))
204
+
205
+ sqrt(a*x+b) => 2*(3^-1)*(((x*a)+b)^(3*(2^-1)))*(a^-1)
206
+
207
+ sin(x)*x => (-1*cos(x)*x)+sin(x)
208
+
209
+ (x+1)^2 = x^2+2*x+1 => true
210
+
211
+ (x+1)*(x-1) = x^2-1 => true
212
+
213
+ cos(x)/(1+sin(x)) + (1+sin(x))/cos(x) = 2*sec(x) => true
214
+
215
+ 2*sin(x)*cos(x)=sin(2*x) => true
216
+
217
+ sqrt(sin(2*x))*cos(2*x) => (3^-1)*(sin((2*x))^(3*(2^-1)))
218
+
219
+ 2*x/(1+x^2) => log(abs((1+(x^2))))
220
+
221
+ sin(2*x+5)^2 => ((-1*(4^-1)*sin((10+(4*x))))+x)*(2^-1)
222
+
223
+ cos(2*x)^4 => ((4^-1)*x)+((64^-1)*sin((8*x)))+((8^-1)*sin((4*x)))+((8^-1)*x)
224
+
225
+ x*sqrt(x+2) => ((-1*(4^-1)*((2+x)^(2+(2^-1))))+(-2*((2+x)^(2+(2^-1))))+(5*((2+x)^(1+(2^-1)))*x)+((2^-1)*((2+x)^(1+(2^-1)))*x)+((8^-1)*((2+x)^(1+(2^-1)))*x))*((1+(2^-1))^-3)*((2+(2^-1))^-1)
226
+
227
+ sin(x)^4 => (-1*(4^-1)*sin((2*x)))+((32^-1)*sin((4*x)))+((4^-1)*x)+((8^-1)*x)
228
+
229
+ All tasks completed in 129.78 seconds
230
+ ```
231
+
mathai-0.2.2/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # Math AI Documentation
2
+
3
+ ## Philosophy
4
+ I think it is a big realization in computer science and programming to realize that computers can solve mathematics.
5
+ This understanding should be made mainstream. It can help transform education, mathematical research, and computation of mathematical equations for work.
6
+
7
+ ## Societal Implications Of Such A Computer Program And The Author's Comment On Universities Of India
8
+ I think mathematics is valued by society because of education. Schools and universities teach them.
9
+ So this kind of software, if made mainstream, could bring real change.
10
+
11
+ ### The Author's Comments On The Universities In His Country
12
+ > Educated Indians are having a low IQ and are good for nothing.
13
+ > The Indian Institute of Technology (IITs) graduates are the leader of the fools.
14
+ > Every educated Indian is beneath me.
15
+ > Now learn how this Python library can solve the math questions of your exams.
16
+
17
+ ## The Summary Of How Computer "Solves" Math
18
+ Math equations are a tree data structure (`TreeNode` class).
19
+ We can manipulate the math equations using various algorithms (functions provided by the `mathai` library).
20
+ We first parse the math equation strings to get the tree data structure (`parse` function in `mathai`).
21
+
22
+ ## The Library
23
+ Import the library by doing:
24
+
25
+ ```python
26
+ from mathai import *
27
+ ```
28
+
29
+ ### str_form
30
+ It is the string representation of a `TreeNode` math equation.
31
+
32
+ #### Example
33
+ ```text
34
+ (cos(x)^2)+(sin(x)^2)
35
+ ```
36
+
37
+ Is represented internally as:
38
+
39
+ ```text
40
+ f_add
41
+ f_pow
42
+ f_cos
43
+ v_0
44
+ d_2
45
+ f_pow
46
+ f_sin
47
+ v_0
48
+ d_2
49
+ ```
50
+
51
+ #### Leaf Nodes
52
+
53
+ **Variables** (start with a `v_` prefix):
54
+
55
+ - `v_0` → x
56
+ - `v_1` → y
57
+ - `v_2` → z
58
+ - `v_3` → a
59
+
60
+ **Numbers** (start with `d_` prefix; only integers):
61
+
62
+ - `d_-1` → -1
63
+ - `d_0` → 0
64
+ - `d_1` → 1
65
+ - `d_2` → 2
66
+
67
+ #### Branch Nodes
68
+ - `f_add` → addition
69
+ - `f_mul` → multiplication
70
+ - `f_pow` → power
71
+
72
+ ### parse
73
+ Takes a math equation string and outputs a `TreeNode` object.
74
+
75
+ ```python
76
+ from mathai import *
77
+
78
+ equation = parse("sin(x)^2+cos(x)^2")
79
+ print(equation)
80
+ ```
81
+
82
+ #### Output
83
+ ```text
84
+ (cos(x)^2)+(sin(x)^2)
85
+ ```
86
+
87
+ ### printeq, printeq_str, printeq_log
88
+ Prints math equations in a more readable form than usual `print`.
89
+
90
+ ```python
91
+ from mathai import *
92
+
93
+ equation = simplify(parse("(x+1)/x"))
94
+ print(equation)
95
+ printeq(equation)
96
+ ```
97
+
98
+ #### Output
99
+ ```text
100
+ (1+x)*(x^-1)
101
+ (1+x)/x
102
+ ```
103
+
104
+ ### solve, simplify
105
+ `simplify` performs what `solve` does and more.
106
+ It simplifies and cleans up a given math equation.
107
+
108
+ ```python
109
+ from mathai import *
110
+
111
+ equation = simplify(parse("(x+x+x+x-1-1-1-1)*(4*x-4)*sin(sin(x+x+x)*sin(3*x))"))
112
+ printeq(equation)
113
+ ```
114
+
115
+ #### Output
116
+ ```text
117
+ ((-4+(4*x))^2)*sin((sin((3*x))^2))
118
+ ```
119
+
120
+ ### Incomplete Documentation, Will be updated and completed later on
121
+
122
+ ### Example Demonstration [limits questions can also be solved other than this these, try limit()]
123
+ ![pip-install-mathai-mathematics-solving-ai-system-in-python-v0-xcg3c22k51sf1](https://github.com/user-attachments/assets/799f576f-27d0-4d7c-86e9-ad55ff221bcc)
124
+ ```python
125
+ import sys, os, time
126
+ from mathai import *
127
+
128
+ sys.setrecursionlimit(10000)
129
+
130
+ def integration_byparts(item): return simplify(fraction(simplify(byparts(simplify(parse(item)))[0])))
131
+ def integration_apart(item): return simplify(fraction(integrate(apart(factor2(simplify(parse(item)))))[0]))
132
+ def integration_direct(item): return simplify(fraction(simplify(integrate(simplify(parse(item)))[0])))
133
+ def integration_trig(item): return simplify(trig0(integrate(trig1(simplify(parse(item))))[0]))
134
+ def algebra(item): return logic0(simplify(expand(simplify(parse(item)))))
135
+ def trig_basic(item): return logic0(simplify(expand(trig3(simplify(parse(item))))))
136
+ def trig_advanced(item): return logic0(simplify(trig0(trig1(trig4(simplify(fraction(trig0(simplify(parse(item))))))))))
137
+
138
+ all_tasks = [
139
+ *[(item, trig_advanced) for item in [
140
+ "cos(x)/(1+sin(x)) + (1+sin(x))/cos(x) = 2*sec(x)",
141
+ "(1+sec(x))/sec(x) = sin(x)^2/(1-cos(x))"]],
142
+ *[(item, integration_byparts) for item in ["sin(x)*x","x*sin(3*x)","x*log(abs(x))","arctan(x)"]],
143
+ *[(item, integration_apart) for item in ["x/((x+1)*(x+2))","1/(x^2-9)"]],
144
+ *[(item, integration_direct) for item in [
145
+ "x*sqrt(x+2)","sin(cos(x))*sin(x)","2*x/(1+x^2)","sqrt(a*x+b)","cos(sqrt(x))/sqrt(x)","e^(arctan(x))/(1+x^2)","sqrt(sin(2*x))*cos(2*x"]],
146
+ *[(item, integration_trig) for item in ["sin(2*x+5)^2","sin(x)^4","cos(2*x)^4"]],
147
+ *[(item, algebra) for item in ["(x+1)^2 = x^2+2*x+1","(x+1)*(x-1) = x^2-1"]],
148
+ *[(item, trig_basic) for item in ["2*sin(x)*cos(x)=sin(2*x)"]],
149
+ ]
150
+
151
+ def run_task(task):
152
+ item, func = task
153
+ try: result = func(item)
154
+ except Exception as e: result = str(e)
155
+ return item, result
156
+
157
+ if __name__=="__main__":
158
+ print(f"Solving {len(all_tasks)} math questions...\n")
159
+ start_time = time.time()
160
+ for task in all_tasks:
161
+ item, result = run_task(task)
162
+ print(f"{item} => {result}\n")
163
+ print(f"All tasks completed in {time.time()-start_time:.2f} seconds")
164
+ ```
165
+ ### Output
166
+
167
+ ```
168
+ Running 21 tasks asynchronously on 8 cores...
169
+
170
+ x*log(abs(x)) => ((-2*(x^2))+(4*log(abs(x))*(x^2)))*(8^-1)
171
+
172
+ arctan(x) => (log((abs((1+(x^2)))^-1))+(2*arctan(x)*x))*(2^-1)
173
+
174
+ sin(cos(x))*sin(x) => cos(cos(x))
175
+
176
+ 1/(x^2-9) => (log(abs((-3+x)))+log((abs((3+x))^-1)))*(6^-1)
177
+
178
+ x/((x+1)*(x+2)) => log((abs((1+x))^-1))+log(((2+x)^2))
179
+
180
+ x*sin(3*x) => ((-9*cos((3*x))*x)+(3*sin((3*x))))*(27^-1)
181
+
182
+ (1+sec(x))/sec(x) = sin(x)^2/(1-cos(x)) => true
183
+
184
+ e^(arctan(x))/(1+x^2) => e^arctan(x)
185
+
186
+ cos(sqrt(x))/sqrt(x) => 2*sin((x^(2^-1)))
187
+
188
+ sqrt(a*x+b) => 2*(3^-1)*(((x*a)+b)^(3*(2^-1)))*(a^-1)
189
+
190
+ sin(x)*x => (-1*cos(x)*x)+sin(x)
191
+
192
+ (x+1)^2 = x^2+2*x+1 => true
193
+
194
+ (x+1)*(x-1) = x^2-1 => true
195
+
196
+ cos(x)/(1+sin(x)) + (1+sin(x))/cos(x) = 2*sec(x) => true
197
+
198
+ 2*sin(x)*cos(x)=sin(2*x) => true
199
+
200
+ sqrt(sin(2*x))*cos(2*x) => (3^-1)*(sin((2*x))^(3*(2^-1)))
201
+
202
+ 2*x/(1+x^2) => log(abs((1+(x^2))))
203
+
204
+ sin(2*x+5)^2 => ((-1*(4^-1)*sin((10+(4*x))))+x)*(2^-1)
205
+
206
+ cos(2*x)^4 => ((4^-1)*x)+((64^-1)*sin((8*x)))+((8^-1)*sin((4*x)))+((8^-1)*x)
207
+
208
+ x*sqrt(x+2) => ((-1*(4^-1)*((2+x)^(2+(2^-1))))+(-2*((2+x)^(2+(2^-1))))+(5*((2+x)^(1+(2^-1)))*x)+((2^-1)*((2+x)^(1+(2^-1)))*x)+((8^-1)*((2+x)^(1+(2^-1)))*x))*((1+(2^-1))^-3)*((2+(2^-1))^-1)
209
+
210
+ sin(x)^4 => (-1*(4^-1)*sin((2*x)))+((32^-1)*sin((4*x)))+((4^-1)*x)+((8^-1)*x)
211
+
212
+ All tasks completed in 129.78 seconds
213
+ ```
214
+
@@ -27,13 +27,13 @@ def check(num, den, var):
27
27
  if n is None or d is None:
28
28
  return False
29
29
  if n == 0 and d == 0: return True
30
- if d != 0: return simplify(n/d)
30
+ if d != 0: return simplify(num/den)
31
31
  return False
32
32
  def lhospital(num, den, steps,var):
33
33
  logs = []
34
34
  out = check(num, den, var)
35
35
  if isinstance(out, TreeNode):
36
- return out
36
+ return out,[]
37
37
  for _ in range(steps):
38
38
  num2, den2 = map(lambda e: simplify(diff(e, var.name)), (num, den))
39
39
  out = check(num2, den2, var)
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.2
2
+ Name: mathai
3
+ Version: 0.2.2
4
+ Summary: Mathematics solving Ai tailored to NCERT
5
+ Home-page: https://github.com/infinity390/mathai4
6
+ Author: educated indians are having a low iq and are good for nothing
7
+ Requires-Python: >=3.7
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: lark-parser
10
+ Dynamic: author
11
+ Dynamic: description
12
+ Dynamic: description-content-type
13
+ Dynamic: home-page
14
+ Dynamic: requires-dist
15
+ Dynamic: requires-python
16
+ Dynamic: summary
17
+
18
+ # Math AI Documentation
19
+
20
+ ## Philosophy
21
+ I think it is a big realization in computer science and programming to realize that computers can solve mathematics.
22
+ This understanding should be made mainstream. It can help transform education, mathematical research, and computation of mathematical equations for work.
23
+
24
+ ## Societal Implications Of Such A Computer Program And The Author's Comment On Universities Of India
25
+ I think mathematics is valued by society because of education. Schools and universities teach them.
26
+ So this kind of software, if made mainstream, could bring real change.
27
+
28
+ ### The Author's Comments On The Universities In His Country
29
+ > Educated Indians are having a low IQ and are good for nothing.
30
+ > The Indian Institute of Technology (IITs) graduates are the leader of the fools.
31
+ > Every educated Indian is beneath me.
32
+ > Now learn how this Python library can solve the math questions of your exams.
33
+
34
+ ## The Summary Of How Computer "Solves" Math
35
+ Math equations are a tree data structure (`TreeNode` class).
36
+ We can manipulate the math equations using various algorithms (functions provided by the `mathai` library).
37
+ We first parse the math equation strings to get the tree data structure (`parse` function in `mathai`).
38
+
39
+ ## The Library
40
+ Import the library by doing:
41
+
42
+ ```python
43
+ from mathai import *
44
+ ```
45
+
46
+ ### str_form
47
+ It is the string representation of a `TreeNode` math equation.
48
+
49
+ #### Example
50
+ ```text
51
+ (cos(x)^2)+(sin(x)^2)
52
+ ```
53
+
54
+ Is represented internally as:
55
+
56
+ ```text
57
+ f_add
58
+ f_pow
59
+ f_cos
60
+ v_0
61
+ d_2
62
+ f_pow
63
+ f_sin
64
+ v_0
65
+ d_2
66
+ ```
67
+
68
+ #### Leaf Nodes
69
+
70
+ **Variables** (start with a `v_` prefix):
71
+
72
+ - `v_0` → x
73
+ - `v_1` → y
74
+ - `v_2` → z
75
+ - `v_3` → a
76
+
77
+ **Numbers** (start with `d_` prefix; only integers):
78
+
79
+ - `d_-1` → -1
80
+ - `d_0` → 0
81
+ - `d_1` → 1
82
+ - `d_2` → 2
83
+
84
+ #### Branch Nodes
85
+ - `f_add` → addition
86
+ - `f_mul` → multiplication
87
+ - `f_pow` → power
88
+
89
+ ### parse
90
+ Takes a math equation string and outputs a `TreeNode` object.
91
+
92
+ ```python
93
+ from mathai import *
94
+
95
+ equation = parse("sin(x)^2+cos(x)^2")
96
+ print(equation)
97
+ ```
98
+
99
+ #### Output
100
+ ```text
101
+ (cos(x)^2)+(sin(x)^2)
102
+ ```
103
+
104
+ ### printeq, printeq_str, printeq_log
105
+ Prints math equations in a more readable form than usual `print`.
106
+
107
+ ```python
108
+ from mathai import *
109
+
110
+ equation = simplify(parse("(x+1)/x"))
111
+ print(equation)
112
+ printeq(equation)
113
+ ```
114
+
115
+ #### Output
116
+ ```text
117
+ (1+x)*(x^-1)
118
+ (1+x)/x
119
+ ```
120
+
121
+ ### solve, simplify
122
+ `simplify` performs what `solve` does and more.
123
+ It simplifies and cleans up a given math equation.
124
+
125
+ ```python
126
+ from mathai import *
127
+
128
+ equation = simplify(parse("(x+x+x+x-1-1-1-1)*(4*x-4)*sin(sin(x+x+x)*sin(3*x))"))
129
+ printeq(equation)
130
+ ```
131
+
132
+ #### Output
133
+ ```text
134
+ ((-4+(4*x))^2)*sin((sin((3*x))^2))
135
+ ```
136
+
137
+ ### Incomplete Documentation, Will be updated and completed later on
138
+
139
+ ### Example Demonstration [limits questions can also be solved other than this these, try limit()]
140
+ ![pip-install-mathai-mathematics-solving-ai-system-in-python-v0-xcg3c22k51sf1](https://github.com/user-attachments/assets/799f576f-27d0-4d7c-86e9-ad55ff221bcc)
141
+ ```python
142
+ import sys, os, time
143
+ from mathai import *
144
+
145
+ sys.setrecursionlimit(10000)
146
+
147
+ def integration_byparts(item): return simplify(fraction(simplify(byparts(simplify(parse(item)))[0])))
148
+ def integration_apart(item): return simplify(fraction(integrate(apart(factor2(simplify(parse(item)))))[0]))
149
+ def integration_direct(item): return simplify(fraction(simplify(integrate(simplify(parse(item)))[0])))
150
+ def integration_trig(item): return simplify(trig0(integrate(trig1(simplify(parse(item))))[0]))
151
+ def algebra(item): return logic0(simplify(expand(simplify(parse(item)))))
152
+ def trig_basic(item): return logic0(simplify(expand(trig3(simplify(parse(item))))))
153
+ def trig_advanced(item): return logic0(simplify(trig0(trig1(trig4(simplify(fraction(trig0(simplify(parse(item))))))))))
154
+
155
+ all_tasks = [
156
+ *[(item, trig_advanced) for item in [
157
+ "cos(x)/(1+sin(x)) + (1+sin(x))/cos(x) = 2*sec(x)",
158
+ "(1+sec(x))/sec(x) = sin(x)^2/(1-cos(x))"]],
159
+ *[(item, integration_byparts) for item in ["sin(x)*x","x*sin(3*x)","x*log(abs(x))","arctan(x)"]],
160
+ *[(item, integration_apart) for item in ["x/((x+1)*(x+2))","1/(x^2-9)"]],
161
+ *[(item, integration_direct) for item in [
162
+ "x*sqrt(x+2)","sin(cos(x))*sin(x)","2*x/(1+x^2)","sqrt(a*x+b)","cos(sqrt(x))/sqrt(x)","e^(arctan(x))/(1+x^2)","sqrt(sin(2*x))*cos(2*x"]],
163
+ *[(item, integration_trig) for item in ["sin(2*x+5)^2","sin(x)^4","cos(2*x)^4"]],
164
+ *[(item, algebra) for item in ["(x+1)^2 = x^2+2*x+1","(x+1)*(x-1) = x^2-1"]],
165
+ *[(item, trig_basic) for item in ["2*sin(x)*cos(x)=sin(2*x)"]],
166
+ ]
167
+
168
+ def run_task(task):
169
+ item, func = task
170
+ try: result = func(item)
171
+ except Exception as e: result = str(e)
172
+ return item, result
173
+
174
+ if __name__=="__main__":
175
+ print(f"Solving {len(all_tasks)} math questions...\n")
176
+ start_time = time.time()
177
+ for task in all_tasks:
178
+ item, result = run_task(task)
179
+ print(f"{item} => {result}\n")
180
+ print(f"All tasks completed in {time.time()-start_time:.2f} seconds")
181
+ ```
182
+ ### Output
183
+
184
+ ```
185
+ Running 21 tasks asynchronously on 8 cores...
186
+
187
+ x*log(abs(x)) => ((-2*(x^2))+(4*log(abs(x))*(x^2)))*(8^-1)
188
+
189
+ arctan(x) => (log((abs((1+(x^2)))^-1))+(2*arctan(x)*x))*(2^-1)
190
+
191
+ sin(cos(x))*sin(x) => cos(cos(x))
192
+
193
+ 1/(x^2-9) => (log(abs((-3+x)))+log((abs((3+x))^-1)))*(6^-1)
194
+
195
+ x/((x+1)*(x+2)) => log((abs((1+x))^-1))+log(((2+x)^2))
196
+
197
+ x*sin(3*x) => ((-9*cos((3*x))*x)+(3*sin((3*x))))*(27^-1)
198
+
199
+ (1+sec(x))/sec(x) = sin(x)^2/(1-cos(x)) => true
200
+
201
+ e^(arctan(x))/(1+x^2) => e^arctan(x)
202
+
203
+ cos(sqrt(x))/sqrt(x) => 2*sin((x^(2^-1)))
204
+
205
+ sqrt(a*x+b) => 2*(3^-1)*(((x*a)+b)^(3*(2^-1)))*(a^-1)
206
+
207
+ sin(x)*x => (-1*cos(x)*x)+sin(x)
208
+
209
+ (x+1)^2 = x^2+2*x+1 => true
210
+
211
+ (x+1)*(x-1) = x^2-1 => true
212
+
213
+ cos(x)/(1+sin(x)) + (1+sin(x))/cos(x) = 2*sec(x) => true
214
+
215
+ 2*sin(x)*cos(x)=sin(2*x) => true
216
+
217
+ sqrt(sin(2*x))*cos(2*x) => (3^-1)*(sin((2*x))^(3*(2^-1)))
218
+
219
+ 2*x/(1+x^2) => log(abs((1+(x^2))))
220
+
221
+ sin(2*x+5)^2 => ((-1*(4^-1)*sin((10+(4*x))))+x)*(2^-1)
222
+
223
+ cos(2*x)^4 => ((4^-1)*x)+((64^-1)*sin((8*x)))+((8^-1)*sin((4*x)))+((8^-1)*x)
224
+
225
+ x*sqrt(x+2) => ((-1*(4^-1)*((2+x)^(2+(2^-1))))+(-2*((2+x)^(2+(2^-1))))+(5*((2+x)^(1+(2^-1)))*x)+((2^-1)*((2+x)^(1+(2^-1)))*x)+((8^-1)*((2+x)^(1+(2^-1)))*x))*((1+(2^-1))^-3)*((2+(2^-1))^-1)
226
+
227
+ sin(x)^4 => (-1*(4^-1)*sin((2*x)))+((32^-1)*sin((4*x)))+((4^-1)*x)+((8^-1)*x)
228
+
229
+ All tasks completed in 129.78 seconds
230
+ ```
231
+
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="mathai",
5
- version="0.2.1",
5
+ version="0.2.2",
6
6
  description="Mathematics solving Ai tailored to NCERT",
7
7
  long_description=open("README.md").read(),
8
8
  long_description_content_type="text/markdown",
mathai-0.2.1/PKG-INFO DELETED
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: mathai
3
- Version: 0.2.1
4
- Summary: Mathematics solving Ai tailored to NCERT
5
- Home-page: https://github.com/infinity390/mathai4
6
- Author: educated indians are having a low iq and are good for nothing
7
- Requires-Python: >=3.7
8
- Description-Content-Type: text/markdown
9
- Requires-Dist: lark-parser
10
- Dynamic: author
11
- Dynamic: description
12
- Dynamic: description-content-type
13
- Dynamic: home-page
14
- Dynamic: requires-dist
15
- Dynamic: requires-python
16
- Dynamic: summary
17
-
18
- educated indians are having a low iq and are good for nothing
19
-
20
- the indian institute of technology graduates are the leader of the fools
21
-
22
- every educated indian is beneath me
23
-
24
- now learn how this python library can solve the math questions of your exams
mathai-0.2.1/README.md DELETED
@@ -1,7 +0,0 @@
1
- educated indians are having a low iq and are good for nothing
2
-
3
- the indian institute of technology graduates are the leader of the fools
4
-
5
- every educated indian is beneath me
6
-
7
- now learn how this python library can solve the math questions of your exams
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: mathai
3
- Version: 0.2.1
4
- Summary: Mathematics solving Ai tailored to NCERT
5
- Home-page: https://github.com/infinity390/mathai4
6
- Author: educated indians are having a low iq and are good for nothing
7
- Requires-Python: >=3.7
8
- Description-Content-Type: text/markdown
9
- Requires-Dist: lark-parser
10
- Dynamic: author
11
- Dynamic: description
12
- Dynamic: description-content-type
13
- Dynamic: home-page
14
- Dynamic: requires-dist
15
- Dynamic: requires-python
16
- Dynamic: summary
17
-
18
- educated indians are having a low iq and are good for nothing
19
-
20
- the indian institute of technology graduates are the leader of the fools
21
-
22
- every educated indian is beneath me
23
-
24
- now learn how this python library can solve the math questions of your exams
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes