mathai 2.3.8__tar.gz → 2.3.9__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 (41) hide show
  1. {mathai-2.3.8 → mathai-2.3.9}/PKG-INFO +1 -1
  2. {mathai-2.3.8 → mathai-2.3.9}/mathai/__init__.py +2 -0
  3. {mathai-2.3.8 → mathai-2.3.9}/mathai/apart.py +4 -1
  4. mathai-2.3.9/mathai/benchmark.py +18 -0
  5. {mathai-2.3.8 → mathai-2.3.9}/mathai/decision.py +30 -19
  6. {mathai-2.3.8 → mathai-2.3.9}/mathai/integrate.py +10 -8
  7. mathai-2.3.9/mathai/ncert_data.txt +61 -0
  8. {mathai-2.3.8 → mathai-2.3.9}/mathai.egg-info/PKG-INFO +1 -1
  9. {mathai-2.3.8 → mathai-2.3.9}/mathai.egg-info/SOURCES.txt +2 -0
  10. {mathai-2.3.8 → mathai-2.3.9}/setup.py +5 -1
  11. {mathai-2.3.8 → mathai-2.3.9}/README.md +0 -0
  12. {mathai-2.3.8 → mathai-2.3.9}/mathai/base.py +0 -0
  13. {mathai-2.3.8 → mathai-2.3.9}/mathai/diff.py +0 -0
  14. {mathai-2.3.8 → mathai-2.3.9}/mathai/electronic.py +0 -0
  15. {mathai-2.3.8 → mathai-2.3.9}/mathai/expand.py +0 -0
  16. {mathai-2.3.8 → mathai-2.3.9}/mathai/factor.py +0 -0
  17. {mathai-2.3.8 → mathai-2.3.9}/mathai/formula_applier.py +0 -0
  18. {mathai-2.3.8 → mathai-2.3.9}/mathai/fraction.py +0 -0
  19. {mathai-2.3.8 → mathai-2.3.9}/mathai/graphics.py +0 -0
  20. {mathai-2.3.8 → mathai-2.3.9}/mathai/inverse.py +0 -0
  21. {mathai-2.3.8 → mathai-2.3.9}/mathai/lambda_calculus.py +0 -0
  22. {mathai-2.3.8 → mathai-2.3.9}/mathai/limit.py +0 -0
  23. {mathai-2.3.8 → mathai-2.3.9}/mathai/linear.py +0 -0
  24. {mathai-2.3.8 → mathai-2.3.9}/mathai/logic.py +0 -0
  25. {mathai-2.3.8 → mathai-2.3.9}/mathai/matrix.py +0 -0
  26. {mathai-2.3.8 → mathai-2.3.9}/mathai/ml.py +0 -0
  27. {mathai-2.3.8 → mathai-2.3.9}/mathai/mlscalar.py +0 -0
  28. {mathai-2.3.8 → mathai-2.3.9}/mathai/ode.py +0 -0
  29. {mathai-2.3.8 → mathai-2.3.9}/mathai/parser.py +0 -0
  30. {mathai-2.3.8 → mathai-2.3.9}/mathai/pde.py +0 -0
  31. {mathai-2.3.8 → mathai-2.3.9}/mathai/printeq.py +0 -0
  32. {mathai-2.3.8 → mathai-2.3.9}/mathai/qm.py +0 -0
  33. {mathai-2.3.8 → mathai-2.3.9}/mathai/simplify.py +0 -0
  34. {mathai-2.3.8 → mathai-2.3.9}/mathai/statistics.py +0 -0
  35. {mathai-2.3.8 → mathai-2.3.9}/mathai/test.py +0 -0
  36. {mathai-2.3.8 → mathai-2.3.9}/mathai/tool.py +0 -0
  37. {mathai-2.3.8 → mathai-2.3.9}/mathai/trig.py +0 -0
  38. {mathai-2.3.8 → mathai-2.3.9}/mathai/univariate_inequality.py +0 -0
  39. {mathai-2.3.8 → mathai-2.3.9}/mathai.egg-info/dependency_links.txt +0 -0
  40. {mathai-2.3.8 → mathai-2.3.9}/mathai.egg-info/top_level.txt +0 -0
  41. {mathai-2.3.8 → mathai-2.3.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 2.3.8
3
+ Version: 2.3.9
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai
6
6
  Requires-Python: >=3.7
@@ -7,6 +7,8 @@ from .qm import hydrogen_gse, helium_gse, power_rule
7
7
 
8
8
  from .graphics import draw_graphics_from_solution, solve_graphics, solve_graphics_string
9
9
 
10
+ from .benchmark import benchmark_ncert
11
+
10
12
  from .lambda_calculus import lambda_expand, lambda_compress, lambda_reduce
11
13
 
12
14
  from .electronic import Edge, CircuitGraph, find_resistance
@@ -51,7 +51,10 @@ def _apart(eq, v=None):
51
51
  if n > 3:
52
52
  return eq
53
53
  n = tree_form("d_"+str(n))
54
- l = len(poly(item, v))
54
+ l = poly(item, v)
55
+ if l is None:
56
+ return eq
57
+ l = len(l)
55
58
  if l == 3:
56
59
  a = alloclst.pop(0)
57
60
  b = alloclst.pop(0)
@@ -0,0 +1,18 @@
1
+ import random
2
+ from .decision import god
3
+ def benchmark_ncert(max_count=5):
4
+ with open("mathai/ncert_data.txt", "r", encoding="utf-8") as file:
5
+ content = file.read()
6
+ content = content.strip().split("\n")
7
+ random.shuffle(content)
8
+ output = []
9
+ count = 1
10
+ if len(max_count) > len(content):
11
+ max_count = len(content)
12
+ for item in content[:max_count]:
13
+ print(f"{count}/{max_count}")
14
+ count += 1
15
+ output.append((item, god(item, False)))
16
+ print()
17
+ for index, item in enumerate(output):
18
+ print(f"{index+1}. {item[0]} => {item[1]}")
@@ -60,9 +60,10 @@ def solve_subs(q):
60
60
  if len(solution.keys()) == 0:
61
61
  return orig
62
62
  return operation("f_and", [item for item in lst if all(not contain(item, tree_form(key)) for key in solution.keys())] + [TreeNode("f_eq", [tree_form(key), item]) for key, item in solution.items()])
63
- def god(string):
64
- print(f"? {string}")
65
- print("thinking...")
63
+ def god(string, debug=True):
64
+ if debug:
65
+ print(f"? {string}")
66
+ print("thinking...")
66
67
  eq = None
67
68
  eq = parse(string)
68
69
  log = [eq]
@@ -72,18 +73,22 @@ def god(string):
72
73
  eq = limit1(limit5(eq))
73
74
  if any(contain2(eq, "f_"+item) for item in "adj det list transpose".split(" ")):
74
75
  eq = matrix_formula(eq)
75
- print(eq)
76
+ if debug:
77
+ print(eq)
76
78
  eq = matrix_solve(eq)
77
- print(eq)
79
+ if debug:
80
+ print(eq)
78
81
  eq = solve_subs(eq)
79
- print(f"=> {eq}")
80
- print()
82
+ if debug:
83
+ print(f"=> {eq}")
84
+ print()
81
85
  return eq
82
86
  elif all(not contain2(eq, "f_"+item) for item in "dif add mul abs pow dif integrate arcsin sin cos log limit eq lt le ge gt".split(" ")) and\
83
87
  any(contain2(eq, "f_"+item) for item in "and or not imply equiv".split(" ")):
84
88
  eq = solve_logically(truth_gen(simplify(set_sub(eq))))
85
- print(f"=> {eq}")
86
- print()
89
+ if debug:
90
+ print(f"=> {eq}")
91
+ print()
87
92
  return eq
88
93
  elif not (eq.name == "f_and" and len(vlist(eq)) > 1) and any(contain2(eq, "f_"+item) for item in "eq lt le ge gt".split(" ")) and all(not contain2(eq, "f_"+item) for item in "limit dif integrate".split(" ")):
89
94
  lst = [simplify, log0, simplify, lambda x: dowhile(x, absolute), lambda x: dowhile(x, lambda y: simplify(expand(y))), lambda x: dowhile(x, lambda y: simplify(fraction(y))), logic0, simple_wavycurvy, simple_wavycurvy]
@@ -98,10 +103,11 @@ def god(string):
98
103
  eq = item(eq)
99
104
  if eq not in log:
100
105
  log.append(eq)
101
- print(eq)
102
- # eq = trig7(eq)
103
- print(f"=> {eq}")
104
- print()
106
+ if debug:
107
+ print(eq)
108
+ if debug:
109
+ print(f"=> {eq}")
110
+ print()
105
111
  return eq
106
112
  elif "f_dif" in str_form(eq) or "f_integrate" in str_form(eq):
107
113
  if "f_dif" in str_form(eq) and "f_integrate" not in str_form(eq):
@@ -109,12 +115,15 @@ def god(string):
109
115
  log.append(eq)
110
116
  if "f_integrate" in str_form(eq):
111
117
  eq = def_integrate_formula(eq)
112
- eq = integrate_full(eq)
118
+ eq = integrate_full(eq, debug)
113
119
  eq = limit5(eq)
114
120
  eq = limit1(eq)
115
121
  eq = simplify(expand(simplify(eq)))
116
- print(f"=> {eq}")
117
- print()
122
+ if contain2(eq, "f_integrate"):
123
+ return None
124
+ if debug:
125
+ print(f"=> {eq}")
126
+ print()
118
127
  return eq
119
128
  if any("f_"+item in str_form(eq) for item in "eq lt le ge gt".split(" ")):
120
129
  eq = simple_wavycurvy(eq)
@@ -122,13 +131,15 @@ def god(string):
122
131
  out = linear_solve(eq)
123
132
  if out is not None:
124
133
  eq = out
125
- print(eq)
134
+ if debug:
135
+ print(eq)
126
136
  eq = solve_subs(eq)
127
137
  out = linear_solve(eq)
128
138
  if out is not None:
129
139
  eq = out
130
140
  eq = simple_wavycurvy(eq)
131
141
  eq = simplify(expand(simplify(fraction(simplify(eq)))))
132
- print(f"=> {eq}")
133
- print()
142
+ if debug:
143
+ print(f"=> {eq}")
144
+ print()
134
145
  return eq
@@ -85,10 +85,10 @@ def subs_heuristic(eq, var):
85
85
  else:
86
86
  p = [poly_term]+output
87
87
  last = list(set(last))
88
- if len(p)>3:
89
- p = p[:3]
90
- elif len(p)<3:
91
- p = (p+last)[:3]
88
+ if len(p)>2:
89
+ p = p[:2]
90
+ elif len(p)<2:
91
+ p = (p+last)[:2]
92
92
  return p
93
93
  try_index = []
94
94
  try_lst = []
@@ -317,13 +317,13 @@ def normalize(x, f=True):
317
317
  if f:
318
318
  x = dowhile(x, lambda y: fraction(simplify(integrate_formula(y))))
319
319
  else:
320
- x = dowhile(x, lambda y: simplify(integrate_formula(y)))
320
+ x = integrate_formula(x)
321
321
  out = integrate_fraction(x)
322
322
  if out is not None:
323
323
  x = out
324
324
  return x
325
325
 
326
- def integrate_full(root):
326
+ def integrate_full(root, debug=True):
327
327
  root = trig0(root)
328
328
  def is_solved(x):
329
329
  x = solve_integrate(x)
@@ -337,11 +337,13 @@ def integrate_full(root):
337
337
  eq = root
338
338
  for item in [[lambda x: x, simplify, expand, normalize], [factor2, apart, normalize2, normalize], [trig1, normalize2],\
339
339
  [factor1, normalize, trig6, normalize, expand, normalize, integrate_subs_main, normalize, factor2, simplify, integrate_trig_formula, trig1, apart, normalize2],\
340
- [normalize2, integrate_subs_main, expand, normalize, byparts, normalize], [simplify, integrate_trig_formula, trig1, integrate_formula]]:
340
+ [normalize2, integrate_subs_main, expand, normalize, factor2, simplify, apart, normalize, expand, byparts, normalize],\
341
+ [simplify, integrate_trig_formula, trig1, integrate_formula]]:
341
342
  for item2 in item:
