23 lines
792 B
Diff
23 lines
792 B
Diff
# sympy__sympy-20322
|
|
# Loki Mode Multi-Agent Patch
|
|
# Attempts: 1
|
|
|
|
--- a/sympy/simplify/radsimp.py
|
|
+++ b/sympy/simplify/radsimp.py
|
|
@@ -1071,7 +1071,15 @@ def fraction(expr, exact=False):
|
|
numer, denom = [], []
|
|
|
|
for term in Mul.make_args(expr):
|
|
- if term.is_commutative and (term.is_Pow or isinstance(term, exp)):
|
|
+ # Handle nested unevaluated Mul expressions by recursively extracting args
|
|
+ if term.is_Mul:
|
|
+ n, d = fraction(term, exact=exact)
|
|
+ numer.append(n)
|
|
+ if d is not S.One:
|
|
+ denom.append(d)
|
|
+ continue
|
|
+
|
|
+ if term.is_commutative and (term.is_Pow or isinstance(term, exp)):
|
|
b, ex = term.as_base_exp()
|
|
if ex.is_negative:
|
|
if ex is S.NegativeOne:
|