mathai 0.2.1__tar.gz → 0.2.3__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.
- mathai-0.2.3/PKG-INFO +231 -0
- mathai-0.2.3/README.md +214 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/__init__.py +2 -1
- {mathai-0.2.1 → mathai-0.2.3}/mathai/base.py +2 -1
- {mathai-0.2.1 → mathai-0.2.3}/mathai/expand.py +2 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/inverse.py +11 -3
- {mathai-0.2.1 → mathai-0.2.3}/mathai/limit.py +2 -2
- {mathai-0.2.1 → mathai-0.2.3}/mathai/simplify.py +24 -9
- mathai-0.2.3/mathai/univariate_inequality.py +411 -0
- mathai-0.2.3/mathai.egg-info/PKG-INFO +231 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai.egg-info/SOURCES.txt +1 -0
- {mathai-0.2.1 → mathai-0.2.3}/setup.py +1 -1
- mathai-0.2.1/PKG-INFO +0 -24
- mathai-0.2.1/README.md +0 -7
- mathai-0.2.1/mathai.egg-info/PKG-INFO +0 -24
- {mathai-0.2.1 → mathai-0.2.3}/mathai/apart.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/console.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/diff.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/factor.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/fraction.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/integrate.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/linear.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/logic.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/parser.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/printeq.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/structure.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/tool.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai/trig.py +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai.egg-info/dependency_links.txt +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai.egg-info/requires.txt +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/mathai.egg-info/top_level.txt +0 -0
- {mathai-0.2.1 → mathai-0.2.3}/setup.cfg +0 -0
mathai-0.2.3/PKG-INFO
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: mathai
|
3
|
+
Version: 0.2.3
|
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
|
+

|
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.3/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
|
+

