mathai 2.1.0__tar.gz → 2.1.2__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 (68) hide show
  1. {mathai-2.1.0 → mathai-2.1.2}/PKG-INFO +3 -1
  2. {mathai-2.1.0 → mathai-2.1.2}/mathai/__init__.py +1 -1
  3. {mathai-2.1.0 → mathai-2.1.2}/mathai/base.py +13 -8
  4. mathai-2.1.2/mathai/formula/differentiation.marshal +0 -0
  5. mathai-2.1.2/mathai/formula/integration.marshal +0 -0
  6. mathai-2.1.2/mathai/formula/integration_trig.marshal +0 -0
  7. mathai-2.1.2/mathai/formula/is_integrate_subs.marshal +0 -0
  8. mathai-2.1.2/mathai/formula/lambda_compress.marshal +0 -0
  9. mathai-2.1.2/mathai/formula/lambda_expand.marshal +0 -0
  10. mathai-2.1.2/mathai/formula/lambda_reduce.marshal +0 -0
  11. mathai-2.1.2/mathai/formula/limit_infinity.marshal +0 -0
  12. mathai-2.1.2/mathai/formula/matrix_vectorization_calculus.marshal +0 -0
  13. mathai-2.1.2/mathai/formula/power_rule.marshal +0 -0
  14. mathai-2.1.2/mathai/formula/quadratic.marshal +0 -0
  15. mathai-2.1.2/mathai/formula/statistics_1.marshal +0 -0
  16. mathai-2.1.2/mathai/formula/statistics_2.marshal +0 -0
  17. mathai-2.1.2/mathai/formula/test.marshal +0 -0
  18. mathai-2.1.2/mathai/formula/trigonometry_misc.marshal +0 -0
  19. {mathai-2.1.0 → mathai-2.1.2}/mathai/formula_compiler.py +128 -131
  20. {mathai-2.1.0 → mathai-2.1.2}/mathai/formula_data.py +48 -44
  21. {mathai-2.1.0 → mathai-2.1.2}/mathai/qm.py +3 -2
  22. {mathai-2.1.0 → mathai-2.1.2}/mathai.egg-info/PKG-INFO +3 -1
  23. {mathai-2.1.0 → mathai-2.1.2}/mathai.egg-info/SOURCES.txt +3 -0
  24. mathai-2.1.2/mathai.egg-info/requires.txt +1 -0
  25. {mathai-2.1.0 → mathai-2.1.2}/setup.py +5 -2
  26. mathai-2.1.0/mathai/formula/differentiation.marshal +0 -0
  27. mathai-2.1.0/mathai/formula/integration.marshal +0 -0
  28. mathai-2.1.0/mathai/formula/integration_trig.marshal +0 -0
  29. mathai-2.1.0/mathai/formula/is_integrate_subs.marshal +0 -0
  30. mathai-2.1.0/mathai/formula/lambda_compress.marshal +0 -0
  31. mathai-2.1.0/mathai/formula/lambda_expand.marshal +0 -0
  32. mathai-2.1.0/mathai/formula/lambda_reduce.marshal +0 -0
  33. mathai-2.1.0/mathai/formula/limit_infinity.marshal +0 -0
  34. mathai-2.1.0/mathai/formula/matrix_vectorization_calculus.marshal +0 -0
  35. mathai-2.1.0/mathai/formula/quadratic.marshal +0 -0
  36. mathai-2.1.0/mathai/formula/statistics_1.marshal +0 -0
  37. mathai-2.1.0/mathai/formula/statistics_2.marshal +0 -0
  38. mathai-2.1.0/mathai/formula/trigonometry_misc.marshal +0 -0
  39. {mathai-2.1.0 → mathai-2.1.2}/README.md +0 -0
  40. {mathai-2.1.0 → mathai-2.1.2}/mathai/apart.py +0 -0
  41. {mathai-2.1.0 → mathai-2.1.2}/mathai/decision.py +0 -0
  42. {mathai-2.1.0 → mathai-2.1.2}/mathai/diff.py +0 -0
  43. {mathai-2.1.0 → mathai-2.1.2}/mathai/expand.py +0 -0
  44. {mathai-2.1.0 → mathai-2.1.2}/mathai/factor.py +0 -0
  45. {mathai-2.1.0 → mathai-2.1.2}/mathai/formula_interpretor.py +0 -0
  46. {mathai-2.1.0 → mathai-2.1.2}/mathai/fraction.py +0 -0
  47. {mathai-2.1.0 → mathai-2.1.2}/mathai/integrate.py +0 -0
  48. {mathai-2.1.0 → mathai-2.1.2}/mathai/inverse.py +0 -0
  49. {mathai-2.1.0 → mathai-2.1.2}/mathai/lambda_calculus.py +0 -0
  50. {mathai-2.1.0 → mathai-2.1.2}/mathai/limit.py +0 -0
  51. {mathai-2.1.0 → mathai-2.1.2}/mathai/linear.py +0 -0
  52. {mathai-2.1.0 → mathai-2.1.2}/mathai/logic.py +0 -0
  53. {mathai-2.1.0 → mathai-2.1.2}/mathai/matrix.py +0 -0
  54. {mathai-2.1.0 → mathai-2.1.2}/mathai/ml.py +0 -0
  55. {mathai-2.1.0 → mathai-2.1.2}/mathai/mlscalar.py +0 -0
  56. {mathai-2.1.0 → mathai-2.1.2}/mathai/ode.py +0 -0
  57. {mathai-2.1.0 → mathai-2.1.2}/mathai/parser.py +0 -0
  58. {mathai-2.1.0 → mathai-2.1.2}/mathai/pde.py +0 -0
  59. {mathai-2.1.0 → mathai-2.1.2}/mathai/printeq.py +0 -0
  60. {mathai-2.1.0 → mathai-2.1.2}/mathai/simplify.py +0 -0
  61. {mathai-2.1.0 → mathai-2.1.2}/mathai/statistics.py +0 -0
  62. {mathai-2.1.0 → mathai-2.1.2}/mathai/test.py +0 -0
  63. {mathai-2.1.0 → mathai-2.1.2}/mathai/tool.py +0 -0
  64. {mathai-2.1.0 → mathai-2.1.2}/mathai/trig.py +0 -0
  65. {mathai-2.1.0 → mathai-2.1.2}/mathai/univariate_inequality.py +0 -0
  66. {mathai-2.1.0 → mathai-2.1.2}/mathai.egg-info/dependency_links.txt +0 -0
  67. {mathai-2.1.0 → mathai-2.1.2}/mathai.egg-info/top_level.txt +0 -0
  68. {mathai-2.1.0 → mathai-2.1.2}/setup.cfg +0 -0
