mathai 0.4.4__tar.gz → 0.4.5__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 (29) hide show
  1. {mathai-0.4.4 → mathai-0.4.5}/PKG-INFO +1 -1
  2. {mathai-0.4.4 → mathai-0.4.5}/mathai/trig.py +31 -28
  3. {mathai-0.4.4 → mathai-0.4.5}/mathai.egg-info/PKG-INFO +1 -1
  4. {mathai-0.4.4 → mathai-0.4.5}/setup.py +1 -1
  5. {mathai-0.4.4 → mathai-0.4.5}/README.md +0 -0
  6. {mathai-0.4.4 → mathai-0.4.5}/mathai/__init__.py +0 -0
  7. {mathai-0.4.4 → mathai-0.4.5}/mathai/apart.py +0 -0
  8. {mathai-0.4.4 → mathai-0.4.5}/mathai/base.py +0 -0
  9. {mathai-0.4.4 → mathai-0.4.5}/mathai/console.py +0 -0
  10. {mathai-0.4.4 → mathai-0.4.5}/mathai/diff.py +0 -0
  11. {mathai-0.4.4 → mathai-0.4.5}/mathai/expand.py +0 -0
  12. {mathai-0.4.4 → mathai-0.4.5}/mathai/factor.py +0 -0
  13. {mathai-0.4.4 → mathai-0.4.5}/mathai/fraction.py +0 -0
  14. {mathai-0.4.4 → mathai-0.4.5}/mathai/integrate.py +0 -0
  15. {mathai-0.4.4 → mathai-0.4.5}/mathai/inverse.py +0 -0
  16. {mathai-0.4.4 → mathai-0.4.5}/mathai/limit.py +0 -0
  17. {mathai-0.4.4 → mathai-0.4.5}/mathai/linear.py +0 -0
  18. {mathai-0.4.4 → mathai-0.4.5}/mathai/logic.py +0 -0
  19. {mathai-0.4.4 → mathai-0.4.5}/mathai/parser.py +0 -0
  20. {mathai-0.4.4 → mathai-0.4.5}/mathai/printeq.py +0 -0
  21. {mathai-0.4.4 → mathai-0.4.5}/mathai/simplify.py +0 -0
  22. {mathai-0.4.4 → mathai-0.4.5}/mathai/structure.py +0 -0
  23. {mathai-0.4.4 → mathai-0.4.5}/mathai/tool.py +0 -0
  24. {mathai-0.4.4 → mathai-0.4.5}/mathai/univariate_inequality.py +0 -0
  25. {mathai-0.4.4 → mathai-0.4.5}/mathai.egg-info/SOURCES.txt +0 -0
  26. {mathai-0.4.4 → mathai-0.4.5}/mathai.egg-info/dependency_links.txt +0 -0
  27. {mathai-0.4.4 → mathai-0.4.5}/mathai.egg-info/requires.txt +0 -0
  28. {mathai-0.4.4 → mathai-0.4.5}/mathai.egg-info/top_level.txt +0 -0
  29. {mathai-0.4.4 → mathai-0.4.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 0.4.4
3
+ Version: 0.4.5
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai4
6
6
  Author: educated indians are having a low iq and are good for nothing
@@ -82,7 +82,7 @@ def trig0(eq):
82
82
  if any(isneg(item) for item in lst):
83
83
  return -(eq.children[0]*-1).fx("sin")
84
84
  out=single_pi(lst)
85
- if out is not None:
85
+ if out is not None and tuple(out) in trig_sin_table.keys():
86
86
  return trig_sin_table[tuple(out)]
87
87
 
88
88
  if eq.name == "f_cos":
@@ -211,35 +211,38 @@ def trig4(eq, numer=True):
211
211
  return TreeNode(eq.name, [trig4(child, False) if not numer or (eq.name == "f_pow" and frac(eq.children[1]) is not None and frac(eq.children[1]) < 0) else trig4(child, True) for child in eq.children])
212
212
 
213
213
  def trig2(eq):
214
- if eq.name == "f_add":
215
- for item in itertools.combinations(range(len(eq.children)), 2):
216
- child1, child2 = eq.children[item[0]], eq.children[item[1]]
214
+ # Base case: if not an addition, recurse into children
215
+ if eq.name != "f_add":
216
+ return TreeNode(eq.name, [trig2(child) for child in eq.children])
217
+
218
+ # Try all pairs in the addition
219
+ for i, j in itertools.combinations(range(len(eq.children)), 2):
220
+ c1, c2 = eq.children[i], eq.children[j]
221
+
222
+ # Combine only sin/sin or cos/cos
223
+ if c1.name in ["f_sin", "f_cos"] and c2.name in ["f_sin", "f_cos"]:
224
+ A, B = c1.children[0], c2.children[0]
225
+ rest = [eq.children[k] for k in range(len(eq.children)) if k not in (i, j)]
226
+ rest_tree = summation(rest) if rest else tree_form("d_0")
217
227
 
218
- # Check if both are sin or cos
219
- if child1.name in ["f_sin", "f_cos"] and child2.name in ["f_sin", "f_cos"]:
220
- a, b = child1.children[0], child2.children[0]
221
-
222
- # Compute the rest of the sum
223
- rest = [eq.children[i] for i in range(len(eq.children)) if i not in item]
224
- if len(rest) == 0:
225
- rest_tree = tree_form("d_0")
226
- else:
227
- rest_tree = summation(rest)
228
+ two = tree_form("d_2")
228
229
 
229
- # Now handle the sin/cos combination formula
230
- if child1.name == "f_sin" and child2.name == "f_sin":
231
- # sin A + sin B = 2 sin((A+B)/2) cos((A-B)/2)
232
- two = tree_form("d_2")
233
- combined = two * ((a + b) / two).fx("sin") * ((a - b) / two).fx("cos")
234
- elif child1.name == "f_cos" and child2.name == "f_cos":
235
- # cos A + cos B = 2 cos((A+B)/2) cos((A-B)/2)
236
- two = tree_form("d_2")
237
- combined = two * ((a + b) / two).fx("cos") * ((a - b) / two).fx("cos")
238
- else:
239
- # sin A + cos B = sin A + cos B (leave unchanged, or implement formula if desired)
240
- continue # skip for now, keep original
230
+ # sinA + sinB
231
+ if c1.name == "f_sin" and c2.name == "f_sin":
232
+ combined = two * ((A + B) / two).fx("sin") * ((A - B) / two).fx("cos")
241
233
 
242
- return rest_tree + combined
234
+ # cosA + cosB
235
+ elif c1.name == "f_cos" and c2.name == "f_cos":
236
+ combined = two * ((A + B) / two).fx("cos") * ((A - B) / two).fx("cos")
243
237
 
244
- # Recurse for other nodes
238
+ # sinA + cosB (leave unchanged)
239
+ else:
240
+ continue
241
+
242
+ new_expr = rest_tree + combined
243
+ # Re-run trig2 in case there are more sin/cos sums to simplify
244
+ return trig2(new_expr)
245
+
246
+ # If no sin/cos pairs found, just recurse on children
245
247
  return TreeNode(eq.name, [trig2(child) for child in eq.children])
248
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 0.4.4
3
+ Version: 0.4.5
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai4
6
6
  Author: educated indians are having a low iq and are good for nothing
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="mathai",
5
- version="0.4.4",
5
+ version="0.4.5",
6
6
  description="Mathematics solving Ai tailored to NCERT",
7
7
  long_description=open("README.md").read(),
8
8
  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