mathai 0.2.9__py3-none-any.whl → 0.3.0__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 +16 -16
- mathai/apart.py +103 -103
- mathai/base.py +355 -355
- mathai/console.py +84 -84
- mathai/diff.py +65 -65
- mathai/expand.py +58 -58
- mathai/factor.py +125 -125
- mathai/fraction.py +59 -59
- mathai/integrate.py +346 -346
- mathai/inverse.py +65 -65
- mathai/limit.py +130 -130
- mathai/linear.py +152 -152
- mathai/logic.py +224 -224
- mathai/parser.py +158 -154
- mathai/printeq.py +34 -34
- mathai/simplify.py +358 -358
- mathai/structure.py +103 -103
- mathai/tool.py +35 -35
- mathai/trig.py +169 -169
- mathai/univariate_inequality.py +410 -410
- {mathai-0.2.9.dist-info → mathai-0.3.0.dist-info}/METADATA +231 -231
- mathai-0.3.0.dist-info/RECORD +24 -0
- {mathai-0.2.9.dist-info → mathai-0.3.0.dist-info}/WHEEL +1 -1
- mathai-0.2.9.dist-info/RECORD +0 -24
- {mathai-0.2.9.dist-info → mathai-0.3.0.dist-info}/top_level.txt +0 -0
mathai/__init__.py
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
from .expand import expand
|
2
|
-
from .parser import parse
|
3
|
-
from .printeq import printeq, printeq_log, printeq_str
|
4
|
-
from .simplify import solve, simplify, solve2
|
5
|
-
from .integrate import integrate, sqint, byparts
|
6
|
-
from .diff import diff
|
7
|
-
from .factor import factor, factor2
|
8
|
-
from .fraction import fraction
|
9
|
-
from .inverse import inverse
|
10
|
-
from .trig import trig0, trig1, trig2, trig3, trig4
|
11
|
-
from .logic import logic0, logic1, logic2, logic3
|
12
|
-
from .apart import apart
|
13
|
-
from .console import console
|
14
|
-
from .limit import limit
|
15
|
-
from .univariate_inequality import wavycurvy, absolute, domain, handle_sqrt
|
16
|
-
from .base import *
|
1
|
+
from .expand import expand
|
2
|
+
from .parser import parse
|
3
|
+
from .printeq import printeq, printeq_log, printeq_str
|
4
|
+
from .simplify import solve, simplify, solve2
|
5
|
+
from .integrate import integrate, sqint, byparts
|
6
|
+
from .diff import diff
|
7
|
+
from .factor import factor, factor2
|
8
|
+
from .fraction import fraction
|
9
|
+
from .inverse import inverse
|
10
|
+
from .trig import trig0, trig1, trig2, trig3, trig4
|
11
|
+
from .logic import logic0, logic1, logic2, logic3
|
12
|
+
from .apart import apart
|
13
|
+
from .console import console
|
14
|
+
from .limit import limit
|
15
|
+
from .univariate_inequality import wavycurvy, absolute, domain, handle_sqrt
|
16
|
+
from .base import *
|
mathai/apart.py
CHANGED
@@ -1,103 +1,103 @@
|
|
1
|
-
from .linear import linear_solve
|
2
|
-
from .expand import expand
|
3
|
-
from .simplify import simplify
|
4
|
-
from .diff import diff
|
5
|
-
from .inverse import inverse
|
6
|
-
from .base import *
|
7
|
-
import math
|
8
|
-
from .tool import poly
|
9
|
-
|
10
|
-
def apart(eq, v="v_0"):
|
11
|
-
eq = simplify(eq)
|
12
|
-
if eq.name != "f_mul":
|
13
|
-
return eq
|
14
|
-
if any("f_"+item in str_form(eq) for item in "sin cos tan log".split(" ")):
|
15
|
-
return eq
|
16
|
-
def exclude(eq):
|
17
|
-
if eq.name == "f_pow" and eq.children[1].name[:2] != "d_":
|
18
|
-
return False
|
19
|
-
if any(not exclude(child) for child in eq.children):
|
20
|
-
return False
|
21
|
-
return True
|
22
|
-
|
23
|
-
if not exclude(eq):
|
24
|
-
return eq
|
25
|
-
|
26
|
-
def countfac(lst, eq):
|
27
|
-
count=0
|
28
|
-
for item in lst:
|
29
|
-
if simplify(expand(simplify(eq - item))) == tree_form("d_0"):
|
30
|
-
count += 1
|
31
|
-
return tree_form("d_"+str(count))
|
32
|
-
|
33
|
-
alloclst = []
|
34
|
-
for i in range(0,26):
|
35
|
-
if "v_"+str(i) not in vlist(eq):
|
36
|
-
alloclst.append(tree_form("v_"+str(i)))
|
37
|
-
|
38
|
-
nn, d = num_dem(eq)
|
39
|
-
|
40
|
-
s = []
|
41
|
-
facd = [simplify(x) for x in factor_generation(simplify(d))]
|
42
|
-
|
43
|
-
|
44
|
-
facd2 = remove_duplicates_custom(facd, lambda m, n: simplify(m-n) == tree_form("d_0"))
|
45
|
-
if len(facd2) == 1:
|
46
|
-
return eq
|
47
|
-
x = tree_form(v)
|
48
|
-
num = []
|
49
|
-
dem = []
|
50
|
-
for item in facd2:
|
51
|
-
|
52
|
-
g = countfac(facd, item)
|
53
|
-
for n in range(int(g.name[2:])):
|
54
|
-
n = n+1
|
55
|
-
if n > 2:
|
56
|
-
return eq
|
57
|
-
n = tree_form("d_"+str(n))
|
58
|
-
l = len(poly(item, v))
|
59
|
-
if l == 3:
|
60
|
-
a = alloclst.pop(0)
|
61
|
-
b = alloclst.pop(0)
|
62
|
-
if n == tree_form("d_1"):
|
63
|
-
num.append(a*x+ b)
|
64
|
-
dem.append(item)
|
65
|
-
s.append((a*x+ b)/item)
|
66
|
-
else:
|
67
|
-
num.append(a*x+ b)
|
68
|
-
dem.append(item**n)
|
69
|
-
s.append((a*x+ b)/item**n)
|
70
|
-
elif l == 2:
|
71
|
-
a = alloclst.pop(0)
|
72
|
-
if n == tree_form("d_1"):
|
73
|
-
num.append(a)
|
74
|
-
dem.append(item)
|
75
|
-
s.append(a/item)
|
76
|
-
else:
|
77
|
-
num.append(a)
|
78
|
-
dem.append(item**n)
|
79
|
-
s.append(a/item**n)
|
80
|
-
else:
|
81
|
-
return eq
|
82
|
-
final3 = summation(s)
|
83
|
-
|
84
|
-
eq2 = simplify(nn*product(dem)/d)
|
85
|
-
|
86
|
-
final2 = []
|
87
|
-
for i in range(len(num)):
|
88
|
-
final2.append(product([dem[k] for k in range(len(dem)) if i != k])*num[i])
|
89
|
-
|
90
|
-
final = summation(final2)
|
91
|
-
|
92
|
-
s = simplify(TreeNode("f_eq", [final-eq2, tree_form("d_0")]))
|
93
|
-
|
94
|
-
lst = poly(s.children[0], v)
|
95
|
-
|
96
|
-
lst = [TreeNode("f_eq", [item, tree_form("d_0")]) for item in lst if "v_" in str_form(item)]
|
97
|
-
|
98
|
-
out = linear_solve(TreeNode("f_and", lst))
|
99
|
-
|
100
|
-
for item in out.children:
|
101
|
-
|
102
|
-
final3 = replace(final3, tree_form(vlist(item)[0]), inverse(item.children[0], vlist(item)[0]))
|
103
|
-
return simplify(final3)
|
1
|
+
from .linear import linear_solve
|
2
|
+
from .expand import expand
|
3
|
+
from .simplify import simplify
|
4
|
+
from .diff import diff
|
5
|
+
from .inverse import inverse
|
6
|
+
from .base import *
|
7
|
+
import math
|
8
|
+
from .tool import poly
|
9
|
+
|
10
|
+
def apart(eq, v="v_0"):
|
11
|
+
eq = simplify(eq)
|
12
|
+
if eq.name != "f_mul":
|
13
|
+
return eq
|
14
|
+
if any("f_"+item in str_form(eq) for item in "sin cos tan log".split(" ")):
|
15
|
+
return eq
|
16
|
+
def exclude(eq):
|
17
|
+
if eq.name == "f_pow" and eq.children[1].name[:2] != "d_":
|
18
|
+
return False
|
19
|
+
if any(not exclude(child) for child in eq.children):
|
20
|
+
return False
|
21
|
+
return True
|
22
|
+
|
23
|
+
if not exclude(eq):
|
24
|
+
return eq
|
25
|
+
|
26
|
+
def countfac(lst, eq):
|
27
|
+
count=0
|
28
|
+
for item in lst:
|
29
|
+
if simplify(expand(simplify(eq - item))) == tree_form("d_0"):
|
30
|
+
count += 1
|
31
|
+
return tree_form("d_"+str(count))
|
32
|
+
|
33
|
+
alloclst = []
|
34
|
+
for i in range(0,26):
|
35
|
+
if "v_"+str(i) not in vlist(eq):
|
36
|
+
alloclst.append(tree_form("v_"+str(i)))
|
37
|
+
|
38
|
+
nn, d = num_dem(eq)
|
39
|
+
|
40
|
+
s = []
|
41
|
+
facd = [simplify(x) for x in factor_generation(simplify(d))]
|
42
|
+
|
43
|
+
|
44
|
+
facd2 = remove_duplicates_custom(facd, lambda m, n: simplify(m-n) == tree_form("d_0"))
|
45
|
+
if len(facd2) == 1:
|
46
|
+
return eq
|
47
|
+
x = tree_form(v)
|
48
|
+
num = []
|
49
|
+
dem = []
|
50
|
+
for item in facd2:
|
51
|
+
|
52
|
+
g = countfac(facd, item)
|
53
|
+
for n in range(int(g.name[2:])):
|
54
|
+
n = n+1
|
55
|
+
if n > 2:
|
56
|
+
return eq
|
57
|
+
n = tree_form("d_"+str(n))
|
58
|
+
l = len(poly(item, v))
|
59
|
+
if l == 3:
|
60
|
+
a = alloclst.pop(0)
|
61
|
+
b = alloclst.pop(0)
|
62
|
+
if n == tree_form("d_1"):
|
63
|
+
num.append(a*x+ b)
|
64
|
+
dem.append(item)
|
65
|
+
s.append((a*x+ b)/item)
|
66
|
+
else:
|
67
|
+
num.append(a*x+ b)
|
68
|
+
dem.append(item**n)
|
69
|
+
s.append((a*x+ b)/item**n)
|
70
|
+
elif l == 2:
|
71
|
+
a = alloclst.pop(0)
|
72
|
+
if n == tree_form("d_1"):
|
73
|
+
num.append(a)
|
74
|
+
dem.append(item)
|
75
|
+
s.append(a/item)
|
76
|
+
else:
|
77
|
+
num.append(a)
|
78
|
+
dem.append(item**n)
|
79
|
+
s.append(a/item**n)
|
80
|
+
else:
|
81
|
+
return eq
|
82
|
+
final3 = summation(s)
|
83
|
+
|
84
|
+
eq2 = simplify(nn*product(dem)/d)
|
85
|
+
|
86
|
+
final2 = []
|
87
|
+
for i in range(len(num)):
|
88
|
+
final2.append(product([dem[k] for k in range(len(dem)) if i != k])*num[i])
|
89
|
+
|
90
|
+
final = summation(final2)
|
91
|
+
|
92
|
+
s = simplify(TreeNode("f_eq", [final-eq2, tree_form("d_0")]))
|
93
|
+
|
94
|
+
lst = poly(s.children[0], v)
|
95
|
+
|
96
|
+
lst = [TreeNode("f_eq", [item, tree_form("d_0")]) for item in lst if "v_" in str_form(item)]
|
97
|
+
|
98
|
+
out = linear_solve(TreeNode("f_and", lst))
|
99
|
+
|
100
|
+
for item in out.children:
|
101
|
+
|
102
|
+
final3 = replace(final3, tree_form(vlist(item)[0]), inverse(item.children[0], vlist(item)[0]))
|
103
|
+
return simplify(final3)
|