Repository: sympy/sympy (python)

Issue:
Simplify returns expression with a Dummy variable

The following code:
```
from sympy import var, Matrix, sqrt, simplify, sin, cos, tan, atan, I, re, im, sinh, cosh

z = var('z')

F = sqrt(cosh(z/2)) * Matrix([
    cosh(z/4 + I/2*atan(sinh(z/2))),
    -I*sinh(z/4 + I/2*atan(sinh(z/2))),
    cosh(-z/4 + I/2*atan(sinh(z/2))),
    -I*sinh(-z/4 + I/2*atan(sinh(z/2)))
    ])

display(simplify(F[0]*F[2] - F[1]*F[3]))
```
Produces this output, up to a varying dummy index:
```
cosh(z/2)*cosh(_Dummy_50*atan(sinh(z/2)))
```


Patch:
diff --git a/.mailmap b/.mailmap
index 00397fbf108e..042d2a233a33 100644
--- a/.mailmap
+++ b/.mailmap
@@ -343,7 +343,7 @@ Anjul Kumar Tyagi <anjul.ten@gmail.com>
 Ankit Agrawal <aaaagrawal@iitb.ac.in>
 Ankit Kumar Singh <ankitdiswar10@gmail.com>
 Ankit Raj Pandey <pandeyan@grinnell.edu> Ankit Pandey <pandeyan@grinnell.edu>
-Annamalai N <srirammount@gmail.com> Annamalai <91740832+RaMathuZen@users.noreply.github.com> 
+Annamalai N <srirammount@gmail.com> Annamalai <91740832+RaMathuZen@users.noreply.github.com>
 Annamalai N <srirammount@gmail.com> ramathuzen <srirammount@gmail.com>
 Ansh Mishra <anshmishra471@gmail.com>
 Anshul Sharma <anshulsharma4605@gmail.com>
@@ -1138,6 +1138,8 @@ MostafaGalal1 <mostafag649.mg@gmail.com> Mostafa Galal <77402549+MostafaGalal1@u
 Mridul Seth <seth.mridul@gmail.com>
 Muhammad Maaz <mmaaz6004@gmail.com> Maaz <76714503+mmaaz-git@users.noreply.github.com>
 Muhammed Abdul Quadir Owais <quadirowais200@gmail.com> MaqOwais <quadirowais200@gmail.com>
+Musab Kasbati <musab16000@gmail.com> Musab Kasbati <43878981+Musab1Blaser@users.noreply.github.com>
+Musab Kasbati <musab16000@gmail.com> Musab1Blaser <musab16000@gmail.com>
 Muskan Kumar <31043527+muskanvk@users.noreply.github.com>
 Nabanita Dash <dashnabanita@gmail.com> Naba7 <dashnabanita@gmail.com>
 Nabanita Dash <dashnabanita@gmail.com> Nabanita Dash <31562743+Naba7@users.noreply.github.com>
diff --git a/sympy/simplify/fu.py b/sympy/simplify/fu.py
index a26706edca98..d942d34aaccb 100644
--- a/sympy/simplify/fu.py
+++ b/sympy/simplify/fu.py
@@ -2022,8 +2022,11 @@ def _osbornei(e, d):
     """
 
     def f(rv):
-        if not isinstance(rv, TrigonometricFunction):
+        if not isinstance(rv, (TrigonometricFunction, HyperbolicFunction)):
             return rv
+        if isinstance(rv, HyperbolicFunction):
+            a = rv.args[0].xreplace({d: I})
+            return rv.func(a)
         const, x = rv.args[0].as_independent(d, as_Add=True)
         a = x.xreplace({d: S.One}) + const*I
         if isinstance(rv, sin):


Test patch:
diff --git a/sympy/simplify/tests/test_trigsimp.py b/sympy/simplify/tests/test_trigsimp.py
index ea091ec8a6c7..871e2ffd30db 100644
--- a/sympy/simplify/tests/test_trigsimp.py
+++ b/sympy/simplify/tests/test_trigsimp.py
@@ -209,6 +209,13 @@ def test_trigsimp_issues():
 
     assert trigsimp(-sin(x)**4 - 2*sin(x)**2*cos(x)**2 - cos(x)**4) == -1
 
+    # issue 29056: the expressions below previously manipulated Dummy variables
+    # in a way that prevented restoring them, leaving them in the final output
+    z = (-sinh((x - 2*I*atan(sinh(x/2)))/4))*sinh((x + 2*I*atan(sinh(x/2)))/4)
+    assert trigsimp(z) == -cosh(x/2)/2 + 1/(2*sqrt(sinh(x/2)**2 + 1))
+    z = cosh(x/4 + I/2*atan(sinh(x/2))) * cosh(-x/4 + I/2*atan(sinh(x/2)))
+    z1 = -I*sinh(x/4 + I/2*atan(sinh(x/2))) * -I*sinh(-x/4 + I/2*atan(sinh(x/2)))
+    assert trigsimp(cosh(x/2) * (z - z1)) == cosh(x/2)/sqrt(sinh(x/2)**2 + 1)
 
 def test_trigsimp_issue_2515():
     x = Symbol('x')