mathai 0.7.5__py3-none-any.whl → 0.7.6__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 CHANGED
@@ -11,14 +11,12 @@ from .printeq import printeq, printeq_str
11
11
 
12
12
  from .simplify import simplify
13
13
 
14
- from .integrate import ref as integrate_save
15
14
  from .integrate import integrate_subs_main as integrate_subs
16
15
  from .integrate import byparts as integrate_byparts
17
16
  from .integrate import sqint as integrate_fraction
18
17
  from .integrate import integrate_summation
19
18
  from .integrate import rm_const as integrate_const
20
19
  from .integrate import solve_integrate as integrate_clean
21
- from .integrate import inteq as integrate_recursive
22
20
  from .integrate import integrate_formula
23
21
 
24
22
  from .diff import diff
mathai/integrate.py CHANGED
@@ -376,6 +376,7 @@ def integration_formula_init():
376
376
  (f"1/cos(A*{var}+B)^2", f"tan(A*{var}+B)/A"),
377
377
  (f"1/sin(A*{var}+B)", f"log(abs(tan((A*{var}+B)/2)))/A"),
378
378
  (f"1/cos(A*{var}+B)^3", f"(sec(A*{var}+B)*tan(A*{var}+B)+log(abs(sec(A*{var}+B)+tan(A*{var}+B))))/(2*A)")
379
+ #(f"cos({var})*e^(A*{var})", f"e^(A*{var})/(A^2+1)*(A*cos({var})+sin({var}))")
379
380
  ]
380
381
  formula_list = [[simplify(parse(y)) for y in x] for x in formula_list]
381
382
  expr = [[parse("A"), parse("1")], [parse("B"), parse("0")]]
@@ -449,13 +450,18 @@ def integrate_formula(equation):
449
450
  if out is not None:
450
451
 
451
452
  return out
452
- expr_str = str_form(shorten(integrand))
453
- if len(expr_str) < 30:
453
+
454
+ short = shorten(integrand)
455
+ expr_str = str_form(short)
456
+
457
+ if len(str(short)) < 25:
458
+
454
459
  if expr_str.count("f_sin") + expr_str.count("f_cos") > 2:
455
460
  out = transform_formula(integrand, wrt.name, formula_gen4[0], formula_gen4[1], formula_gen4[2])
456
461
  if out is not None:
457
462
  return out
458
463
  if "f_cos" in expr_str and contain(integrand, tree_form("s_e")):
464
+
459
465
  out = transform_formula(integrand, wrt.name, formula_gen11[0], formula_gen11[1], formula_gen11[2])
460
466
  if out is not None:
461
467
  return out
mathai/ode.py CHANGED
@@ -1,3 +1,4 @@
1
+ from collections import Counter
1
2
  from .diff import diff
2
3
  from .factor import factor
3
4
  from .expand import expand
@@ -131,5 +132,60 @@ def diffsolve(eq):
131
132
  eq2 = diffsolve_sep2(eq2)
132
133
  if eq2 is not None:
133
134
  return e0(TreeNode("f_subs", [replace(eq2.children[0],b,c), c,b/a]).fx("try"))
134
- return orig
135
+ eq = orig
136
+
137
+ eq = fraction(eq)
138
+ eq = simplify(eq)
139
+ for i in range(2):
140
+ out = linear_dif(eq, tree_form(f"v_{i}"), tree_form(f"v_{1-i}"))
141
+ if out is not None:
142
+ return out
135
143
  return eq
144
+ def clist(x):
145
+ return list(x.elements())
146
+ def collect_term(eq, term_lst):
147
+
148
+ lst = None
149
+ if eq.name == "f_add":
150
+ lst = eq.children
151
+ else:
152
+ lst = [eq]
153
+
154
+ other = []
155
+ dic = {}
156
+ term_lst = sorted(term_lst, key=lambda x: -len(factor_generation(x)))
157
+ for item2 in lst:
158
+ done = True
159
+ tmp2 = Counter(factor_generation(item2))
160
+ for index, item in enumerate(term_lst):
161
+ tmp = Counter(factor_generation(item))
162
+
163
+ if (tmp2&tmp) == tmp and clist((tmp2 - tmp)&tmp)==[]:
164
+ if item in dic.keys():
165
+ dic[item] += product(clist(tmp2-tmp))
166
+ else:
167
+ dic[item] = product(clist(tmp2-tmp))
168
+ done = False
169
+ break
170
+ if done:
171
+ other.append(item2)
172
+ other = summation(other)
173
+
174
+ for key in dic.keys():
175
+ dic[key] = simplify(dic[key])
176
+ return [dic, simplify(other)]
177
+ def linear_dif(eq, a, b):
178
+ eq = simplify(eq)
179
+ out = collect_term(eq.children[0], [b.fx("dif"), b*a.fx("dif"), a.fx("dif")])
180
+
181
+ if out[1] == tree_form("d_0"):
182
+ tmp = out[0][b.fx("dif")]
183
+ if tmp != tree_form("d_0"):
184
+
185
+ for key in out[0].keys():
186
+ out[0][key] = simplify(out[0][key]/tmp)
187
+ p, q = out[0][b*a.fx("dif")], -out[0][a.fx("dif")]
188
+
189
+ f = tree_form("s_e") ** TreeNode("f_integrate", [p, a])
190
+ return simplify(TreeNode("f_eq", [b*f, TreeNode("f_integrate", [q*f, a])+allocvar()]))
191
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 0.7.5
3
+ Version: 0.7.6
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai4
6
6
  Requires-Python: >=3.7
