mathai 2.0.2__tar.gz → 2.0.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.
Files changed (38) hide show
  1. {mathai-2.0.2 → mathai-2.0.3}/PKG-INFO +1 -1
  2. {mathai-2.0.2 → mathai-2.0.3}/mathai/formula_compiler.py +3 -2
  3. {mathai-2.0.2 → mathai-2.0.3}/mathai/formula_data.py +6 -5
  4. {mathai-2.0.2 → mathai-2.0.3}/mathai/integrate.py +26 -15
  5. {mathai-2.0.2 → mathai-2.0.3}/mathai.egg-info/PKG-INFO +1 -1
  6. {mathai-2.0.2 → mathai-2.0.3}/setup.py +1 -1
  7. {mathai-2.0.2 → mathai-2.0.3}/README.md +0 -0
  8. {mathai-2.0.2 → mathai-2.0.3}/mathai/__init__.py +0 -0
  9. {mathai-2.0.2 → mathai-2.0.3}/mathai/apart.py +0 -0
  10. {mathai-2.0.2 → mathai-2.0.3}/mathai/base.py +0 -0
  11. {mathai-2.0.2 → mathai-2.0.3}/mathai/decision.py +0 -0
  12. {mathai-2.0.2 → mathai-2.0.3}/mathai/diff.py +0 -0
  13. {mathai-2.0.2 → mathai-2.0.3}/mathai/expand.py +0 -0
  14. {mathai-2.0.2 → mathai-2.0.3}/mathai/factor.py +0 -0
  15. {mathai-2.0.2 → mathai-2.0.3}/mathai/fraction.py +0 -0
  16. {mathai-2.0.2 → mathai-2.0.3}/mathai/inverse.py +0 -0
  17. {mathai-2.0.2 → mathai-2.0.3}/mathai/lambda_calculus.py +0 -0
  18. {mathai-2.0.2 → mathai-2.0.3}/mathai/limit.py +0 -0
  19. {mathai-2.0.2 → mathai-2.0.3}/mathai/linear.py +0 -0
  20. {mathai-2.0.2 → mathai-2.0.3}/mathai/logic.py +0 -0
  21. {mathai-2.0.2 → mathai-2.0.3}/mathai/matrix.py +0 -0
  22. {mathai-2.0.2 → mathai-2.0.3}/mathai/ml.py +0 -0
  23. {mathai-2.0.2 → mathai-2.0.3}/mathai/mlscalar.py +0 -0
  24. {mathai-2.0.2 → mathai-2.0.3}/mathai/ode.py +0 -0
  25. {mathai-2.0.2 → mathai-2.0.3}/mathai/parser.py +0 -0
  26. {mathai-2.0.2 → mathai-2.0.3}/mathai/pde.py +0 -0
  27. {mathai-2.0.2 → mathai-2.0.3}/mathai/printeq.py +0 -0
  28. {mathai-2.0.2 → mathai-2.0.3}/mathai/qm.py +0 -0
  29. {mathai-2.0.2 → mathai-2.0.3}/mathai/simplify.py +0 -0
  30. {mathai-2.0.2 → mathai-2.0.3}/mathai/statistics.py +0 -0
  31. {mathai-2.0.2 → mathai-2.0.3}/mathai/test.py +0 -0
  32. {mathai-2.0.2 → mathai-2.0.3}/mathai/tool.py +0 -0
  33. {mathai-2.0.2 → mathai-2.0.3}/mathai/trig.py +0 -0
  34. {mathai-2.0.2 → mathai-2.0.3}/mathai/univariate_inequality.py +0 -0
  35. {mathai-2.0.2 → mathai-2.0.3}/mathai.egg-info/SOURCES.txt +0 -0
  36. {mathai-2.0.2 → mathai-2.0.3}/mathai.egg-info/dependency_links.txt +0 -0
  37. {mathai-2.0.2 → mathai-2.0.3}/mathai.egg-info/top_level.txt +0 -0
  38. {mathai-2.0.2 → mathai-2.0.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai
6
6
  Requires-Python: >=3.7
@@ -3,6 +3,7 @@ import itertools
3
3
  from .base import *
4
4
  from .parser import parse
5
5
  from fractions import Fraction
6
+ from .simplify import simplify
6
7
  def simplify0_h(eq):
7
8
  if eq.name == "f_add":
8
9
  lst = [item for item in eq.children if item.name != "d_0"]
@@ -293,7 +294,7 @@ def structure(
293
294
  for key, item3 in varlist.items():
294
295
  local_pos = replace(local_pos, tree_form(key), item3)
295
296
  s = print_code2(local_pos)
296
- s = f"simplify0({s})==0 or (compute({s}) is not None and compute({s})>0)"
297
+ s = f"simplify({s})==0 or (compute({s}) is not None and compute({s})>0)"
297
298
  d.append(TreeNode(s))
298
299
  for item2 in negative:
299
300
  local_neg = copy.deepcopy(item2)
@@ -443,7 +444,7 @@ def formula_compiler(lst_formula):
443
444
  "contain": contain,
444
445
  "str_form": str_form,
445
446
  "copy":copy,
446
- "simplify0":simplify0,
447
+ "simplify":simplify,
447
448
  "compute":compute,
448
449
  "remove_all":remove_all,
449
450
  }
@@ -14,9 +14,10 @@ formula_data = {}
14
14
  # negative constraint
15
15
  # associative arity
16
16
  formula = """
17
- integrate(1/(a*x+b),x) log(abs(a*x+b))/a x _ [a,b] _ [a,0] _ _ 6
18
- integrate((a*x+b)^c,x) (a*x+b)^(c+1)/(a*(c+1)) x _ [a,b,c] _ [[a,0],[c,-1]] _ _ 1
19
- // dummy
17
+ a*x^2+b*x+c true x _ [a,b,c] _ [a,0] _ _ 2
18
+ a*x+b true x _ [a,b] _ [a,0] _ _ 4
19
+ a false _ _ _ _ _ _ _ 1
20
+ // is_integrate_subs
20
21
 
21
22
  integrate(x^2*e^(a*x+b),x) ((x^2/a)-(2*x/(a^2))+(2/(a^3)))*e^(a*x+b) x _ [a,b] _ [a,0] _ _ 6
22
23
  integrate(x*e^(a*x+b),x) ((x/a)-(1/(a^2)))*e^(a*x+b) x _ [a,b] _ [a,0] _ _ 6
@@ -114,7 +115,7 @@ a*x^2+b*x+c a*(x-(-b+sqrt(b^2-4*a*c))/(2*a))*(x-(-b-sqrt(b^2-4*a*c))/(2*a)) _ x
114
115
  """
115
116
 
116
117
  def load_formula(label):
117
- global formula_data
118
+ global formula_data
118
119
  return formula_data[label]
119
120
  def convert_lst(eq):
120
121
  if eq.name == "f_list":
@@ -144,7 +145,7 @@ def init_formula(label_list="all"):
144
145
  for item in formula.strip().split("\n\n"):
145
146
  item = item.split("\n")
146
147
  item[-1] = item[-1][3:]
147
- if label_list == "all" or item[-1] in label_list:
148
+ if label_list == "all" or item[-1] in label_list or (label_list == "god" and item[-1] in "is_integrate_subs differentiation integration quadratic trigonometry_misc".split(" ")):
148
149
  formula_data[item[-1]] = compile_formula("\n".join(item[:-1]))
149
150
  print(f"{item[-1]} formula set compiled")
150
151
  print()
@@ -16,7 +16,13 @@ from .trig import trig0, trig2, trig3, trig4, trig1, trig5, trig6
16
16
  from .apart import apart, apart2
17
17
  from .univariate_inequality import wavycurvy, eq2range, range2eq2, Range
18
18
  from .printeq import *
19
-
19
+ def all_branch(eq):
20
+ if eq.children == []:
21
+ return []
22
+ out = [eq.name]
23
+ for child in eq.children:
24
+ out += all_branch(child)
25
+ return list(set(out))
20
26
  def subs_heuristic(eq, var):
21
27
  output = []
22
28
  last = []
@@ -27,6 +33,8 @@ def subs_heuristic(eq, var):
27
33
  if eq.name in ["f_pow"] and var.name in str_form(eq):
28
34
  if eq.children[1].name[:2] != "v_":
29
35
  output.append(str_form(eq))
36
+ if eq.name in ["f_arctan"] and var.name in str_form(eq.children[0]):
37
+ output.append(str_form(eq))
30
38
  if eq.name in ["f_pow", "f_sin", "f_cos", "f_arcsin"] and var.name in str_form(eq.children[0]):
31
39
  if eq.children[0].name[:2] != "v_":
32
40
  output.append(str_form(eq.children[0]))
@@ -52,21 +60,19 @@ def subs_heuristic(eq, var):
52
60
  tmp = list(set([simplify(tree_form(x)) for x in output]))
53
61
  tmp = sorted(tmp, key=lambda x: len(str_form(x)))
54
62
  poly_term = None
55
- term_degree = 20
63
+ fx = load_formula("is_integrate_subs")
56
64
  output = []
57
- for item in tmp:
58
- n = poly(simplify(item), var.name)
59
- if n is None:
60
- output.append(item)
61
- else:
62
- if term_degree > len(n):
65
+ if set(all_branch(eq)) <= set("f_add f_mul f_pow".split(" ")):
66
+ for item in tmp:
67
+ if fx(item).name == "s_true":
63
68
  poly_term = item
64
- term_degree = len(n)
69
+ else:
70
+ output.append(item)
65
71
  p = None
66
72
  if poly_term is None:
67
73
  p = tmp
68
74
  else:
69
- p = [poly_term]+output
75
+ p = output+[poly_term]
70
76
  last = list(set(last))
71
77
  if len(p)>3:
72
78
  p = p[:3]
@@ -164,17 +170,22 @@ def integrate_subs(equation, term, v1, v2, extra):
164
170
  eq = equation
165
171
  termeq = term
166
172
  t = inverse(copy.deepcopy(termeq), v1)
167
- g = inverse(termeq, v2)
173
+ g = inverse(copy.deepcopy(termeq), v2)
168
174
  if g is None:
169
175
  return none
170
176
  if t is None:
171
177
  return none
172
178
  else:
173
179
  t = expand(t)
174
- eq = replace(eq, tree_form(v1), t)
175
- eq2 = replace(diff(g, v1), tree_form(v1), t)
176
- equation = eq/eq2
177
- equation = simplify(equation)
180
+ eq3 = diff(g, v1)
181
+ eq2 = replace(eq, g, tree_form(v2))
182
+ eq4 = simplify(eq2/eq3)
183
+ if not contain(eq4, tree_form(v1)):
184
+ equation = eq4
185
+ else:
186
+ eq = replace(eq, tree_form(v1), t)
187
+ equation = eq/eq3
188
+ equation = simplify(equation)
178
189
  if v1 in str_form(equation):
179
190
  return none
180
191
  return dowhile(TreeNode("f_subs", [TreeNode("f_integrate", [simplify(equation), tree_form(origv2)]),tree_form(origv2) ,g]+extra), lambda x: simplify(trig4(trig0(x))))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai
6
6
  Requires-Python: >=3.7
@@ -3,7 +3,7 @@ from pathlib import Path
3
3
 
4
4
  setup(
5
5
  name="mathai",
6
- version="2.0.2",
6
+ version="2.0.3",
7
7
  description="Mathematics solving Ai tailored to NCERT",
8
8
  long_description=Path("README.md").read_text(encoding="utf-8"),
9
9
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes