Repository: sympy/sympy
Pull request: solve exp and difference of logs  with irrational coefficients
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234". See
https://github.com/blog/1506-closing-issues-via-pull-requests . Please also
write a comment on that issue linking back to this pull request once it is
open. -->
Fixes #15949

#### Brief description of what is fixed or changed
```
In [1]: x,y=symbols('x y',positive=True)                                                                                                                                                                     

In [2]: exp(sqrt(2)*(log(x)-log(y)))                                                                                                                                                                         
Out[2]: 
 √2⋅(log(x) - log(y))
ℯ    
```
As expression is not combining by itself.
So I use logcombine to combine when x,y is positive .
#### Other comments


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
- functions
  - use logcombine to combine "logs  with irrational coefficients" 
<!-- END RELEASE NOTES -->


Problem statement:
exp and difference of logs doesn't simplify with irrational coefficients 
These expressions auto-simplify
```julia
In [36]: x, y = symbols('x y')                                                                                                    

In [37]: exp(log(x))                                                                                                              
Out[37]: x

In [38]: exp(log(x)-log(y))                                                                                                       
Out[38]: 
x
─
y

In [39]: exp(2*(log(x)-log(y)))                                                                                                   
Out[39]: 
 2
x 
──
 2
y 

In [41]: exp(sqrt(2)*log(x))                                                                                                      
Out[41]: 
 √2
x  
```
However this one does not simplify:
```julia
In [42]: exp(sqrt(2)*(log(x)-log(y)))                                                                                             
Out[42]: 
 √2⋅(log(x) - log(y))
ℯ                    

In [43]: simplify(_)                                                                                                              
Out[43]: 
 √2⋅(log(x) - log(y))
ℯ                    
```

I would expect one of these results:
```julia
In [44]: (x/y)**sqrt(2)                                                                                                           
Out[44]: 
   √2
⎛x⎞  
⎜─⎟  
⎝y⎠  

In [45]: x**sqrt(2)/y**sqrt(2)                                                                                                    
Out[45]: 
 √2  -√2
x  ⋅y   
```

Hints from issue discussion:
I think` exp(log(x)-log(y))` should not combine until we define x as positive integer.
```
In [6]: x,y=symbols('x y')                                                                                                                                                                                   

In [7]: exp(log(x)-log(y))                                                                                                                                                                                   
Out[7]: 
x
─
y

```
so i think this is an issue.
but if we define x,y as positive then also` exp(sqrt(2)*(log(x)-log(y)))` is not combining .
So i am looking for this.
Thanks

Commit message: solve exp and difference of logs  with irrational coefficients

Patch to review:
diff --git a/sympy/functions/elementary/exponential.py b/sympy/functions/elementary/exponential.py
index 2827ad648385..01021b064346 100644
--- a/sympy/functions/elementary/exponential.py
+++ b/sympy/functions/elementary/exponential.py
@@ -231,6 +231,7 @@ def eval(cls, arg):
         from sympy.calculus import AccumBounds
         from sympy.sets.setexpr import SetExpr
         from sympy.matrices.matrices import MatrixBase
+        from sympy import logcombine
         if arg.is_Number:
             if arg is S.NaN:
                 return S.NaN
@@ -277,9 +278,9 @@ def eval(cls, arg):
 
             coeffs, log_term = [coeff], None
             for term in Mul.make_args(terms):
-                if isinstance(term, log):
+                if isinstance(logcombine(term), log):
                     if log_term is None:
-                        log_term = term.args[0]
+                        log_term = logcombine(term).args[0]
                     else:
                         return None
                 elif term.is_comparable:


Code review comments:
diff_hunk: @@ -277,9 +278,9 @@ def eval(cls, arg):
 
             coeffs, log_term = [coeff], None
             for term in Mul.make_args(terms):
-                if isinstance(term, log):
+                if isinstance(logcombine(term), log):
                     if log_term is None:
-                        log_term = term.args[0]
+                        log_term = logcombine(term).args[0]
path: sympy/functions/elementary/exponential.py
text: @user1:
You are calling `logcombine` twice which is inefficient.

@author:
okk i got you.