@@ -1,4 +1,4 @@
1
- mathai/__init__.py,sha256=elVGU1vjxbvzY3CQ8M5kzj5i6o8YyCsdb2vw-kSxTN0,1575
1
+ mathai/__init__.py,sha256=uSG7914Pp9wW9801C38J76gWD3MIoJa5hbJyVEpXfgg,1476
2
2
  mathai/apart.py,sha256=VSS3khE9PNuxiRvdU5JDl4IN-KJBSIFjwR17pkhviXI,4197
3
3
  mathai/base.py,sha256=XNmXWADG7mA4AeyFbCUsjBvUzDnw8AzWscX0Cc3GjvA,14854
4
4
  mathai/bivariate_inequality.py,sha256=Da-A1kqVynR0tNOlEI7GSTf5T2vNkcF4etL9-EoyPJg,11415
@@ -7,13 +7,13 @@ mathai/diff.py,sha256=3__PoEqs_JlS2fRkebXyL-7eyV69ZoV8vCjpYgDWcXE,3297
7
7
  mathai/expand.py,sha256=IuzMX6emCT480VE27aCtR0eWU-rJ2VElvRLVa2xcRw0,2582
8
8
  mathai/factor.py,sha256=mz_UlPuAqwvsextLB0FM5KWIuuDiMMKG51bXrofqzw8,12830
9
9
  mathai/fraction.py,sha256=3Qer3K20ZO2exMAYp1z80H69qRjVMfWKg5Ik0Ud8wf4,4402
10
- mathai/integrate.py,sha256=C_lqYgQN4UiriCb_LDkpwtKx7XJhp_K8T9skCkxWqas,17208
10
+ mathai/integrate.py,sha256=nUE2_ubklNIfj6QGtZTGuZmprYX-U3Ln454W-I1JddQ,17365
11
11
  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
15
  mathai/matrix.py,sha256=MFe6tUL4a3jYuP13fXWGwER_34AbqfoOK5kHwVHfsKk,7169
16
- mathai/ode.py,sha256=csfXXodMmfujl5klMQFXFqQsm31mfqJC0R3A-Fh2XA0,5297
16
+ mathai/ode.py,sha256=vQmCedrfC8-Z0nTSogDYyFu7ASk9pu0E2iYLsfw0zvw,7152
17
17
  mathai/parser.py,sha256=FcjOTM_2-YFqPNS9EyZfo76pa4CedDJCbcs8wOXc_uU,7130
18
18
  mathai/parsetab.py,sha256=TL-4jvRM_Tx6ipwet8CFJc2DkjR4tGsbrGF_r4IC8xI,9651
19
19
  mathai/printeq.py,sha256=4UgLJo-vV_YlVw_3QUQY_jQMHrFnG-ZKAyVZsd7yD6o,1450
@@ -23,7 +23,7 @@ mathai/structure.py,sha256=wrU7kqphSN7CqaVffyHHXD2-3t5My_Z_TtYFoUe_lTU,4099
23
23
  mathai/tool.py,sha256=ozcXTXLbKUnyPM9r9kz9M43YA2CBcWezcqLZfEs8rpc,6051
24
24
  mathai/trig.py,sha256=fnBbfiopcQzFg4ya1BoO5M0X_aCBnse2bjnKh1juw4I,11223
25
25
  mathai/univariate_inequality.py,sha256=LPFdWgC1y5zBwnsy1wwZxj-yP_SbqFDhCmTTzhuwoiY,16469
26
- mathai-0.7.5.dist-info/METADATA,sha256=GSXYZlfllT4oNidG0NEqx549V4kq5GMgyCwNSAh1K-k,7735
27
- mathai-0.7.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
28
- mathai-0.7.5.dist-info/top_level.txt,sha256=ROP4l3OhGYw3ihkQGASr18xM9GsK4z3_6whV5AyXLwE,7
29
- mathai-0.7.5.dist-info/RECORD,,
26
+ mathai-0.7.6.dist-info/METADATA,sha256=CtT2xE0HxPzOuwYgjgbr-jU-idsfJC8Zh8azf53h3eA,7735
27
+ mathai-0.7.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
28
+ mathai-0.7.6.dist-info/top_level.txt,sha256=ROP4l3OhGYw3ihkQGASr18xM9GsK4z3_6whV5AyXLwE,7
29
+ mathai-0.7.6.dist-info/RECORD,,
File without changes