|
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
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from .expand import expand
|
2
2
|
from .parser import parse
|
3
3
|
from .printeq import printeq, printeq_log, printeq_str
|
4
|
-
from .simplify import solve, simplify
|
4
|
+
from .simplify import solve, simplify, solve2
|
5
5
|
from .integrate import integrate, sqint, byparts
|
6
6
|
from .diff import diff
|
7
7
|
from .factor import factor, factor2
|
@@ -12,4 +12,5 @@ from .logic import logic0, logic1, logic2, logic3
|
|
12
12
|
from .apart import apart
|
13
13
|
from .console import console
|
14
14
|
from .limit import limit
|
15
|
+
from .univariate_inequality import wavycurvy, absolute, domain, handle_sqrt
|
15
16
|
from .base import *
|
@@ -1,10 +1,11 @@
|
|
1
1
|
from .base import *
|
2
2
|
from .simplify import solve
|
3
3
|
from .expand import expand
|
4
|
-
def inverse(rhs,term):
|
4
|
+
def inverse(rhs,term, sign=None):
|
5
5
|
term = tree_form(term)
|
6
6
|
lhs = tree_form("d_0")
|
7
7
|
count = 15
|
8
|
+
|
8
9
|
while not rhs==term:
|
9
10
|
if rhs.name == "f_add":
|
10
11
|
if all(term in factor_generation(child) for child in rhs.children):
|
@@ -20,6 +21,12 @@ def inverse(rhs,term):
|
|
20
21
|
for i in range(len(rhs.children)-1,-1,-1):
|
21
22
|
if not contain(rhs.children[i], term):
|
22
23
|
lhs = lhs * rhs.children[i]**-1
|
24
|
+
if sign is not None:
|
25
|
+
if "v_" in str_form(rhs.children[i]):
|
26
|
+
return None
|
27
|
+
if compute(rhs.children[i]**-1) < 0:
|
28
|
+
sign = not sign
|
29
|
+
|
23
30
|
rhs.children.pop(i)
|
24
31
|
elif rhs.name == "f_pow" and contain(rhs.children[0], term):
|
25
32
|
lhs = lhs ** (tree_form("d_1")/rhs.children[1])
|
@@ -53,5 +60,6 @@ def inverse(rhs,term):
|
|
53
60
|
count -= 1
|
54
61
|
if count == 0:
|
55
62
|
return None
|
56
|
-
|
57
|
-
|
63
|
+
if sign is None:
|
64
|
+
return solve(lhs)
|
65
|
+
return solve(lhs), sign
|
@@ -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(
|
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)
|
@@ -144,25 +144,36 @@ def solve(eq, specialfx=False):
|
|
144
144
|
eq = flatten_tree(eq)
|
145
145
|
|
146
146
|
return dowhile(eq, _solve)
|
147
|
-
|
147
|
+
def solve2(eq):
|
148
|
+
return solve(eq, True)
|
148
149
|
def clear_div(eq):
|
149
150
|
lst = factor_generation(eq)
|
150
151
|
if tree_form("d_0") in lst:
|
151
152
|
return tree_form("d_0")
|
152
|
-
|
153
|
+
lst3 = [item for item in lst if "v_" not in str_form(item) and compute(item) < 0]
|
154
|
+
sign = True
|
155
|
+
if len(lst3) % 2 == 1:
|
156
|
+
sign = False
|
157
|
+
lst = [item for item in lst if not(item.name == "f_pow" and frac(item.children[1]) is not None and frac(item.children[1]) == -1)]
|
153
158
|
|
154
159
|
lst2 = [item for item in lst if "v_" in str_form(item)]
|
155
160
|
if lst2 == []:
|
156
|
-
return solve(product(lst))
|
157
|
-
return solve(product(lst2))
|
161
|
+
return solve(product(lst)),sign
|
162
|
+
return solve(product(lst2)),sign
|
158
163
|
|
159
164
|
def simplify(eq):
|
160
165
|
error = False
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
+
eq = flatten_tree(eq)
|
167
|
+
if eq.name in ["f_and", "f_or", "f_not"]:
|
168
|
+
return TreeNode(eq.name, [simplify(child) for child in eq.children])
|
169
|
+
|
170
|
+
if eq.name in ["f_lt", "f_gt", "f_le", "f_ge", "f_eq"]:
|
171
|
+
tmp, sign = clear_div(simplify(eq.children[0]-eq.children[1]))
|
172
|
+
name2 = eq.name
|
173
|
+
if not sign:
|
174
|
+
name2 = {"f_lt":"f_gt", "f_gt":"f_lt", "f_eq":"f_eq", "f_le":"f_ge", "f_ge":"f_le"}[name2]
|
175
|
+
|
176
|
+
return TreeNode(name2, [tmp, tree_form("d_0")])
|
166
177
|
|
167
178
|
eq = solve(eq, True)
|
168
179
|
def helper(eq):
|
@@ -219,6 +230,8 @@ def simplify(eq):
|
|
219
230
|
return TreeNode(eq.name, [helper3(child) for child in eq.children])
|
220
231
|
def helper4(eq):
|
221
232
|
nonlocal error
|
233
|
+
if eq == tree_form("d_-1")**tree_form("d_-1"):
|
234
|
+
return tree_form("d_-1")
|
222
235
|
def perfect_nth_root_value(x, n):
|
223
236
|
"""Return integer y if x is a perfect n-th power (y**n == x), else None."""
|
224
237
|
if x < 0 and n % 2 == 0:
|
@@ -316,6 +329,8 @@ def simplify(eq):
|
|
316
329
|
return eq.children[0].children[0]**eq.children[1]
|
317
330
|
return TreeNode(eq.name, [helper5(child) for child in eq.children])
|
318
331
|
def helper8(eq):
|
332
|
+
if eq.name == "f_pow" and eq.children[0].name == "f_abs" and frac(eq.children[1]) is not None and frac(eq.children[1]).numerator % 2==0:
|
333
|
+
return eq.children[0].children[0] ** eq.children[1]
|
319
334
|
if eq.name == "f_abs" and eq.children[0].name == "f_abs":
|
320
335
|
return eq.children[0]
|
321
336
|
if eq.name == "f_cos" and eq.children[0].name == "f_abs":
|