342
343
  eq = item2(eq)
343
344
  if eq not in log:
344
- print(eq)
345
+ if debug:
346
+ print(eq)
345
347
  log.append(eq)
346
348
  if is_solved(eq):
347
349
  result = eq
@@ -0,0 +1,61 @@
1
+ integrate(cos(2*x),x)
2
+ integrate(3*x^2+4*x^3,x)
3
+ integrate(1/x,x)
4
+ integrate((x^3-1)/x^2,x)
5
+ integrate(x^(2/3)+1,x)
6
+ integrate(x^(3/2)+2*e^x-1/x,x)
7
+ integrate(sin(x)+cos(x),x)
8
+ integrate(cosec(x)*(cosec(x)+cot(x)),x)
9
+ integrate((1-sin(x))/cos(x)^2,x)
10
+ integrate(sin(2*x),x)
11
+ integrate(cos(3*x),x)
12
+ integrate(e^(2*x),x)
13
+ integrate((a*x+b)^2,x)
14
+ integrate(sin(2*x)-4*e^(3*x),x)
15
+ integrate(4*e^(3*x)+1,x)
16
+ integrate(x^2*(1-1/x^2),x)
17
+ integrate(a*x^2+b*x+c,x)
18
+ integrate(2*x^2+e^x,x)
19
+ integrate((sqrt(x)-1/sqrt(x))^2,x)
20
+ integrate((x^3+5*x^2-4)/x^2,x)
21
+ integrate((x^3+3*x+4)/sqrt(x),x)
22
+ integrate((x^3-x^2+x-1)/(x-1),x)
23
+ integrate((1-x)*sqrt(x),x)
24
+ integrate(sqrt(x)*(3*x^2+2*x+3),x)
25
+ integrate(2*x-3*cos(x)+e^x,x)
26
+ integrate(2*x^2-3*sin(x)+5*sqrt(x),x)
27
+ integrate(sec(x)*(sec(x)+tan(x)),x)
28
+ integrate(sec(x)^2/cosec(x)^2,x)
29
+ integrate((2-3*sin(x))/cos(x)^2,x)
30
+ integrate(sqrt(x)+1/sqrt(x),x)
31
+ integrate(sin(x)^3*cos(x)^2,x)
32
+ integrate(sin(x)/sin(x+a),x)
33
+ integrate(1/(1+tan(x),x)
34
+ integrate((e^(2*x)-1)/(e^(2*x)+1),x)
35
+ integrate((e^(2*x)-e^(-2*x))/(e^(2*x)+e^(-2*x)),x)
36
+ integrate(tan(2*x-3)^2,x)
37
+ integrate(sec(7-4*x)^2,x)
38
+ integrate(arcsin(x)/sqrt(1-x^2),x)
39
+ integrate((2*cos(x)-3*sin(x))/(6*cos(x)+4*sin(x)),x)
40
+ integrate((4*x+2)*sqrt(x^2+x+1),x)
41
+ integrate(1/(x-sqrt(x)),x)
42
+ integrate(1/(x*log(x)^m),x)
43
+ integrate(e^arctan(x)/(1+x^2),x)
44
+ integrate(x/e^(x^2),x)
45
+ integrate(e^(2*x+3),x)
46
+ integrate(x/(9-4*x^2),x)
47
+ integrate(x^2/(2+3*x^3)^3,x)
48
+ integrate((x^3-1)^(1/3)*x^5,x)
49
+ integrate(x/sqrt(x+4),x)
50
+ integrate(x*sqrt(1+2*x^2),x)
51
+ integrate(x*sqrt(x+2),x)
52
+ integrate(sqrt(a*x+b),x)
53
+ integrate(sin(a*x+b)*cos(a*x+b),x)
54
+ integrate(sin(cos(x))*sin(x),x)
55
+ integrate(2*x/(1+x^2),x)
56
+ integrate(log(x)^2/x,x)
57
+ integrate(1/(x+log(x)*x),x)
58
+ integrate(tan(sqrt(x))^4*sec(sqrt(x))^2/sqrt(x),x)
59
+ integrate(sin(arctan(x))/(1+x^2),x)
60
+ integrate(2*x*sin(x^2+1),x)
61
+ integrate(sin(m*x),x)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 2.3.8
3
+ Version: 2.3.9
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai
6
6
  Requires-Python: >=3.7
@@ -4,6 +4,7 @@ setup.py
4
4
  mathai/__init__.py
5
5
  mathai/apart.py
6
6
  mathai/base.py
7
+ mathai/benchmark.py
7
8
  mathai/decision.py
8
9
  mathai/diff.py
9
10
  mathai/electronic.py
@@ -21,6 +22,7 @@ mathai/logic.py
21
22
  mathai/matrix.py
22
23
  mathai/ml.py
23
24
  mathai/mlscalar.py
25
+ mathai/ncert_data.txt
24
26
  mathai/ode.py
25
27
  mathai/parser.py
26
28
  mathai/pde.py
@@ -3,11 +3,15 @@ from setuptools import setup, find_packages
3
3
 
4
4
  setup(
5
5
  name="mathai",
6
- version="2.3.8",
6
+ version="2.3.9",
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",
10
10
  url="https://github.com/infinity390/mathai",
11
11
  packages=find_packages(),
12
+ include_package_data=True,
13
+ package_data={
14
+ "mathai": ["ncert_data.txt"],
15
+ },
12
16
  python_requires=">=3.7",
13
17
  )
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