mathai 0.6.3__py3-none-any.whl → 0.6.4__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/base.py CHANGED
@@ -45,6 +45,9 @@ class TreeNode:
45
45
 
46
46
  else:
47
47
  self.children = list(sorted(sortable, key=lambda x: str_form(x)))
48
+ elif name == "f_mul" and TreeNode.matmul == 0:
49
+
50
+ self.children = children
48
51
  else:
49
52
  self.children = children
50
53
 
mathai/matrix.py CHANGED
@@ -60,6 +60,13 @@ def contains_neg(node):
60
60
  return True
61
61
  # ---------- multiplication (fully simplified) ----------
62
62
  def multiply(left,right):
63
+ left2, right2 = left, right
64
+ if left2.name != "f_pow":
65
+ left2 = left2 ** 1
66
+ if right2.name != "f_pow":
67
+ right2 = right2 ** 1
68
+ if left2.name == "f_pow" and right2.name == "f_pow" and left2.children[0]==right2.children[0]:
69
+ return simplify(left2.children[0]**(left2.children[1]+right2.children[1]))
63
70
  A,B = promote(left), promote(right)
64
71
 
65
72
  # vector · vector
@@ -79,23 +86,33 @@ def multiply(left,right):
79
86
  return None
80
87
 
81
88
  def fold_wmul(eq):
82
- if eq.name=="f_wmul" and any(item.name=="f_list" or item.name.startswith("v_-") for item in eq.children):
89
+ if eq.name == "f_pow" and eq.children[1].name.startswith("d_"):
90
+ n = int(eq.children[1].name[2:])
91
+ if n == 1:
92
+ eq = eq.children[0]
93
+ elif n > 1:
94
+ tmp = promote(eq.children[0])
95
+ if is_matrix(tmp):
96
+ orig =tmp
97
+ for i in range(n-1):
98
+ tmp = matmul(orig, tmp)
99
+ eq = py_to_tree(tmp)
100
+ elif eq.name=="f_wmul":
101
+
83
102
  i = len(eq.children)-1
84
103
  while i>0:
85
104
  out = multiply(eq.children[i], eq.children[i-1])
86
105
  if out is not None:
87
106
  eq.children.pop(i)
88
107
  eq.children.pop(i-1)
89
- eq.children.append(out)
108
+ eq.children.insert(i-1,out)
90
109
  i = i-1
91
- return eq
92
110
  return TreeNode(eq.name, [fold_wmul(child) for child in eq.children])
93
111
  def flat(eq):
94
- return flatten_tree(tree_form(str_form(eq).replace("f_w","f_")))
112
+ return flatten_tree(eq, ["f_wmul"])
95
113
  def matrix_solve(eq):
96
114
  if TreeNode.matmul == True:
97
115
  TreeNode.matmul = False
98
- eq = simplify(eq)
99
116
  eq = flat(dowhile(eq, lambda x: fold_wmul(flat(x))))
100
117
  TreeNode.matmul = True
101
118
  return eq
mathai/simplify.py CHANGED
@@ -20,7 +20,6 @@ def clear_div(eq, denom):
20
20
  return tree_form("d_0"), True
21
21
  lst3 = []
22
22
  for item in lst:
23
- print(str_form(item))
24
23
  if "v_" not in str_form(item) and compute(item) < 0:
25
24
  lst3.append(item)
26
25
  sign = denom
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 0.6.3
3
+ Version: 0.6.4
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai4
6
6
  Author: educated indians are having a low iq and are good for nothing
@@ -1,6 +1,6 @@
1
1
  mathai/__init__.py,sha256=gzddzgNCG3Bg5BnqrDYvO71SzK4hu9fbo4nGEaDaG5Q,1554
2
2
  mathai/apart.py,sha256=VSS3khE9PNuxiRvdU5JDl4IN-KJBSIFjwR17pkhviXI,4197
3
- mathai/base.py,sha256=_VIVHzJ2wYAJjPn7asNvrhlHOqTtOwUgmohvmA9pUso,15552
3
+ mathai/base.py,sha256=HSmUAUAVlKhjn-i3_IDoduyRzNrhw9kTHDgpUpahdK8,15660
4
4
  mathai/bivariate_inequality.py,sha256=Da-A1kqVynR0tNOlEI7GSTf5T2vNkcF4etL9-EoyPJg,11415
