mathai 0.2.7__tar.gz → 0.2.9__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 (29) hide show
  1. {mathai-0.2.7 → mathai-0.2.9}/PKG-INFO +231 -231
  2. {mathai-0.2.7 → mathai-0.2.9}/README.md +214 -214
  3. {mathai-0.2.7 → mathai-0.2.9}/mathai/__init__.py +16 -16
  4. {mathai-0.2.7 → mathai-0.2.9}/mathai/apart.py +103 -103
  5. {mathai-0.2.7 → mathai-0.2.9}/mathai/base.py +355 -354
  6. {mathai-0.2.7 → mathai-0.2.9}/mathai/console.py +84 -84
  7. {mathai-0.2.7 → mathai-0.2.9}/mathai/diff.py +65 -65
  8. {mathai-0.2.7 → mathai-0.2.9}/mathai/expand.py +58 -58
  9. {mathai-0.2.7 → mathai-0.2.9}/mathai/factor.py +125 -125
  10. {mathai-0.2.7 → mathai-0.2.9}/mathai/fraction.py +59 -59
  11. {mathai-0.2.7 → mathai-0.2.9}/mathai/integrate.py +346 -346
  12. {mathai-0.2.7 → mathai-0.2.9}/mathai/inverse.py +65 -65
  13. {mathai-0.2.7 → mathai-0.2.9}/mathai/limit.py +130 -130
  14. {mathai-0.2.7 → mathai-0.2.9}/mathai/linear.py +152 -152
  15. {mathai-0.2.7 → mathai-0.2.9}/mathai/logic.py +224 -224
  16. {mathai-0.2.7 → mathai-0.2.9}/mathai/parser.py +154 -154
  17. {mathai-0.2.7 → mathai-0.2.9}/mathai/printeq.py +34 -34
  18. {mathai-0.2.7 → mathai-0.2.9}/mathai/simplify.py +358 -358
  19. {mathai-0.2.7 → mathai-0.2.9}/mathai/structure.py +103 -103
  20. {mathai-0.2.7 → mathai-0.2.9}/mathai/tool.py +35 -35
  21. {mathai-0.2.7 → mathai-0.2.9}/mathai/trig.py +169 -169
  22. {mathai-0.2.7 → mathai-0.2.9}/mathai/univariate_inequality.py +410 -414
  23. {mathai-0.2.7 → mathai-0.2.9}/mathai.egg-info/PKG-INFO +231 -231
  24. {mathai-0.2.7 → mathai-0.2.9}/setup.cfg +4 -4
  25. {mathai-0.2.7 → mathai-0.2.9}/setup.py +16 -16
  26. {mathai-0.2.7 → mathai-0.2.9}/mathai.egg-info/SOURCES.txt +0 -0
  27. {mathai-0.2.7 → mathai-0.2.9}/mathai.egg-info/dependency_links.txt +0 -0
  28. {mathai-0.2.7 → mathai-0.2.9}/mathai.egg-info/requires.txt +0 -0
  29. {mathai-0.2.7 → mathai-0.2.9}/mathai.egg-info/top_level.txt +0 -0
@@ -1,231 +1,231 @@
1
- Metadata-Version: 2.2
2
- Name: mathai
3
- Version: 0.2.7
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
-
1
+ Metadata-Version: 2.4
2
+ Name: mathai
3
+ Version: 0.2.9
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
+