Repository: sympy/sympy

Issue:
integral_steps provides wrong substep for tan(x)
https://sympy-beta.vercel.app/input/integrate(tan(x))
Step 2A is wrong
```py
>>> from sympy import *
>>> from sympy.integrals.manualintegrate import integral_steps
>>> x=Symbol('x')
>>> integral_steps(tan(x), x)
RewriteRule(rewritten=sin(x)/cos(x), substep=URule(u_var=_u, u_func=cos(x), constant=-1, substep=ConstantTimesRule(constant=-1, other=1/_u, substep=ReciprocalRule(func=_u, context=1/_u, symbol=_u), context=1/_u, symbol=_u), context=sin(x)/cos(x), symbol=x), context=tan(x), symbol=x)
```
I'll make a PR to fix it.

Discussion:

Patch:
diff --git a/sympy/integrals/manualintegrate.py b/sympy/integrals/manualintegrate.py
index 37e9716de9..d342e44fcb 100644
--- a/sympy/integrals/manualintegrate.py
+++ b/sympy/integrals/manualintegrate.py
@@ -1129,7 +1129,7 @@ def substitution_rule(integral):
             if simplify(c - 1) != 0:
                 _, denom = c.as_numer_denom()
                 if subrule:
-                    subrule = ConstantTimesRule(c, substituted, subrule, substituted, u_var)
+                    subrule = ConstantTimesRule(c, substituted, subrule, c * substituted, u_var)
 
                 if denom.free_symbols:
                     piecewise = []


Test patch:
diff --git a/sympy/integrals/tests/test_manual.py b/sympy/integrals/tests/test_manual.py
index 80810b5f40..7a12cf7897 100644
--- a/sympy/integrals/tests/test_manual.py
+++ b/sympy/integrals/tests/test_manual.py
@@ -555,3 +555,9 @@ def test_quadratic_denom():
 
 def test_issue_22757():
     assert manualintegrate(sin(x), y) == y * sin(x)
+
+
+def test_issue_23348():
+    steps = integral_steps(tan(x), x)
+    constant_times_step = steps.substep.substep
+    assert constant_times_step.context == constant_times_step.constant * constant_times_step.other