5
5
  mathai/console.py,sha256=Sn58iwYE79MLEh67s8X3q6vZjw6g7f9XM1T8_dBBR2o,3048
6
6
  mathai/diff.py,sha256=RSTwlfeddvYXUDShCeRdcPjsmAS8Vf5OkYJAaUBPaiM,3060
@@ -12,17 +12,17 @@ mathai/inverse.py,sha256=ya7P8WjzfaAL3UXL7xqOh5GaIsXLDZ-F6lZFy3IEgaQ,2931
12
12
  mathai/limit.py,sha256=9F8i9UZh2xb-V8A5Sd1gdhDf9c2RFgpE1GdNn9MvbWI,5703
13
13
  mathai/linear.py,sha256=viGlPU8BPrjLWHlyNUvnfPHNH5d4ZBImiQMdyXaKGg0,5702
14
14
  mathai/logic.py,sha256=Ndz4Fd6aNCmzFlqoPyyIpSmV_BXmYHsurePjLyZJoNc,9809
15
- mathai/matrix.py,sha256=atXZlgiDgqI3cRyQ78GrDCWiy7oWWelq-XHvC_kH_DE,3324
15
+ mathai/matrix.py,sha256=gExDBHre3f2JTkj63-58b2YKnlLhqVYszOaNTvG9maE,3927
16
16
  mathai/ode.py,sha256=zxxTXAOpt7oSsfpgI4vHsCWKXevmM96ZOBZWWs-vj8Y,4801
17
17
  mathai/parser.py,sha256=dhI4hRiYDdmSAOrhIWkBs_Boo2BFzC1m5cbAOOfHUas,7220
18
18
  mathai/parsetab.py,sha256=TL-4jvRM_Tx6ipwet8CFJc2DkjR4tGsbrGF_r4IC8xI,9651
19
19
  mathai/printeq.py,sha256=MKsR6-qXig80R07vLnFPYHQMeS41FrMVj3n3arrhJpQ,1329
20
- mathai/simplify.py,sha256=HeZqQbB9SD7CAduvotQOiv4hFqGe68ZmNLl9LLJ7sAo,19619
20
+ mathai/simplify.py,sha256=nvpwTLEgnGeXgc9NGGmQLAjKZ9c4XTdEVqAuo04oSrw,19588
21
21
  mathai/structure.py,sha256=wrU7kqphSN7CqaVffyHHXD2-3t5My_Z_TtYFoUe_lTU,4099
22
22
  mathai/tool.py,sha256=ozcXTXLbKUnyPM9r9kz9M43YA2CBcWezcqLZfEs8rpc,6051
23
23
  mathai/trig.py,sha256=fnBbfiopcQzFg4ya1BoO5M0X_aCBnse2bjnKh1juw4I,11223
24
24
  mathai/univariate_inequality.py,sha256=LPFdWgC1y5zBwnsy1wwZxj-yP_SbqFDhCmTTzhuwoiY,16469
25
- mathai-0.6.3.dist-info/METADATA,sha256=ecYnPYus3Nd-KLLG3JOi3YCocVvzqff3iZwgecdebiM,7103
26
- mathai-0.6.3.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
27
- mathai-0.6.3.dist-info/top_level.txt,sha256=ROP4l3OhGYw3ihkQGASr18xM9GsK4z3_6whV5AyXLwE,7
28
- mathai-0.6.3.dist-info/RECORD,,
25
+ mathai-0.6.4.dist-info/METADATA,sha256=vj85R6gzXafAT_M4LhpjwqOp_Ru32chy8M2SMiZGzaU,7103
26
+ mathai-0.6.4.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
27
+ mathai-0.6.4.dist-info/top_level.txt,sha256=ROP4l3OhGYw3ihkQGASr18xM9GsK4z3_6whV5AyXLwE,7
28
+ mathai-0.6.4.dist-info/RECORD,,
File without changes