@@ -1,13 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 2.1.0
3
+ Version: 2.1.2
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
7
  Description-Content-Type: text/markdown
8
+ Requires-Dist: more_itertools
8
9
  Dynamic: description
9
10
  Dynamic: description-content-type
10
11
  Dynamic: home-page
12
+ Dynamic: requires-dist
11
13
  Dynamic: requires-python
12
14
  Dynamic: summary
13
15
 
@@ -3,7 +3,7 @@ from .ode import diffsolve_sep as ode_shift_term
3
3
 
4
4
  from .pde import pde_sep, want, absorb
5
5
 
6
- from .qm import hydrogen_gse, helium_gse
6
+ from .qm import hydrogen_gse, helium_gse, power_rule
7
7
 
8
8
  from .lambda_calculus import lambda_expand, lambda_compress, lambda_reduce
9
9
 
@@ -3,6 +3,7 @@ import copy
3
3
  from fractions import Fraction
4
4
  import math
5
5
  import itertools
6
+ import more_itertools
6
7
  def transform_dfs(root, func, arg=None):
7
8
  if root is None:
8
9
  return None
@@ -51,14 +52,18 @@ def transform_dfs_parent(root, func, parent, arg=[]):
51
52
  return result_map[root]
52
53
  def groupings(lst, k, exclude=None):
53
54
  exclude = set(exclude or [])
54
- n = len(lst)
55
- if k < 1 or k > n:
56
- return
57
- for cuts in itertools.combinations(range(1, n), k - 1):
58
- cuts = (0,) + cuts + (n,)
59
- groups = [lst[cuts[i]:cuts[i + 1]] for i in range(k)]
60
- if all(len(groups[i]) == 1 for i in exclude):
61
- yield groups
55
+
56
+ # Guard against invalid k or out-of-bound exclude indices
57
+ if k < 1 or k > len(lst) or any(i < 0 or i >= k for i in exclude):
58
+ return []
59
+
60
+ results = []
61
+ # Generate all contiguous partitions of lst
62
+ for part in more_itertools.partitions(lst):
63
+ if len(part) == k and all(len(part[i]) == 1 for i in exclude):
64
+ results.append(part)
65
+
66
+ return results
62
67
  def partitions(lst):
63
68
  res = set()
64
69
  n = len(lst)
Binary file
@@ -1,4 +1,5 @@
1
1
  import copy
2
+ import more_itertools
2
3
  import itertools
3
4
  from .base import *
4
5
  from .parser import parse
