mathai 2.3.9__tar.gz → 2.4.0__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 (43) hide show
  1. {mathai-2.3.9 → mathai-2.4.0}/PKG-INFO +1 -1
  2. {mathai-2.3.9 → mathai-2.4.0}/mathai/__init__.py +3 -0
  3. mathai-2.4.0/mathai/diff.py +24 -0
  4. {mathai-2.3.9 → mathai-2.4.0}/mathai/factor.py +2 -2
  5. {mathai-2.3.9 → mathai-2.4.0}/mathai/formula_applier.py +9 -4
  6. mathai-2.4.0/mathai/formula_compiler.py +719 -0
  7. {mathai-2.3.9 → mathai-2.4.0}/mathai/integrate.py +23 -18
  8. {mathai-2.3.9 → mathai-2.4.0}/mathai/limit.py +2 -2
  9. {mathai-2.3.9 → mathai-2.4.0}/mathai/ml.py +8 -7
  10. {mathai-2.3.9 → mathai-2.4.0}/mathai/trig.py +6 -7
  11. {mathai-2.3.9 → mathai-2.4.0}/mathai.egg-info/PKG-INFO +1 -1
  12. {mathai-2.3.9 → mathai-2.4.0}/mathai.egg-info/SOURCES.txt +1 -0
  13. {mathai-2.3.9 → mathai-2.4.0}/setup.py +1 -1
  14. mathai-2.3.9/mathai/diff.py +0 -179
  15. {mathai-2.3.9 → mathai-2.4.0}/README.md +0 -0
  16. {mathai-2.3.9 → mathai-2.4.0}/mathai/apart.py +0 -0
  17. {mathai-2.3.9 → mathai-2.4.0}/mathai/base.py +0 -0
  18. {mathai-2.3.9 → mathai-2.4.0}/mathai/benchmark.py +0 -0
  19. {mathai-2.3.9 → mathai-2.4.0}/mathai/decision.py +0 -0
  20. {mathai-2.3.9 → mathai-2.4.0}/mathai/electronic.py +0 -0
  21. {mathai-2.3.9 → mathai-2.4.0}/mathai/expand.py +0 -0
  22. {mathai-2.3.9 → mathai-2.4.0}/mathai/fraction.py +0 -0
  23. {mathai-2.3.9 → mathai-2.4.0}/mathai/graphics.py +0 -0
  24. {mathai-2.3.9 → mathai-2.4.0}/mathai/inverse.py +0 -0
  25. {mathai-2.3.9 → mathai-2.4.0}/mathai/lambda_calculus.py +0 -0
  26. {mathai-2.3.9 → mathai-2.4.0}/mathai/linear.py +0 -0
  27. {mathai-2.3.9 → mathai-2.4.0}/mathai/logic.py +0 -0
  28. {mathai-2.3.9 → mathai-2.4.0}/mathai/matrix.py +0 -0
  29. {mathai-2.3.9 → mathai-2.4.0}/mathai/mlscalar.py +0 -0
  30. {mathai-2.3.9 → mathai-2.4.0}/mathai/ncert_data.txt +0 -0
  31. {mathai-2.3.9 → mathai-2.4.0}/mathai/ode.py +0 -0
  32. {mathai-2.3.9 → mathai-2.4.0}/mathai/parser.py +0 -0
  33. {mathai-2.3.9 → mathai-2.4.0}/mathai/pde.py +0 -0
  34. {mathai-2.3.9 → mathai-2.4.0}/mathai/printeq.py +0 -0
  35. {mathai-2.3.9 → mathai-2.4.0}/mathai/qm.py +0 -0
  36. {mathai-2.3.9 → mathai-2.4.0}/mathai/simplify.py +0 -0
  37. {mathai-2.3.9 → mathai-2.4.0}/mathai/statistics.py +0 -0
  38. {mathai-2.3.9 → mathai-2.4.0}/mathai/test.py +0 -0
  39. {mathai-2.3.9 → mathai-2.4.0}/mathai/tool.py +0 -0
  40. {mathai-2.3.9 → mathai-2.4.0}/mathai/univariate_inequality.py +0 -0
  41. {mathai-2.3.9 → mathai-2.4.0}/mathai.egg-info/dependency_links.txt +0 -0
  42. {mathai-2.3.9 → mathai-2.4.0}/mathai.egg-info/top_level.txt +0 -0
  43. {mathai-2.3.9 → mathai-2.4.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 2.3.9
3
+ Version: 2.4.0
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai
6
6
  Requires-Python: >=3.7
@@ -9,6 +9,9 @@ from .graphics import draw_graphics_from_solution, solve_graphics, solve_graphic
9
9
 
10
10
  from .benchmark import benchmark_ncert
11
11
 
12
+ from .formula_compiler import formula_compiler
13
+ from .formula_compiler import formula_list_compiler
14
+
12
15
  from .lambda_calculus import lambda_expand, lambda_compress, lambda_reduce
13
16
 
14
17
  from .electronic import Edge, CircuitGraph, find_resistance
@@ -0,0 +1,24 @@
1
+ from .simplify import simplify
2
+ from .base import *
3
+ from .parser import parse
4
+ from .formula_compiler import formula_list_compiler
5
+
6
+ diff2_s = """pdif(e^a,x) e^a*pdif(a,x) [] x _ _ _
7
+ pdif(a^b,x) b*(a^(b-1))*pdif(a,x)+(a^b)*log(a)*pdif(b,x) [] x _ _ _
8
+ pdif(sin(a),x) cos(a)*pdif(a,x) [] x _ _ _
9
+ pdif(cos(a),x) -sin(a)*pdif(a,x) [] x _ _ _
10
+ pdif(arcsin(a),x) (1/sqrt(1-a^2))*pdif(a,x) [] x _ _ _
11
+ pdif(arccos(a),x) (-1/sqrt(1-a^2))*pdif(a,x) [] x _ _ _
12
+ pdif(arctan(a),x) (1/(1+a^2))*pdif(a,x) [] x _ _ _
13
+ pdif(k,x) 0 [] x k _ _
14
+ pdif(x,x) 1 [] x _ _ _
15
+ pdif(product(a,b),x) pdif(a,x)*b+a*pdif(b,x) [] x _ _ _
16
+ pdif(sum(a,b),x) pdif(a,x)+pdif(b,x) [] x _ _ _
17
+ pdif(product(k,a),x) k*pdif(a,x) [] x k _ _"""
18
+
19
+ diff2 = formula_list_compiler(diff2_s)
20
+
21
+ def diff(equation, var=None):
22
+ var = var if var else "v_0"
23
+ out = diff2(simplify(TreeNode("f_pdif", [equation, tree_form(var)])))
24
+ return out
@@ -7,9 +7,9 @@ import math
7
7
  from .tool import poly
8
8
  from .fraction import fraction
9
9
  from collections import Counter
10
- from .formula_applier import formula_list_applier
10
+ from .formula_compiler import formula_list_compiler
11
11
 
12
- factor2 = lambda x: formula_list_applier(x, "poly(x,a,b,c) a*(x-(-b+sqrt(b^2-4*a*c))/(2*a))*(x-(-b-sqrt(b^2-4*a*c))/(2*a)) [] _ _ b^2-4*a*c _")
12
+ factor2 = formula_list_compiler("poly(x,a,b,c) a*(x-(-b+sqrt(b^2-4*a*c))/(2*a))*(x-(-b-sqrt(b^2-4*a*c))/(2*a)) [] _ _ b^2-4*a*c _")
13
13
  def multiset_intersection(*lists):
14
14
  counters = list(map(Counter, lists))
15
15
  common = counters[0]
@@ -705,6 +705,9 @@ def formula_list_applier(eq, s):
705
705
  return dowhile(eq, lambda x: formula_list_applier_h(x, s))
706
706
 
707
707
 
708
+ def _is_zero(node):
709
+ return node is not None and (getattr(node, "name", None) == "d_0" or node == 0)
710
+
708
711
  def extract_polynomial_coefficients(eq, var, degree):
709
712
  if eq is None:
710
713
  return None
@@ -717,12 +720,14 @@ def extract_polynomial_coefficients(eq, var, degree):
717
720
  if c_val is None:
718
721
  return None
719
722
  coefficients.append(c_val)
720
- simplified_num = simplify(operation("f_sub", [current_eq, c_val]))
721
- if simplified_num == 0:
723
+ remainder = simplify(operation("f_sub", [current_eq, c_val]))
724
+ if remainder is None:
725
+ return None
726
+ if _is_zero(remainder):
722
727
  coefficients.extend(TreeNode("d_0") for _ in range(degree + 1 - len(coefficients)))
723
728
  return coefficients
724
- current_eq = simplify(expand(simplify(operation("f_div", [simplified_num, var_node]))))
729
+ current_eq = simplify(expand(simplify(operation("f_div", [remainder, var_node]))))
725
730
  if current_eq is None:
726
731
  return None
727
732
  final_check = simplify(replace(copy.deepcopy(current_eq), var_node, zero_node))
728
- return coefficients if final_check == 0 else None
733
+ return coefficients if _is_zero(final_check) else None