mathai 0.5.4__py3-none-any.whl → 0.5.5__py3-none-any.whl
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/__init__.py +3 -3
- mathai/base.py +63 -17
- mathai/diff.py +3 -3
- mathai/expand.py +111 -83
- mathai/factor.py +43 -21
- mathai/fraction.py +2 -2
- mathai/integrate.py +19 -15
- mathai/inverse.py +4 -4
- mathai/limit.py +1 -1
- mathai/linear.py +1 -1
- mathai/logic.py +7 -1
- mathai/printeq.py +4 -4
- mathai/simplify.py +490 -382
- mathai/structure.py +2 -2
- mathai/tool.py +2 -2
- mathai/trig.py +42 -25
- mathai/univariate_inequality.py +11 -8
- {mathai-0.5.4.dist-info → mathai-0.5.5.dist-info}/METADATA +1 -1
- mathai-0.5.5.dist-info/RECORD +27 -0
- mathai-0.5.4.dist-info/RECORD +0 -27
- {mathai-0.5.4.dist-info → mathai-0.5.5.dist-info}/WHEEL +0 -0
- {mathai-0.5.4.dist-info → mathai-0.5.5.dist-info}/top_level.txt +0 -0
mathai/structure.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import itertools
|
|
2
|
-
from .simplify import
|
|
2
|
+
from .simplify import simplify
|
|
3
3
|
from .base import *
|
|
4
4
|
|
|
5
5
|
def structure(equation, formula, formula_out=None, only_const=False):
|
|
@@ -84,7 +84,7 @@ def transform_formula(equation, wrt, formula_list, var, expr):
|
|
|
84
84
|
for j in range(len(expr)):
|
|
85
85
|
item[i] = replace(item[i], expr[j][0], item2[j])
|
|
86
86
|
for i in range(2):
|
|
87
|
-
item[i] =
|
|
87
|
+
item[i] = simplify(item[i])
|
|
88
88
|
out = None
|
|
89
89
|
p = False
|
|
90
90
|
if var != "":
|
mathai/tool.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from .diff import diff
|
|
2
2
|
from .expand import expand
|
|
3
|
-
from .simplify import simplify
|
|
3
|
+
from .simplify import simplify
|
|
4
4
|
from .base import *
|
|
5
5
|
import math
|
|
6
6
|
|
|
@@ -159,5 +159,5 @@ def poly(eq, to_compute, m=10):
|
|
|
159
159
|
final = []
|
|
160
160
|
for index, item in enumerate(out):
|
|
161
161
|
final.append(substitute_val(item, 0, to_compute)/tree_form("d_"+str(math.factorial(index))))
|
|
162
|
-
|
|
162
|
+
|
|
163
163
|
return [expand(simplify(item)) for item in final][::-1]
|
mathai/trig.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import itertools
|
|
2
|
-
from .simplify import
|
|
2
|
+
from .simplify import simplify
|
|
3
3
|
from .base import *
|
|
4
4
|
from .expand import expand
|
|
5
5
|
from .structure import transform_formula
|
|
@@ -49,7 +49,7 @@ def trig0(eq):
|
|
|
49
49
|
count += 1
|
|
50
50
|
if count != 1:
|
|
51
51
|
return None
|
|
52
|
-
eq =
|
|
52
|
+
eq = simplify(product(lst)/tree_form("s_pi"))
|
|
53
53
|
out = frac(eq)
|
|
54
54
|
if out is None or out < 0:
|
|
55
55
|
return None
|
|
@@ -99,31 +99,48 @@ def trig0(eq):
|
|
|
99
99
|
if tuple(out) in trig_cos_table.keys():
|
|
100
100
|
return trig_cos_table[tuple(out)]
|
|
101
101
|
return TreeNode(eq.name, [trig0(child) for child in eq.children])
|
|
102
|
+
def cog(expr):
|
|
103
|
+
expr = TreeNode(expr.name, [product_to_sum(child) for child in expr.children])
|
|
104
|
+
expr = trig0(simplify(expr))
|
|
105
|
+
expr = expand(simplify(expr))
|
|
106
|
+
return expr
|
|
107
|
+
def product_to_sum(expr):
|
|
108
|
+
factors = factor_generation(expr)
|
|
109
|
+
other = []
|
|
110
|
+
lst = []
|
|
111
|
+
for item in factors:
|
|
112
|
+
if item.name in ["f_cos", "f_sin"]:
|
|
113
|
+
lst.append(item)
|
|
114
|
+
else:
|
|
115
|
+
other.append(item)
|
|
116
|
+
if len(lst) <= 1:
|
|
102
117
|
|
|
103
|
-
|
|
104
|
-
lst = factor_generation(eq)
|
|
105
|
-
if len(lst) == 1:
|
|
106
|
-
return lst[0]
|
|
118
|
+
return dowhile(expr, cog)
|
|
107
119
|
if len(lst) == 2:
|
|
108
120
|
a, b = lst
|
|
121
|
+
out = None
|
|
122
|
+
if a.name < b.name:
|
|
123
|
+
a, b = b, a
|
|
124
|
+
A, B = a.children[0], b.children[0]
|
|
109
125
|
if a.name == "f_sin" and b.name == "f_sin":
|
|
110
|
-
|
|
126
|
+
out =((A - B).fx("cos") - (A + B).fx("cos")) / tree_form("d_2")
|
|
111
127
|
elif a.name == "f_cos" and b.name == "f_cos":
|
|
112
|
-
|
|
128
|
+
out =((A - B).fx("cos") + (A + B).fx("cos")) / tree_form("d_2")
|
|
113
129
|
elif a.name == "f_sin" and b.name == "f_cos":
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return
|
|
130
|
+
out =((A + B).fx("sin") + (A - B).fx("sin")) / tree_form("d_2")
|
|
131
|
+
|
|
132
|
+
return out * product(other)
|
|
133
|
+
|
|
134
|
+
rest = tree_form("d_1")
|
|
135
|
+
if len(lst) % 2 == 1:
|
|
136
|
+
rest = lst.pop(0)
|
|
137
|
+
out = []
|
|
138
|
+
for i in range(0, len(lst), 2):
|
|
139
|
+
out.append(product_to_sum(product(lst[i:i+2])))
|
|
140
|
+
expr = product(out)*rest*product(other)
|
|
141
|
+
|
|
142
|
+
return dowhile(expr, cog)
|
|
143
|
+
|
|
127
144
|
def trig_formula_init():
|
|
128
145
|
var = ""
|
|
129
146
|
formula_list = [(f"A*sin(B)+C*sin(B)", f"(A^2+C^2)^(1/2)*sin(B+arctan(C/A))"),\
|
|
@@ -162,11 +179,11 @@ def noneg_pow(eq):
|
|
|
162
179
|
if eq.name == "f_pow" and frac(eq.children[1]) is not None and frac(eq.children[1])<0:
|
|
163
180
|
return (eq.children[0]**(simplify(-eq.children[1])))**-1
|
|
164
181
|
return TreeNode(eq.name, [noneg_pow(child) for child in eq.children])
|
|
165
|
-
|
|
166
|
-
equation = product_to_sum(equation)
|
|
167
|
-
return TreeNode(equation.name, [_trig1(child) for child in equation.children])
|
|
182
|
+
|
|
168
183
|
def trig1(eq):
|
|
169
|
-
|
|
184
|
+
eq = noneg_pow(eq)
|
|
185
|
+
return product_to_sum(eq)
|
|
186
|
+
|
|
170
187
|
def trig4(eq):
|
|
171
188
|
done = False
|
|
172
189
|
def _trig4(eq, numer=True, chance="sin"):
|
mathai/univariate_inequality.py
CHANGED
|
@@ -3,8 +3,8 @@ import itertools
|
|
|
3
3
|
from .base import *
|
|
4
4
|
from .inverse import inverse
|
|
5
5
|
from collections import Counter
|
|
6
|
-
from .factor import factor2
|
|
7
|
-
from .simplify import simplify
|
|
6
|
+
#from .factor import factor2
|
|
7
|
+
from .simplify import simplify
|
|
8
8
|
from .expand import expand
|
|
9
9
|
from .fraction import fraction
|
|
10
10
|
import copy
|
|
@@ -18,6 +18,7 @@ def intersection2(domain, lst):
|
|
|
18
18
|
return []
|
|
19
19
|
lst = [item for item in lst if item not in domain]
|
|
20
20
|
out = []
|
|
21
|
+
|
|
21
22
|
for item2 in lst:
|
|
22
23
|
for index in range(len(domain)):
|
|
23
24
|
|
|
@@ -180,7 +181,7 @@ def helper(eq, var="v_0"):
|
|
|
180
181
|
if eq.children[0].name == "f_add":
|
|
181
182
|
|
|
182
183
|
eq.children[0] = simplify(expand(eq.children[0]))
|
|
183
|
-
eq = simplify(factor2(eq))
|
|
184
|
+
#eq = simplify(factor2(eq))
|
|
184
185
|
|
|
185
186
|
|
|
186
187
|
equ = False
|
|
@@ -198,10 +199,12 @@ def helper(eq, var="v_0"):
|
|
|
198
199
|
more = []
|
|
199
200
|
|
|
200
201
|
_, d = num_dem(eq.children[0])
|
|
201
|
-
d =
|
|
202
|
+
d = simplify(d)
|
|
203
|
+
|
|
204
|
+
#d = factor2(d)
|
|
202
205
|
|
|
203
206
|
for item in factor_generation(d):
|
|
204
|
-
|
|
207
|
+
|
|
205
208
|
item = simplify(expand(item))
|
|
206
209
|
if len(vlist(item)) != 0:
|
|
207
210
|
v = vlist(item)[0]
|
|
@@ -210,7 +213,7 @@ def helper(eq, var="v_0"):
|
|
|
210
213
|
out = inverse(item, vlist(item)[0])
|
|
211
214
|
more.append(simplify(out))
|
|
212
215
|
|
|
213
|
-
eq.children[0] = factor2(eq.children[0])
|
|
216
|
+
#eq.children[0] = factor2(eq.children[0])
|
|
214
217
|
|
|
215
218
|
for item in factor_generation(eq.children[0]):
|
|
216
219
|
item = simplify(expand(item))
|
|
@@ -262,6 +265,7 @@ def helper(eq, var="v_0"):
|
|
|
262
265
|
equal = list(set([simplify(item) for item in equal]))
|
|
263
266
|
more = list(set([simplify(item) for item in more]))
|
|
264
267
|
critical = [simplify(item) for item in critical]
|
|
268
|
+
|
|
265
269
|
critical = Counter(critical)
|
|
266
270
|
|
|
267
271
|
critical = sorted(critical.items(), key=lambda x: compute(x[0]))
|
|
@@ -277,7 +281,6 @@ def helper(eq, var="v_0"):
|
|
|
277
281
|
critical[i] = critical[i][0]
|
|
278
282
|
|
|
279
283
|
|
|
280
|
-
|
|
281
284
|
if eq.name == "f_eq":
|
|
282
285
|
final = Range([False], equal, more)
|
|
283
286
|
dic_table[eq2] = final
|
|
@@ -392,7 +395,7 @@ def handle_sqrt(eq):
|
|
|
392
395
|
return out
|
|
393
396
|
return TreeNode("f_and", [helper2(eq)]+d)
|
|
394
397
|
def domain(eq):
|
|
395
|
-
eq =
|
|
398
|
+
eq = simplify(eq)
|
|
396
399
|
out = []
|
|
397
400
|
def helper2(eq):
|
|
398
401
|
nonlocal out
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
mathai/__init__.py,sha256=fS2JF5cF02nWEw_GwqT7VzXpTP1YJe4WPD7ScFhNWTU,1542
|
|
2
|
+
mathai/apart.py,sha256=VSS3khE9PNuxiRvdU5JDl4IN-KJBSIFjwR17pkhviXI,4197
|
|
3
|
+
mathai/base.py,sha256=mc_uvjdVBbTMMrusMEUgYBrrpY1DMNXcaftuf-EUTT4,14158
|
|
4
|
+
mathai/bivariate_inequality.py,sha256=FJOC2zKU5zWCMybCrhEQ7nVDgRO_w19Zko8WPTaDTSo,11411
|
|
5
|
+
mathai/console.py,sha256=Sn58iwYE79MLEh67s8X3q6vZjw6g7f9XM1T8_dBBR2o,3048
|
|
6
|
+
mathai/diff.py,sha256=RSTwlfeddvYXUDShCeRdcPjsmAS8Vf5OkYJAaUBPaiM,3060
|
|
7
|
+
mathai/expand.py,sha256=chf5Ht6jLWNZl_RB_hziI7u_ZwsRtCGWJropt88dPA4,5474
|
|
8
|
+
mathai/factor.py,sha256=WZqwLJwpDnkgYiUtmX4OPwcLg87--l_naUA39Lctfik,12513
|
|
9
|
+
mathai/fraction.py,sha256=88xvRpDGfFi8tbe1QIyejdSP91HcErrN4VS2MxzbhrY,4392
|
|
10
|
+
mathai/integrate.py,sha256=AqNp6DeQOQJUCbIcRo5Y36r5zjIhHUYDAj-_RkRrEJE,17202
|
|
11
|
+
mathai/inverse.py,sha256=ya7P8WjzfaAL3UXL7xqOh5GaIsXLDZ-F6lZFy3IEgaQ,2931
|
|
12
|
+
mathai/limit.py,sha256=9F8i9UZh2xb-V8A5Sd1gdhDf9c2RFgpE1GdNn9MvbWI,5703
|
|
13
|
+
mathai/linear.py,sha256=viGlPU8BPrjLWHlyNUvnfPHNH5d4ZBImiQMdyXaKGg0,5702
|
|
14
|
+
mathai/logic.py,sha256=Ndz4Fd6aNCmzFlqoPyyIpSmV_BXmYHsurePjLyZJoNc,9809
|
|
15
|
+
mathai/matrix.py,sha256=dWIXF5oInIL3SZ3naRzKN5ElI5drXJNiVTDM48hfZOw,972
|
|
16
|
+
mathai/ode.py,sha256=zxxTXAOpt7oSsfpgI4vHsCWKXevmM96ZOBZWWs-vj8Y,4801
|
|
17
|
+
mathai/parser.py,sha256=K6O5TR1PGl9LbSdGpcbwiwQva8r5-SwZ5fSp84oA8co,7025
|
|
18
|
+
mathai/printeq.py,sha256=MKsR6-qXig80R07vLnFPYHQMeS41FrMVj3n3arrhJpQ,1329
|
|
19
|
+
mathai/simplify.py,sha256=sI3Hw7pEFZrUZx5J8wZxwJbSZ2CBFcTrTHELW4kbpKg,19418
|
|
20
|
+
mathai/structure.py,sha256=wrU7kqphSN7CqaVffyHHXD2-3t5My_Z_TtYFoUe_lTU,4099
|
|
21
|
+
mathai/tool.py,sha256=ozcXTXLbKUnyPM9r9kz9M43YA2CBcWezcqLZfEs8rpc,6051
|
|
22
|
+
mathai/trig.py,sha256=fnBbfiopcQzFg4ya1BoO5M0X_aCBnse2bjnKh1juw4I,11223
|
|
23
|
+
mathai/univariate_inequality.py,sha256=WXp-vpAUDjQYwBupQ7M_a-Z9lFcoMlhlX45DRDVyDs8,15088
|
|
24
|
+
mathai-0.5.5.dist-info/METADATA,sha256=Jn1tgXWspkEK7pCQNL_AX5qE9D8z578TwVVdZd652lA,7103
|
|
25
|
+
mathai-0.5.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
26
|
+
mathai-0.5.5.dist-info/top_level.txt,sha256=ROP4l3OhGYw3ihkQGASr18xM9GsK4z3_6whV5AyXLwE,7
|
|
27
|
+
mathai-0.5.5.dist-info/RECORD,,
|
mathai-0.5.4.dist-info/RECORD
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
mathai/__init__.py,sha256=LNmGQztU8xBh7mjgbPemQZKRXythLwif56rDv3ksjs4,1539
|
|
2
|
-
mathai/apart.py,sha256=VSS3khE9PNuxiRvdU5JDl4IN-KJBSIFjwR17pkhviXI,4197
|
|
3
|
-
mathai/base.py,sha256=pduS0fRpFZR8O-MP-7lDuq1dU603mwfDpmBcT2FyJgI,12793
|
|
4
|
-
mathai/bivariate_inequality.py,sha256=FJOC2zKU5zWCMybCrhEQ7nVDgRO_w19Zko8WPTaDTSo,11411
|
|
5
|
-
mathai/console.py,sha256=Sn58iwYE79MLEh67s8X3q6vZjw6g7f9XM1T8_dBBR2o,3048
|
|
6
|
-
mathai/diff.py,sha256=YUBpRsz0qmBkq5vGxeGnvR4nMKjdOQiIXlNMxpij2ns,3051
|
|
7
|
-
mathai/expand.py,sha256=SnBltkpIENMGkP0AYmbMlSc4H-CF5RslO2PcBEkn1BQ,3359
|
|
8
|
-
mathai/factor.py,sha256=muPDOcClrqc2XyVlbyIrhiIqI0QxauYL3e2mq3qa6OI,11533
|
|
9
|
-
mathai/fraction.py,sha256=Q2ztsh5Bpz6YhML2QU0tfufbAs0Q6J319AhlzKephIY,4396
|
|
10
|
-
mathai/integrate.py,sha256=LMj7om6vTGbYiUwqN-y11fiD4YR_XMbL33AWgI2893o,16982
|
|
11
|
-
mathai/inverse.py,sha256=QCvDrzKquWsZv-BDAzZd9HnU0c3gZvcc44UztHVO5LQ,2919
|
|
12
|
-
mathai/limit.py,sha256=DoTBMGdbc47WPN2yo6XwES6Gc-GDDArDhF5uyDFPSC4,5710
|
|
13
|
-
mathai/linear.py,sha256=Mmmnn4IdnADRMuv6crB0a_Ba2drGUFXOh7eqIIkirYA,5709
|
|
14
|
-
mathai/logic.py,sha256=UvHzRmKcO9AD51tRzHmpNSEhgW5gmaf4XPaQKFjGfC4,9653
|
|
15
|
-
mathai/matrix.py,sha256=dWIXF5oInIL3SZ3naRzKN5ElI5drXJNiVTDM48hfZOw,972
|
|
16
|
-
mathai/ode.py,sha256=zxxTXAOpt7oSsfpgI4vHsCWKXevmM96ZOBZWWs-vj8Y,4801
|
|
17
|
-
mathai/parser.py,sha256=K6O5TR1PGl9LbSdGpcbwiwQva8r5-SwZ5fSp84oA8co,7025
|
|
18
|
-
mathai/printeq.py,sha256=gIes-pstFOa6FcnpVIVvkjVKuWdsVdo11LlEnmHhakU,1303
|
|
19
|
-
mathai/simplify.py,sha256=4-7yps_I_OQBd8NthF96H0R-ofA3cFSxgM4wDE45OvU,17217
|
|
20
|
-
mathai/structure.py,sha256=4Ww2IAx62RcQSO7_17TZES-DjMWBpcFQtL939FBIHwY,4103
|
|
21
|
-
mathai/tool.py,sha256=r8ejBY4Bnk_t8USYQCuxwmmJ4M-5H5OR6A3VbV7W-5w,6066
|
|
22
|
-
mathai/trig.py,sha256=BQd_Gl_u0g5ZuZIwKozuXKbMinqb6K-OYicrtftn7eg,11174
|
|
23
|
-
mathai/univariate_inequality.py,sha256=3Yr7d9mE-mUNkwOPQyFPBDp0-gKkqrpzEYeHFQ8JcXA,15060
|
|
24
|
-
mathai-0.5.4.dist-info/METADATA,sha256=WIcw95PJtFwsEyhCKVJJuNpQLUlROTfErTRC76nqUX8,7103
|
|
25
|
-
mathai-0.5.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
26
|
-
mathai-0.5.4.dist-info/top_level.txt,sha256=ROP4l3OhGYw3ihkQGASr18xM9GsK4z3_6whV5AyXLwE,7
|
|
27
|
-
mathai-0.5.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|