@@ -71,36 +72,14 @@ def structure(
71
72
  ignore_list = [item.name for item in ignore_list]
72
73
 
73
74
  equation = TreeNode("eq", [])
74
- def strip_w(s):
75
- if s in ["f_addw", "f_mulw", "f_hadamardw", "f_waddw"]:
76
- return s[:-1]
77
- return s
75
+
78
76
  def make_treenode_string(name, children):
79
77
  return f"TreeNode('{name}',[{','.join(children)}])"
80
78
  def helper(equation, formula):
81
- nonlocal const_1, var_name, ignore_list, const_var, varlist, associativity, ignore
82
- if formula.name.startswith("v_") and formula.name in const_1:
83
- cond_1 = TreeNode("f_condition", [])
84
- ls = [f"any(contain({equation.name},item) for item in [{','.join(ignore)}])", f"any(contain({equation.name},tree_form(item)) for item in {var_name})"]
85
- ls = [TreeNode(h) for h in ls]
86
- cond_2 = TreeNode("f_if", [operation("f_wor", ls),TreeNode("False")])
87
-
88
- if formula.name.startswith("v_") and formula.name in varlist.keys():
89
- cond_3 = TreeNode(f"{varlist[formula.name].name} == {equation.name}")
90
- cond_1.children += [cond_2, cond_3.fx("else")]
91
- return cond_1
92
- elif formula.name.startswith("v_") and formula.name not in varlist.keys():
93
- varlist[formula.name] = equation
94
- cond_3 = TreeNode("True")
95
- cond_1.children += [cond_2, cond_3.fx("else")]
96
- return cond_1
97
- elif formula.name.startswith("v_") and formula.name in ignore_list:
79
+ nonlocal ignore_list, varlist, associativity, ignore
80
+ if formula.name.startswith("v_") and formula.name in ignore_list:
98
81
  cond_1 = TreeNode("f_condition", [])
99
- cond_2 = None
100
- if const_var == []:
101
- cond_2 = TreeNode("f_if", [TreeNode(f"not {equation.name}.name.startswith('v_')"),TreeNode("False")])
102
- else:
103
- cond_2 = TreeNode("f_if", [TreeNode(f"not {equation.name}.name.startswith('v_')"),TreeNode("False")])
82
+ cond_2 = TreeNode("f_if", [TreeNode(f"not {equation.name}.name.startswith('v_')"),TreeNode("False")])
104
83
  if formula.name.startswith("v_") and formula.name in varlist.keys():
105
84
  cond_3 = TreeNode(f"{varlist[formula.name].name} == {equation.name}")
106
85
  cond_1.children += [cond_2, cond_3.fx("else")]
@@ -127,18 +106,33 @@ def structure(
127
106
  s += 1
128
107
  children = [f"{equation.name}.children[{i}]" for i in range(s)]
129
108
  new_children = []
130
- for key in formula.children:
131
- if key.name in associativity.keys():
132
- n = associativity[key.name]
133
- if n == 1:
134
- new_children.append(children.pop(0))
135
- else:
136
- new_children.append(make_treenode_string(strip_w(formula.name), children[:n]))
137
- children = children[n:]
109
+ if formula.name in ["f_add", "f_mul"]:
110
+ target_lengths = []
111
+ for key in formula.children:
112
+ n = 1
113
+ if key.name in associativity.keys():
114
+ n = associativity[key.name]
115
+ target_lengths.append(n)
116
+ result = [[list(group) for group in more_itertools.split_into(p, target_lengths)] for p in itertools.permutations(children)]
117
+ if not hasattr(formula, "count"):
118
+ formula.count = len(result)-1
138
119
  else:
139
- new_children.append(children.pop(0))
120
+ formula.count = formula.count-1
121
+ result = result[formula.count]
122
+ new_children = [item[0] if len(item) == 1 else make_treenode_string(formula.name, item) for item in result]
123
+ else:
124
+ for key in formula.children:
125
+ if key.name in associativity.keys():
126
+ n = associativity[key.name]
127
+ if n == 1:
128
+ new_children.append(children.pop(0))
129
+ else:
130
+ new_children.append(make_treenode_string(formula.name, children[:n]))
131
+ children = children[n:]
132
+ else:
133
+ new_children.append(children.pop(0))
140
134
  cond_1 = TreeNode("f_condition", [])
141
- ls = [f"{equation.name}.name != '{strip_w(formula.name)}'",f"len({equation.name}.children) != {s}"]
135
+ ls = [f"{equation.name}.name != '{formula.name}'",f"len({equation.name}.children) != {s}"]
142
136
  ls = [TreeNode(h) for h in ls]
143
137
  cond_2 = TreeNode("f_if", [operation("f_wor", ls),\
144
138
  TreeNode("False")])
@@ -154,29 +148,6 @@ def structure(
154
148
  cond_3 = lst
155
149
  cond_1.children += [cond_2, cond_3.fx("else")]
156
150
  return cond_1
157
- def lst(formula):
158
- out = set()
159
- formula = conversion(formula)
160
- def helper_lst(node):
161
- if not node.children:
162
- return [node]
163
- child_groups = [tuple(node.children)]
164
- if node.name in ["f_waddw", "f_hadamardw", "f_addw", "f_mulw"]:
165
- child_groups = list(itertools.permutations(node.children))
166
- results = []
167
- for children in child_groups:
168
- child_perms = [helper_lst(child) for child in children]
169
- for combo in itertools.product(*child_perms):
170
- results.append(TreeNode(node.name, list(combo)))
171
- return results
172
- for tree in helper_lst(formula):
173
- out.add(tree)
174
- return list(out)
175
- def conversion(node):
176
- new_name = node.name + "w" if node.name in ["f_wadd", "f_hadamard", "f_add", "f_mul"] else node.name
177
- return TreeNode(
178
- new_name, [conversion(child) for child in node.children]
179
- )
180
151
  def gen_ac(eq, formula_list, ignore_list):
181
152
  lst = []
182
153
  def merge_unique(dicts):
@@ -189,23 +160,22 @@ def structure(
189
160
  else:
190
161
  merged[key] = value
191
162
  return merged
192
- def make_eq(f):
163
+ def make_eq(f, arity):
193
164
  nonlocal formula_list, lst, ignore_list
194
- if f.name in ["f_addw", "f_mulw", "f_hadamardw", "f_waddw", "f_wmul"]:
165
+ valid_ops = {"f_add", "f_mul", "f_hadamard", "f_wadd", "f_wmul"}
166
+ if f.name in valid_ops:
195
167
  lst2 = []
196
- for i in range(len(f.children),len(f.children)+arity):
197
- for item in groupings(list(range(i)), len(f.children),\
198
- [index for index, child in enumerate(f.children)\
199
- if child.name not in formula_list or child.name in ignore_list]):
200
- dic ={}
201
- for j in range(len(item)):
202
- if f.children[j].name in formula_list:
203
- dic[f.children[j].name] = len(item[j])
204
- lst2.append(dic)
168
+ label = [child.name for child in f.children if child.name.startswith("v_")]
169
+ lst3 = [[1] if child.name in ignore_list else list(range(1,arity+1)) for child in f.children if child.name.startswith("v_")]
170
+ for item in itertools.product(*lst3):
171
+ dic = {}
172
+ for index, item2 in enumerate(item):
173
+ dic[label[index]] = item2
174
+ lst2.append(dic)
205
175
  lst.append(lst2)
206
176
  for child in f.children:
207
- make_eq(child)
208
- make_eq(eq)
177
+ make_eq(child, arity)
178
+ make_eq(eq, arity)
209
179
  output = []
210
180
  for item in itertools.product(*lst):
211
181
  out = merge_unique(item)
@@ -233,20 +203,45 @@ def structure(
233
203
  var.name == item[0].name
234
204
  and item[1] == 1
235
205
  for item in forbidden_value
236
- ):
206
+ ) or var in negative:
237
207
  return out
238
208
  return out + [1]
239
209
  else:
240
210
  return out
241
211
  return out
212
+ def any_attr(eq):
213
+ if hasattr(eq, "count"):
214
+ return True
215
+ if eq.children == []:
216
+ return False
217
+ return any(any_attr(child) for child in eq.children)
218
+ def tree_count_all_zero(eq):
219
+ if hasattr(eq, "count") and eq.count == 0:
220
+ return False
221
+ if eq.children == []:
222
+ return True
223
+ return all(tree_count_all_zero(child) for child in eq.children)
224
+ def del_count(eq):
225
+ if hasattr(eq, "count"):
226
+ del eq.count
227
+ for child in eq.children:
228
+ del_count(child)
242
229
  formula_lst = []
243
230
  ll = []
244
231
  sorted_vars = list(sorted(set(vlist(formula))))
232
+ fv = {}
233
+ for key, item in forbidden_value:
234
+ if key not in fv.keys():
235
+ fv[key] = []
236
+ fv[key] += [item]
245
237
  for item in sorted_vars:
246
- if forbidden_value == "forbid" or item in ignore_list:
238
+ if item in ignore_list:
247
239
  ll.append([-100])
248
240
  continue
249
- output = var_replace(formula, tree_form(item))
241
+ output = [0,1] if item in var_name else []
242
+ output = [x for x in output if (tree_form(item) not in fv.keys() or x not in fv[tree_form(item)]) and (item not in negative or x!=1)]
243
+ if output == []:
244
+ output = None
250
245
  if output is not None:
251
246
  ll.append([-100] + list(set(output)))
252
247
  else:
@@ -267,65 +262,67 @@ def structure(
267
262
  )
268
263
  )
269
264
  formula_lst.append((eq_try, eq_var))
270
- formula_lst_2 = []
271
- for key, item in formula_lst:
272
- for item2 in lst(key):
273
- formula_lst_2.append((item2, item))
274
265
  final_output = ""
275
- for item, upd in formula_lst_2:
276
-
266
+ for item, upd in formula_lst:
277
267
  hh = gen_ac(item, vlist(item), ignore_list)
278
268
  for associativity in hh:
279
- varlist = {}
280
- ignore = []
281
- out2 = helper(copy.deepcopy(equation), copy.deepcopy(item))
282
- varlist = {}
283
- out = helper(copy.deepcopy(equation), item)
284
- varlist.update(upd)
285
- d = []
286
- for key, item2 in varlist.items():
287
- for val in [h[1] for h in forbidden_value if h[0].name == key]:
288
- if item2.name[:2] in ["d_"]:
289
- d.append(TreeNode(f"{item2} != {val}"))
290
- elif item2.name[:2] in ["f_","v_","s_"]:
291
- pass
292
- else:
293
- d.append(TreeNode(f"{item2.name} != {val}"))
294
- for item2 in positive:
295
- local_pos = copy.deepcopy(item2)
296
- for key, item3 in varlist.items():
297
- local_pos = replace(local_pos, tree_form(key), item3)
298
- s = print_code2(local_pos)
299
- s = f"frac({s}) is not None and frac({s})>=0"
300
- d.append(TreeNode(s))
301
- for item2 in negative:
302
- local_neg = copy.deepcopy(item2)
303
- for key, item3 in varlist.items():
304
- local_neg = replace(local_neg, tree_form(key), item3)
305
- s = print_code2(local_neg)
306
- s = f"frac({s}) is not None and frac({s})<=0"
307
- d.append(TreeNode(s))
308
- if len(d) == 0:
309
- pass
310
- elif len(d) == 1:
311
- out = TreeNode("f_condition", [
312
- TreeNode("f_if", [out, d[0]]),
313
- tree_form("s_false").fx("else")
314
- ])
315
- else:
316
- out = TreeNode("f_condition", [
317
- TreeNode("f_if", [out, TreeNode("f_wand", d)]),
318
- tree_form("s_false").fx("else")
319
- ])
320
- local_formula_out = copy.deepcopy(formula_out)
321
- for key, item2 in varlist.items():
322
- local_formula_out = replace(
323
- local_formula_out, tree_form(key), item2
324
- )
325
- out = TreeNode("f_wand", [out2, out])
326
- s = "\tif " + print_code(out) + ":\n"
327
- t = "\t\treturn " + print_code2(local_formula_out) + "\n"
328
- final_output += s + t
269
+ while tree_count_all_zero(item):
270
+ ignore = []
271
+ varlist = copy.deepcopy(upd)
272
+ out = helper(copy.deepcopy(equation), item)
273
+ d = []
274
+ for key, item2 in varlist.items():
275
+ if key in const_1:
276
+ if item2.name.startswith("d_"):
277
+ d.append(TreeNode(f"all(not contain(TreeNode('{item2}'),item) for item in [{','.join(ignore)}])"))
278
+ else:
279
+ d.append(TreeNode(f"all(not contain({item2},item) for item in [{','.join(ignore)}])"))
280
+ for key, item2 in varlist.items():
281
+ for val in [h[1] for h in forbidden_value if h[0].name == key]:
282
+ if item2.name[:2] in ["d_"]:
283
+ d.append(TreeNode(f"{item2} != {val}"))
284
+ elif item2.name[:2] in ["f_","v_","s_"]:
285
+ pass
286
+ else:
287
+ d.append(TreeNode(f"{item2.name} != {val}"))
288
+ for item2 in positive:
289
+ local_pos = copy.deepcopy(item2)
290
+ for key, item3 in varlist.items():
291
+ local_pos = replace(local_pos, tree_form(key), item3)
292
+ s = print_code2(local_pos)
293
+ s = f"frac({s}) is not None and frac({s})>=0"
294
+ d.append(TreeNode(s))
295
+ for item2 in negative:
296
+ local_neg = copy.deepcopy(item2)
297
+ for key, item3 in varlist.items():
298
+ local_neg = replace(local_neg, tree_form(key), item3)
299
+ s = print_code2(local_neg)
300
+ s = f"frac({s}) is not None and frac({s})<=0"
301
+ d.append(TreeNode(s))
302
+ if len(d) == 0:
303
+ pass
304
+ elif len(d) == 1:
305
+ out = TreeNode("f_condition", [
306
+ TreeNode("f_if", [out, d[0]]),
307
+ tree_form("s_false").fx("else")
308
+ ])
309
+ else:
310
+ out = TreeNode("f_condition", [
311
+ TreeNode("f_if", [out, TreeNode("f_wand", d)]),
312
+ tree_form("s_false").fx("else")
313
+ ])
314
+ local_formula_out = copy.deepcopy(formula_out)
315
+ for key, item2 in varlist.items():
316
+ local_formula_out = replace(
317
+ local_formula_out, tree_form(key), item2
318
+ )
319
+
320
+ s = "\tif " + print_code(out) + ":\n"
321
+ t = "\t\treturn " + print_code2(local_formula_out) + "\n"
322
+ final_output += s + t
323
+ if not any_attr(item):
324
+ break
325
+ del_count(item)
329
326
  return final_output
330
327
  def print_condition(eq):
331
328
  assert eq.name == "f_condition"
@@ -16,43 +16,46 @@ formula_data = {}
16
16
  # negative constraint
17
17
  # associative arity
18
18
  formula = """
19
- a*x^2+b*x+c true x _ [a,b,c] _ [a,0] _ _ 2
20
- a*x+b true x _ [a,b] _ [a,0] _ _ 4
19
+ a*x^2+b*x+c true x [a,b] [a,b,c] _ [a,0] _ _ 2
20
+ a*x+b true x [a,b] [a,b] _ [a,0] _ _ 4
21
21
  a false _ _ _ _ _ _ _ 1
22
22
  // is_integrate_subs
23
23
 
24
- 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
25
- integrate(x*e^(a*x+b),x) ((x/a)-(1/(a^2)))*e^(a*x+b) x _ [a,b] _ [a,0] _ _ 6
26
- integrate(e^(a*x+b),x) e^(a*x+b)/a x _ [a,b] _ [a,0] _ _ 6
27
- integrate(1/(a*x+b),x) log(abs(a*x+b))/a x _ [a,b] _ [a,0] _ _ 6
28
- integrate((a*x+b)^c,x) (a*x+b)^(c+1)/(a*(c+1)) x _ [a,b,c] _ [[a,0],[c,-1]] _ _ 1
29
- integrate(1/cos(a*x+b)^2,x) tan(a*x+b)/a x _ [a,b] _ [a,0] _ _ 2
30
- integrate(1/sin(a*x+b)^2,x) -cot(a*x+b)/a x _ [a,b] _ [a,0] _ _ 2
31
- integrate(1/cos(a*x+b),x) log(abs((1+sin(a*x+b))/cos(a*x+b)))/a x _ [a,b] _ [a,0] _ _ 2
32
- integrate(1/sin(a*x+b),x) log(abs(tan((a*x+b)/2)))/a x _ [a,b] _ [a,0] _ _ 2
33
- integrate(sin(a*x+b)^2/cos(a*x+b)^2,x) tan(a*x+b)/a-x x _ [a,b] _ [a,0] _ _ 2
34
- integrate(sin(a*x+b)/(cos(a*x+b)^2),x) 1/(a*cos(a*x+b)) x _ [a,b] _ [a,0] _ _ 2
35
- integrate(sin(a*x+b),x) -cos(a*x+b)/a x _ [a,b] _ [a,0] _ _ 6
36
- integrate(cos(a*x+b),x) sin(a*x+b)/a x _ [a,b] _ [a,0] _ _ 6
37
- integrate(x,x) x^2/2 x _ _ _ _ _ _ 6
24
+ d*a^(b+c) d*a^b*a^c _ d _ _ [d,0] _ _ 3
25
+ // power_rule
26
+
27
+ 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,b] _ [a,0] _ _ 3
28
+ integrate(x*e^(a*x+b),x) ((x/a)-(1/(a^2)))*e^(a*x+b) x [a,b] [a,b] _ [a,0] _ _ 3
29
+ integrate(e^(a*x+b),x) e^(a*x+b)/a x [a,b] [a,b] _ [a,0] _ _ 2
30
+ integrate(1/(a*x+b),x) log(abs(a*x+b))/a x [a,b] [a,b] _ [a,0] _ _ 3
31
+ integrate((a*x+b)^c,x) (a*x+b)^(c+1)/(a*(c+1)) x [a,b] [a,b,c] _ [[a,0],[c,-1]] _ _ 1
32
+ integrate(1/cos(a*x+b)^2,x) tan(a*x+b)/a x [a,b] [a,b] _ [a,0] _ _ 2
33
+ integrate(1/sin(a*x+b)^2,x) -cot(a*x+b)/a x [a,b] [a,b] _ [a,0] _ _ 2
34
+ integrate(1/cos(a*x+b),x) log(abs((1+sin(a*x+b))/cos(a*x+b)))/a x [a,b] [a,b] _ [a,0] _ _ 2
35
+ integrate(1/sin(a*x+b),x) log(abs(tan((a*x+b)/2)))/a x [a,b] [a,b] _ [a,0] _ _ 2
36
+ integrate(sin(a*x+b)^2/cos(a*x+b)^2,x) tan(a*x+b)/a-x x [a,b] [a,b] _ [a,0] _ _ 2
37
+ integrate(sin(a*x+b)/(cos(a*x+b)^2),x) 1/(a*cos(a*x+b)) x [a,b] [a,b] _ [a,0] _ _ 2
38
+ integrate(sin(a*x+b),x) -cos(a*x+b)/a x [a,b] [a,b] _ [a,0] _ _ 3
39
+ integrate(cos(a*x+b),x) sin(a*x+b)/a x [a,b] [a,b] _ [a,0] _ _ 3
40
+ c+integrate(a+b,x) c+integrate(a,x)+integrate(b,x) x c _ _ [[a,0],[b,0],[c,1]] _ _ 3
41
+ integrate(x,x) x^2/2 x _ _ _ _ _ _ 3
38
42
  integrate(a,x) a*x x _ [a] _ _ _ _ 1
39
- integrate(a*b,x) a*integrate(b,x) x _ [a] _ [a,1] _ _ 6
40
- integrate(a+b,x) integrate(a,x)+integrate(b,x) x _ _ _ [[a,0],[b,0]] _ _ 6
43
+ c*integrate(a*b,x) c*a*integrate(b,x) x c [a] _ [[c,0],[a,1]] _ _ 3
41
44
  // integration
42
45
 
43
- integrate(cos(a*x+b)/sin(a*x+b),x) log(abs(sin(a*x+b)))/a x _ [a,b] _ [a,0] _ _ 2
44
- integrate(sin(a*x+b)/cos(a*x+b),x) -(log(abs(cos(a*x+b)))/a) x _ [a,b] _ [a,0] _ _ 2
45
- integrate(sin(x)^a*cos(x)^b,x) -(sin(x)^(a+1)*cos(x)^(b+1)/(b+1))+(a+b+2)/(b+1)*integrate(sin(x)^a*cos(x)^(b+2),x) x _ [a,b] _ [b,-1] _ b 4
46
- integrate((sin(x)/cos(x))^a,x) tan(x)^(a-1)/(a-1)-integrate((sin(x)/cos(x))^(a-2),x) x _ a _ [[a,1],[a,0]] a _ 4
47
- integrate((cos(x)/sin(x))^a,x) -(cot(x)^(a-1)/(a-1))-integrate((cos(x)/sin(x))^(a-2),x) x _ a _ [[a,1],[a,0]] a _ 4
48
- integrate(sin(x)^a/cos(x),x) -(sin(x)^(a-1)/(a-1))+integrate(sin(x)^(a-2)/cos(x),x) x _ a _ [[a,1],[a,0]] a _ 4
49
- integrate(cos(x)^a/sin(x),x) cos(x)^(a-1)/(a-1)+integrate(cos(x)^(a-2)/sin(x),x) x _ a _ [[a,1],[a,0]] a _ 4
50
- integrate(sin(x)^a*cos(x)^b,x) sin(x)^(a+1)*cos(x)^(b+1)/(a+1)+(a+b+2)/(a+1)*integrate(sin(x)^(a+2)*cos(x)^b,x) x _ [a,b] _ [a,-1] _ a 4
51
- integrate(sin(x)^a,x) sin(x)^(a+1)*cos(x)/(a+1)+(a+2)/(a+1)*integrate(sin(x)^(a+2),x) x _ a _ [[a,-1],[a,0]] _ a 4
52
- integrate(cos(x)^a,x) -(sin(x)*cos(x)^(a+1)/(a+1))+(a+2)/(a+1)*integrate(cos(x)^(a+2),x) x _ a _ [[a,-1],[a,0]] _ a 4
46
+ integrate(cos(a*x+b)/sin(a*x+b),x) log(abs(sin(a*x+b)))/a x [a,b] [a,b] _ [a,0] _ _ 2
47
+ integrate(sin(a*x+b)/cos(a*x+b),x) -(log(abs(cos(a*x+b)))/a) x [a,b] [a,b] _ [a,0] _ _ 2
48
+ integrate(sin(x)^a*cos(x)^b,x) -(sin(x)^(a+1)*cos(x)^(b+1)/(b+1))+(a+b+2)/(b+1)*integrate(sin(x)^a*cos(x)^(b+2),x) x [a,b] [a,b] _ [b,-1] _ b 3
49
+ integrate((sin(x)/cos(x))^a,x) tan(x)^(a-1)/(a-1)-integrate((sin(x)/cos(x))^(a-2),x) x a a _ [[a,1],[a,0]] a _ 3
50
+ integrate((cos(x)/sin(x))^a,x) -(cot(x)^(a-1)/(a-1))-integrate((cos(x)/sin(x))^(a-2),x) x a a _ [[a,1],[a,0]] a _ 3
51
+ integrate(sin(x)^a/cos(x),x) -(sin(x)^(a-1)/(a-1))+integrate(sin(x)^(a-2)/cos(x),x) x a a _ [[a,1],[a,0]] a _ 3
52
+ integrate(cos(x)^a/sin(x),x) cos(x)^(a-1)/(a-1)+integrate(cos(x)^(a-2)/sin(x),x) x a a _ [[a,1],[a,0]] a _ 3
53
+ integrate(sin(x)^a*cos(x)^b,x) sin(x)^(a+1)*cos(x)^(b+1)/(a+1)+(a+b+2)/(a+1)*integrate(sin(x)^(a+2)*cos(x)^b,x) x [a,b] [a,b] _ [a,-1] _ a 3
54
+ integrate(sin(x)^a,x) sin(x)^(a+1)*cos(x)/(a+1)+(a+2)/(a+1)*integrate(sin(x)^(a+2),x) x _ a _ [[a,-1],[a,0]] _ a 3
55
+ integrate(cos(x)^a,x) -(sin(x)*cos(x)^(a+1)/(a+1))+(a+2)/(a+1)*integrate(cos(x)^(a+2),x) x _ a _ [[a,-1],[a,0]] _ a 3
53
56
  // integration_trig
54
57
 
55
- pdif(a^b,x) b*(a^(b-1))*pdif(a,x)+(a^b)*log(a)*pdif(b,x) x _ k _ _ _ _ 6
58
+ pdif(a^b,x) b*(a^(b-1))*pdif(a,x)+(a^b)*log(a)*pdif(b,x) x _ k _ _ _ _ 3
56
59
  pdif(sin(a),x) cos(a)*pdif(a,x) x _ k _ [[c,1],[d,1],[f,0],[g,0]] _ _ 2
57
60
  pdif(cos(a),x) -sin(a)*pdif(a,x) x _ k _ [[c,1],[d,1],[f,0],[g,0]] _ _ 2
58
61
  pdif(arcsin(a),x) (1/sqrt(1-a^2))*pdif(a,x) x _ k _ [[c,1],[d,1],[f,0],[g,0]] _ _ 2
@@ -60,9 +63,9 @@ pdif(arccos(a),x) (-1/sqrt(1-a^2))*pdif(a,x) x _ k _ [[c,1],[d,1],[f,0],[g,0]] _
60
63
  pdif(arctan(a),x) (1/(1+a^2))*pdif(a,x) x _ k _ [[c,1],[d,1],[f,0],[g,0]] _ _ 2
61
64
  pdif(k,x) 0 x _ k _ _ _ _ 2
62
65
  pdif(x,x) 1 x _ k _ _ _ _ 2
63
- pdif(a*b,x) pdif(a,x)*b+a*pdif(b,x) x _ k _ [[a,1],[b,1],[a,0],[b,0]] _ _ 6
64
- pdif(a+b,x) pdif(a,x)+pdif(b,x) x _ k _ [[a,1],[b,1],[a,0],[b,0]] _ _ 6
65
- pdif(k*a,x) k*pdif(a,x) x _ k _ [[a,1],[k,1],[a,0],[k,0]] _ _ 6
66
+ pdif(a*b,x) pdif(a,x)*b+a*pdif(b,x) x _ k _ [[a,1],[b,1],[a,0],[b,0]] _ _ 3
67
+ pdif(a+b,x) pdif(a,x)+pdif(b,x) x _ k _ [[a,1],[b,1],[a,0],[b,0]] _ _ 3
68
+ pdif(k*a,x) k*pdif(a,x) x _ k _ [[a,1],[k,1],[a,0],[k,0]] _ _ 3
66
69
  // differentiation
67
70
 
68
71
  I lambda(x,x) [x,y,f,t,I] _ _ _ _ _ _ 1
@@ -81,16 +84,17 @@ lambda(t,lambda(f,f)) false [x,y,f,t,I] _ _ _ _ _ _ 1
81
84
  lambda(f,lambda(x,x)) 0 [x,y,f,t,I] _ _ _ _ _ _ 1
82
85
  // lambda_compress
83
86
 
84
- limitpinf(a*b,x) a*limitpinf(b,x) x _ a _ [a,1] _ _ 6
85
- limitpinf(x^c,x) 0 x _ _ _ _ _ c 6
86
- limitpinf(x^c*e^(d*x),x) 0 x _ _ _ _ _ d 6
87
- limitpinf(x*e^(d*x),x) 0 x _ _ _ _ _ d 6
88
- limitpinf(e^(d*x),x) 0 x _ _ _ _ _ d 6
89
- limitpinf(a+b,x) limitpinf(a,x)+limitpinf(b,x) x _ _ _ _ _ _ 6
87
+ limitpinf(a*b,x) a*limitpinf(b,x) x _ a _ [a,1] _ _ 3
88
+ limitpinf(x^c,x) 0 x _ _ _ _ _ c 3
89
+ limitpinf(x^c*e^(d*x),x) 0 x _ _ _ _ _ d 3
90
+ limitpinf(x*e^(d*x),x) 0 x _ _ _ _ _ d 3
91
+ limitpinf(e^(d*x),x) 0 x _ _ _ _ _ d 3
92
+ limitpinf(a+b,x) limitpinf(a,x)+limitpinf(b,x) x _ _ _ _ _ _ 3
93
+ limitpinf(a,x) a x _ a _ _ _ _ 1
90
94
  // limit_infinity
91
95
 
92
- 1/(1+sin(x)) (1-sin(x))/cos(x)^2 x _ _ _ _ _ _ 6
93
- 1/(1+cos(x)) (1-cos(x))/sin(x)^2 x _ _ _ [x,0] _ _ 6
96
+ 1/(1+sin(x)) (1-sin(x))/cos(x)^2 x _ _ _ _ _ _ 3
97
+ 1/(1+cos(x)) (1-cos(x))/sin(x)^2 x _ _ _ [x,0] _ _ 3
94
98
  // trigonometry_misc
95
99
 
96
100
  wmul(identity(a),b) b x _ k m _ _ _ 6
@@ -112,9 +116,9 @@ pdif(wmul(transpose(y),y),vec(x)) wmul(transpose(pdif(y,vec(x))),hadamard(2,y))
112
116
  pdif(vec(conv(a,b)),vec(x)) wadd(wmul(im2col(a,b),pdif(vec(b),vec(x))),wmul(col2im(b,a),pdif(vec(a),vec(x)))) x _ k m _ _ _ 6
113
117
  // matrix_vectorization_calculus
114
118
 
115
- expect(a+b) expect(a)+expect(b) _ _ _ _ [[a,0],[a,1],[b,0],[b,1]] _ _ 6
116
- expect(1) 1 _ _ _ _ _ _ _ 6
117
- expect(0) 0 _ _ _ _ _ _ _ 6
119
+ expect(a+b) expect(a)+expect(b) _ _ _ _ [[a,0],[a,1],[b,0],[b,1]] _ _ 3
120
+ expect(1) 1 _ _ _ _ _ _ _ 3
121
+ expect(0) 0 _ _ _ _ _ _ _ 3
118
122
  variance(x) expect(x^2)+expect(x)^2 _ _ _ _ _ _ _ 2
119
123
  covariance(x,y) expect(x*y)-expect(x)*expect(y) _ _ _ _ _ _ _ 2
120
124
  expect(k) k _ [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z] k _ _ _ _ 2
@@ -124,7 +128,7 @@ expect(x*y)-expect(x)*expect(y)+a+b covariance(x,y)+a+b _ _ _ _ [[x,1],[x,0],[y,
124
128
  -expect(x*y)+expect(x)*expect(y)+a+b -covariance(x,y)+a+b _ _ _ _ [[x,1],[x,0],[y,0],[y,1],[b,1],[a,1]] _ _ 2
125
129
  // statistics_2
126
130
 
127
- 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 [a,b,c] _ [a,0] b^2-4*a*c _ 2
131
+ 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 [a,b,c] [a,b,c] _ [[a,0],[c,1]] b^2-4*a*c _ 2
128
132
  // quadratic
129
133
  """
130
134
 
@@ -19,6 +19,7 @@ from .integrate import integrate_formula, integrate_full, integrate_definite
19
19
  from .integrate import normalize as integration_basic
20
20
 
21
21
  from .diff import diff
22
+ from .formula_data import load_formula
22
23
 
23
24
  def helium_gse():
24
25
  basic_int = lambda x: dowhile(x, lambda y: expand(simplify(integrate_formula(y))))
@@ -155,9 +156,9 @@ def helium_gse():
155
156
  hs = inverse(dh, Z.name)
156
157
  H = replace(H, Z, hs)
157
158
  return compute(simplify(H/e1))
158
-
159
+ power_rule = lambda x: load_formula("power_rule")(x)
159
160
  def hydrogen_gse():
160
- basic_int = lambda x: dowhile(x, lambda y: integrate_formula(simplify(expand(simplify(y)))))
161
+ basic_int = lambda x: dowhile(x, lambda y: integrate_formula(simplify(expand(simplify(power_rule(y))))))
161
162
  algebra = lambda x: dowhile(x, lambda y: expand(simplify(y)))
162
163
  z = simplify(parse("1"))
163
164
  k = simplify(parse("8987551787"))
@@ -1,13 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 2.1.0
3
+ Version: 2.1.2
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
7
  Description-Content-Type: text/markdown
8
+ Requires-Dist: more_itertools
8
9
  Dynamic: description
9
10
  Dynamic: description-content-type
10
11
  Dynamic: home-page
12
+ Dynamic: requires-dist
11
13
  Dynamic: requires-python
12
14
  Dynamic: summary
13
15
 
@@ -35,6 +35,7 @@ mathai/univariate_inequality.py
35
35
  mathai.egg-info/PKG-INFO
36
36
  mathai.egg-info/SOURCES.txt
37
37
  mathai.egg-info/dependency_links.txt
38
+ mathai.egg-info/requires.txt
38
39
  mathai.egg-info/top_level.txt
39
40
  mathai/formula/differentiation.marshal
40
41
  mathai/formula/integration.marshal
@@ -45,7 +46,9 @@ mathai/formula/lambda_expand.marshal
45
46
  mathai/formula/lambda_reduce.marshal
46
47
  mathai/formula/limit_infinity.marshal
47
48
  mathai/formula/matrix_vectorization_calculus.marshal
49
+ mathai/formula/power_rule.marshal
48
50
  mathai/formula/quadratic.marshal
49
51
  mathai/formula/statistics_1.marshal
50
52
  mathai/formula/statistics_2.marshal
53
+ mathai/formula/test.marshal
51
54
  mathai/formula/trigonometry_misc.marshal
@@ -0,0 +1 @@
1
+ more_itertools
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
  from pathlib import Path
3
3
  setup(
4
4
  name="mathai",
5
- version="2.1.0",
5
+ version="2.1.2",
6
6
  description="Mathematics solving Ai tailored to NCERT",
7
7
  long_description=Path("README.md").read_text(encoding="utf-8"),
8
8
  long_description_content_type="text/markdown",
@@ -12,4 +12,7 @@ setup(
12
12
  "mathai": ["formula/*.marshal"],
13
13
  },
14
14
  python_requires=">=3.7",
15
- )
15
+ install_requires=[
16
+ "more_itertools",
17
+ ],
18
+ )
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