Repository: sympy/sympy (Python)

Issue:
sqrt() automatically pulls out a floating point factor
```py
>>> sqrt(4*x + 16)
sqrt(4*x + 16)
>>> sqrt(4.*x + 16.)
4.0*sqrt(0.25*x + 1)
```

I don't think the second instance should be automatically rewritten as it is. It's not simpler than the original, and doing such an automatic simplification can change the behavior of an expression when evaluated on floating point inputs. 
Pow of Add should not extract Floats
I don't know if there is an existing issue about this but this behaviour should be changed:
```python
In [4]: (x**2 + 10)**2
Out[4]: 
         2
⎛ 2     ⎞ 
⎝x  + 10⎠ 

In [5]: (x**2 + 10.0)**2
Out[5]: 
                  2
      ⎛     2    ⎞ 
100.0⋅⎝0.1⋅x  + 1⎠ 
```
The behaviour comes from gh-16762 which links various issues but I don't see any good justification for applying this transformation especially automatically. The example above with 10.0 becoming 100.0 might seem reasonable (I don't consider it reasonable) but there are many situations where this is clearly a bad idea:
```python
In [15]: (x**2 + 7.0)**1000
Out[15]: 
                                                1000
                      ⎛                   2    ⎞    
1.25325663996572e+845⋅⎝0.142857142857143⋅x  + 1⎠ 
```
This behaviour should not be expected and anything that it was intended to address should be handled some other way.

The code that handles this is here:
https://github.com/sympy/sympy/blob/30c23fec32d6babaab813e8c67a133d1ce08a42a/sympy/core/add.py#L490-L503
There is a comment with a question "should this always be done" I think that the answer is that it should never be done automatically like this. There can be some other function for doing things like this if desired. Otherwise it is generally a bad idea to special case floats like this in low-level expression manipulation. Especially with floats it is important to avoid performing any unnecessary arithmetic that can introduce additional rounding errors.

Actually I'm unsure about the whole of `Add._eval_power`. It is no wonder that anything with SymPy expressions is slow when you see stuff like this:
https://github.com/sympy/sympy/blob/30c23fec32d6babaab813e8c67a133d1ce08a42a/sympy/core/add.py#L454-L503


Discussion:
This is handled here:
https://github.com/sympy/sympy/blob/ef14666d718f147878b51ed7ba9a5192e16c04f3/sympy/core/add.py#L482-L495

Looks like it was added in https://github.com/sympy/sympy/pull/16762. I'll have to take a closer look at the issues that was fixing to understand why this is being done. 
Actually the issue https://github.com/sympy/sympy/issues/2993 sounds like it is complaining about similar behavior:

> The coefficients in the input equation were all fairly close to 1, so I don't understand why sympy decided to pull 2e-16 out of the square root while at the same time multiplying everything under the radical sign by 4e+32. More importantly, I can't find any simplification commands that will convince sympy to factor those coefficients back in. In addition to making the equation needlessly long and messy, it can introduce loss of precision when numerically evaluating the output.

So was this "fixed" just by making sqrt pull out a different factor than what it used to? From what I can tell, now it pulls out the largest coefficient value. This is probably better for numerical precision than what was happening before, but I don't see why it needs to automatically factor out coefficients from an Add at all.
I would just delete the referenced code. The original issue should be fixed in a different way.
This will lead to better scaling of expressions since they are more canonical, I believe. I imagine I had some discussion or notes in the issue in which this was added.  See also [here](https://stackoverflow.com/questions/56792659/simplifying-large-coefficients-in-sympy/56805700#56805700). And, as pointed out in the original issue, is consistent with the following behavior:

```python
>>> (.23*x)**.3
0.643455253163189*x**0.3
```





Patch:
diff --git a/sympy/core/add.py b/sympy/core/add.py
index f09051ed8bd7..d9144593991d 100644
--- a/sympy/core/add.py
+++ b/sympy/core/add.py
@@ -8,7 +8,6 @@
 from .singleton import S
 from .operations import AssocOp, AssocOpDispatcher
 from .cache import cacheit
-from .numbers import equal_valued
 from .intfunc import ilcm, igcd
 from .expr import Expr
 from .kind import UndefinedKind
@@ -487,20 +486,6 @@ def _eval_power(self, e):
                     return _unevaluated_Mul(
                         r - i*S.ImaginaryUnit,
                         1/(r**2 + i**2))
-        elif e.is_Number and abs(e) != 1:
-            # handle the Float case: (2.0 + 4*x)**e -> 4**e*(0.5 + x)**e
-            c, m = zip(*[i.as_coeff_Mul() for i in self.args])
-            if any(i.is_Float for i in c):  # XXX should this always be done?
-                big = -1
-                for i in c:
-                    if abs(i) >= big:
-                        big = abs(i)
-                if big > 0 and not equal_valued(big, 1):
-                    from sympy.functions.elementary.complexes import sign
-                    bigs = (big, -big)
-                    c = [sign(i) if i in bigs else i/big for i in c]
-                    addpow = Add(*[c*m for c, m in zip(c, m)])**e
-                    return big**e*addpow
 
     @cacheit
     def _eval_derivative(self, s):
diff --git a/sympy/physics/biomechanics/curve.py b/sympy/physics/biomechanics/curve.py
index 6474dc1517cc..50535271f514 100644
--- a/sympy/physics/biomechanics/curve.py
+++ b/sympy/physics/biomechanics/curve.py
@@ -1020,9 +1020,9 @@ class FiberForceLengthActiveDeGroote2016(CharacteristicCurveFunction):
     canonical form and won't simplify any constants.
 
     >>> fl_M.doit(evaluate=False)
-    0.814*exp(-19.0519737844841*(l_M/l_M_opt
-    - 1.06)**2/(0.390740740740741*l_M/l_M_opt + 1)**2)
-    + 0.433*exp(-12.5*(l_M/l_M_opt - 0.717)**2/(l_M/l_M_opt - 0.1495)**2)
+    0.814*exp(-(l_M/l_M_opt
+    - 1.06)**2/(2*(0.0633*l_M/l_M_opt + 0.162)**2))
+    + 0.433*exp(-(l_M/l_M_opt - 0.717)**2/(2*(0.2*l_M/l_M_opt - 0.0299)**2))
     + 0.1*exp(-3.98991349867535*(l_M/l_M_opt - 1.0)**2)
 
     The function can also be differentiated. We'll differentiate with respect
@@ -1032,14 +1032,14 @@ class FiberForceLengthActiveDeGroote2016(CharacteristicCurveFunction):
     >>> fl_M.diff(l_M)
     ((-0.79798269973507*l_M/l_M_opt
     + 0.79798269973507)*exp(-3.98991349867535*(l_M/l_M_opt - 1.0)**2)
-    + (10.825*(-l_M/l_M_opt + 0.717)/(l_M/l_M_opt - 0.1495)**2
-    + 10.825*(l_M/l_M_opt - 0.717)**2/(l_M/l_M_opt
-    - 0.1495)**3)*exp(-12.5*(l_M/l_M_opt - 0.717)**2/(l_M/l_M_opt - 0.1495)**2)
-    + (31.0166133211401*(-l_M/l_M_opt + 1.06)/(0.390740740740741*l_M/l_M_opt
-    + 1)**2 + 13.6174190361677*(0.943396226415094*l_M/l_M_opt
-    - 1)**2/(0.390740740740741*l_M/l_M_opt
-    + 1)**3)*exp(-21.4067977442463*(0.943396226415094*l_M/l_M_opt
-    - 1)**2/(0.390740740740741*l_M/l_M_opt + 1)**2))/l_M_opt
+    + (0.433*(-l_M/l_M_opt + 0.717)/(0.2*l_M/l_M_opt - 0.0299)**2
+    + 0.0866*(l_M/l_M_opt - 0.717)**2/(0.2*l_M/l_M_opt
+    - 0.0299)**3)*exp(-(l_M/l_M_opt - 0.717)**2/(2*(0.2*l_M/l_M_opt - 0.0299)**2))
+    + (0.814*(-l_M/l_M_opt + 1.06)/(0.0633*l_M/l_M_opt
+    + 0.162)**2 + 0.0515262*(l_M/l_M_opt
+    - 1.06)**2/(0.0633*l_M/l_M_opt
+    + 0.162)**3)*exp(-(l_M/l_M_opt
+    - 1.06)**2/(2*(0.0633*l_M/l_M_opt + 0.162)**2)))/l_M_opt
 
     References
     ==========
diff --git a/sympy/physics/continuum_mechanics/cable.py b/sympy/physics/continuum_mechanics/cable.py
index 0c493ec56035..e38c6601b0a1 100644
--- a/sympy/physics/continuum_mechanics/cable.py
+++ b/sympy/physics/continuum_mechanics/cable.py
@@ -620,7 +620,7 @@ def draw(self):
         >>> p = c.draw()
         >>> p # doctest: +ELLIPSIS
         Plot object containing:
-        [0]: cartesian line: 39.9955291375291*(0.0170706725844998*x - 1)**2 + 0.00447086247086247 for x over (0.0, 100.0)
+        [0]: cartesian line: 0.0116550116550117*(x - 58.58)**2 + 0.00447086247086247 for x over (0.0, 100.0)
         [1]: cartesian line: -7.49552913752915 for x over (0.0, 100.0)
         ...
         >>> p.show()


Test patch:
diff --git a/sympy/core/tests/test_power.py b/sympy/core/tests/test_power.py
index f1080e338de7..80ae48c525c2 100644
--- a/sympy/core/tests/test_power.py
+++ b/sympy/core/tests/test_power.py
@@ -496,17 +496,17 @@ def test_better_sqrt():
 
 
 def test_issue_2993():
-    assert str((2.3*x - 4)**0.3) == '1.5157165665104*(0.575*x - 1)**0.3'
-    assert str((2.3*x + 4)**0.3) == '1.5157165665104*(0.575*x + 1)**0.3'
-    assert str((-2.3*x + 4)**0.3) == '1.5157165665104*(1 - 0.575*x)**0.3'
-    assert str((-2.3*x - 4)**0.3) == '1.5157165665104*(-0.575*x - 1)**0.3'
-    assert str((2.3*x - 2)**0.3) == '1.28386201800527*(x - 0.869565217391304)**0.3'
-    assert str((-2.3*x - 2)**0.3) == '1.28386201800527*(-x - 0.869565217391304)**0.3'
-    assert str((-2.3*x + 2)**0.3) == '1.28386201800527*(0.869565217391304 - x)**0.3'
-    assert str((2.3*x + 2)**0.3) == '1.28386201800527*(x + 0.869565217391304)**0.3'
-    assert str((2.3*x - 4)**Rational(1, 3)) == '2**(2/3)*(0.575*x - 1)**(1/3)'
+    assert str((2.3*x - 4)**0.3) == '(2.3*x - 4)**0.3'
+    assert str((2.3*x + 4)**0.3) == '(2.3*x + 4)**0.3'
+    assert str((-2.3*x + 4)**0.3) == '(4 - 2.3*x)**0.3'
+    assert str((-2.3*x - 4)**0.3) == '(-2.3*x - 4)**0.3'
+    assert str((2.3*x - 2)**0.3) == '(2.3*x - 2)**0.3'
+    assert str((-2.3*x - 2)**0.3) == '(-2.3*x - 2)**0.3'
+    assert str((-2.3*x + 2)**0.3) == '(2 - 2.3*x)**0.3'
+    assert str((2.3*x + 2)**0.3) == '(2.3*x + 2)**0.3'
+    assert str((2.3*x - 4)**Rational(1, 3)) == '(2.3*x - 4)**(1/3)'
     eq = (2.3*x + 4)
-    assert eq**2 == 16*(0.575*x + 1)**2
+    assert str(eq**2) == '(2.3*x + 4)**2'
     assert (1/eq).args == (eq, -1)  # don't change trivial power
     # issue 17735
     q=.5*exp(x) - .5*exp(-x) + 0.1
diff --git a/sympy/physics/biomechanics/tests/test_curve.py b/sympy/physics/biomechanics/tests/test_curve.py
index 6dfd9ab9d412..6a8fcbccdb8b 100644
--- a/sympy/physics/biomechanics/tests/test_curve.py
+++ b/sympy/physics/biomechanics/tests/test_curve.py
@@ -1035,175 +1035,95 @@ def test_expression_print_latex(self):
             (
                 C89CodePrinter,
                 (
-                    '(0.81399999999999995*exp(-19.051973784484073'
-                    '*pow(l_M_tilde - 1.0600000000000001, 2)'
-                    '/pow(0.39074074074074072*l_M_tilde + 1, 2)) '
-                    '+ 0.433*exp(-12.499999999999998'
-                    '*pow(l_M_tilde - 0.71699999999999997, 2)'
-                    '/pow(l_M_tilde - 0.14949999999999999, 2)) '
-                    '+ 0.10000000000000001*exp(-3.9899134986753491'
-                    '*pow(l_M_tilde - 1.0, 2)))'
+                    '(0.81399999999999995*exp(-1.0/2.0*pow(l_M_tilde - 1.0600000000000001, 2)/pow(0.063299999999999995*l_M_tilde + 0.16200000000000001, 2)) + 0.433*exp(-1.0/2.0*pow(l_M_tilde - 0.71699999999999997, 2)/pow(0.20000000000000001*l_M_tilde - 0.029899999999999999, 2)) + 0.10000000000000001*exp(-3.9899134986753491*pow(l_M_tilde - 1.0, 2)))'
                 ),
             ),
             (
                 C99CodePrinter,
                 (
-                    '(0.81399999999999995*exp(-19.051973784484073'
-                    '*pow(l_M_tilde - 1.0600000000000001, 2)'
-                    '/pow(0.39074074074074072*l_M_tilde + 1, 2)) '
-                    '+ 0.433*exp(-12.499999999999998'
-                    '*pow(l_M_tilde - 0.71699999999999997, 2)'
-                    '/pow(l_M_tilde - 0.14949999999999999, 2)) '
-                    '+ 0.10000000000000001*exp(-3.9899134986753491'
-                    '*pow(l_M_tilde - 1.0, 2)))'
+                    '(0.81399999999999995*exp(-1.0/2.0*pow(l_M_tilde - 1.0600000000000001, 2)/pow(0.063299999999999995*l_M_tilde + 0.16200000000000001, 2)) + 0.433*exp(-1.0/2.0*pow(l_M_tilde - 0.71699999999999997, 2)/pow(0.20000000000000001*l_M_tilde - 0.029899999999999999, 2)) + 0.10000000000000001*exp(-3.9899134986753491*pow(l_M_tilde - 1.0, 2)))'
                 ),
             ),
             (
                 C11CodePrinter,
                 (
-                    '(0.81399999999999995*exp(-19.051973784484073'
-                    '*pow(l_M_tilde - 1.0600000000000001, 2)'
-                    '/pow(0.39074074074074072*l_M_tilde + 1, 2)) '
-                    '+ 0.433*exp(-12.499999999999998'
-                    '*pow(l_M_tilde - 0.71699999999999997, 2)'
-                    '/pow(l_M_tilde - 0.14949999999999999, 2)) '
-                    '+ 0.10000000000000001*exp(-3.9899134986753491'
-                    '*pow(l_M_tilde - 1.0, 2)))'
+                    '(0.81399999999999995*exp(-1.0/2.0*pow(l_M_tilde - 1.0600000000000001, 2)/pow(0.063299999999999995*l_M_tilde + 0.16200000000000001, 2)) + 0.433*exp(-1.0/2.0*pow(l_M_tilde - 0.71699999999999997, 2)/pow(0.20000000000000001*l_M_tilde - 0.029899999999999999, 2)) + 0.10000000000000001*exp(-3.9899134986753491*pow(l_M_tilde - 1.0, 2)))'
                 ),
             ),
             (
                 CXX98CodePrinter,
                 (
-                    '(0.81399999999999995*exp(-19.051973784484073'
-                    '*std::pow(l_M_tilde - 1.0600000000000001, 2)'
-                    '/std::pow(0.39074074074074072*l_M_tilde + 1, 2)) '
-                    '+ 0.433*exp(-12.499999999999998'
-                    '*std::pow(l_M_tilde - 0.71699999999999997, 2)'
-                    '/std::pow(l_M_tilde - 0.14949999999999999, 2)) '
-                    '+ 0.10000000000000001*exp(-3.9899134986753491'
-                    '*std::pow(l_M_tilde - 1.0, 2)))'
+                    '(0.81399999999999995*exp(-1.0/2.0*std::pow(l_M_tilde - 1.0600000000000001, 2)/std::pow(0.063299999999999995*l_M_tilde + 0.16200000000000001, 2)) + 0.433*exp(-1.0/2.0*std::pow(l_M_tilde - 0.71699999999999997, 2)/std::pow(0.20000000000000001*l_M_tilde - 0.029899999999999999, 2)) + 0.10000000000000001*exp(-3.9899134986753491*std::pow(l_M_tilde - 1.0, 2)))'
                 ),
             ),
             (
                 CXX11CodePrinter,
                 (
-                    '(0.81399999999999995*std::exp(-19.051973784484073'
-                    '*std::pow(l_M_tilde - 1.0600000000000001, 2)'
-                    '/std::pow(0.39074074074074072*l_M_tilde + 1, 2)) '
-                    '+ 0.433*std::exp(-12.499999999999998'
-                    '*std::pow(l_M_tilde - 0.71699999999999997, 2)'
-                    '/std::pow(l_M_tilde - 0.14949999999999999, 2)) '
-                    '+ 0.10000000000000001*std::exp(-3.9899134986753491'
-                    '*std::pow(l_M_tilde - 1.0, 2)))'
+                    '(0.81399999999999995*std::exp(-1.0/2.0*std::pow(l_M_tilde - 1.0600000000000001, 2)/std::pow(0.063299999999999995*l_M_tilde + 0.16200000000000001, 2)) + 0.433*std::exp(-1.0/2.0*std::pow(l_M_tilde - 0.71699999999999997, 2)/std::pow(0.20000000000000001*l_M_tilde - 0.029899999999999999, 2)) + 0.10000000000000001*std::exp(-3.9899134986753491*std::pow(l_M_tilde - 1.0, 2)))'
                 ),
             ),
             (
                 CXX17CodePrinter,
                 (
-                    '(0.81399999999999995*std::exp(-19.051973784484073'
-                    '*std::pow(l_M_tilde - 1.0600000000000001, 2)'
-                    '/std::pow(0.39074074074074072*l_M_tilde + 1, 2)) '
-                    '+ 0.433*std::exp(-12.499999999999998'
-                    '*std::pow(l_M_tilde - 0.71699999999999997, 2)'
-                    '/std::pow(l_M_tilde - 0.14949999999999999, 2)) '
-                    '+ 0.10000000000000001*std::exp(-3.9899134986753491'
-                    '*std::pow(l_M_tilde - 1.0, 2)))'
+                    '(0.81399999999999995*std::exp(-1.0/2.0*std::pow(l_M_tilde - 1.0600000000000001, 2)/std::pow(0.063299999999999995*l_M_tilde + 0.16200000000000001, 2)) + 0.433*std::exp(-1.0/2.0*std::pow(l_M_tilde - 0.71699999999999997, 2)/std::pow(0.20000000000000001*l_M_tilde - 0.029899999999999999, 2)) + 0.10000000000000001*std::exp(-3.9899134986753491*std::pow(l_M_tilde - 1.0, 2)))'
                 ),
             ),
             (
                 FCodePrinter,
                 (
-                    '      (0.814d0*exp(-19.051973784484073d0*(l_M_tilde - 1.06d0)**2/(\n'
-                    '     @ 0.39074074074074072d0*l_M_tilde + 1.0d0)**2) + 0.433d0*exp(\n'
-                    '     @ -12.499999999999998d0*(l_M_tilde - 0.717d0)**2/(l_M_tilde -\n'
-                    '     @ 0.14949999999999999d0)**2) + 0.1d0*exp(-3.9899134986753491d0*(\n'
-                    '     @ l_M_tilde - 1.0d0)**2))'
+                    '      (0.814d0*exp(-0.5d0*(l_M_tilde - 1.06d0)**2/(\n'
+                    '     @ 0.063299999999999995d0*l_M_tilde + 0.16200000000000001d0)**2) +\n'
+                    '     @ 0.433d0*exp(-0.5d0*(l_M_tilde - 0.717d0)**2/(\n'
+                    '     @ 0.20000000000000001d0*l_M_tilde - 0.029899999999999999d0)**2) +\n'
+                    '     @ 0.1d0*exp(-3.9899134986753491d0*(l_M_tilde - 1.0d0)**2))'
                 ),
             ),
             (
                 OctaveCodePrinter,
                 (
-                    '(0.814*exp(-19.0519737844841*(l_M_tilde - 1.06).^2'
-                    './(0.390740740740741*l_M_tilde + 1).^2) '
-                    '+ 0.433*exp(-12.5*(l_M_tilde - 0.717).^2'
-                    './(l_M_tilde - 0.1495).^2) '
-                    '+ 0.1*exp(-3.98991349867535*(l_M_tilde - 1.0).^2))'
+                    '(0.814*exp(-(l_M_tilde - 1.06).^2./(2*(0.0633*l_M_tilde + 0.162).^2)) + 0.433*exp(-(l_M_tilde - 0.717).^2./(2*(0.2*l_M_tilde - 0.0299).^2)) + 0.1*exp(-3.98991349867535*(l_M_tilde - 1.0).^2))'
                 ),
             ),
             (
                 PythonCodePrinter,
                 (
-                    '(0.814*math.exp(-19.0519737844841*(l_M_tilde - 1.06)**2'
-                    '/(0.390740740740741*l_M_tilde + 1)**2) '
-                    '+ 0.433*math.exp(-12.5*(l_M_tilde - 0.717)**2'
-                    '/(l_M_tilde - 0.1495)**2) '
-                    '+ 0.1*math.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
+                    '(0.814*math.exp(-1/2*(l_M_tilde - 1.06)**2/(0.0633*l_M_tilde + 0.162)**2) + 0.433*math.exp(-1/2*(l_M_tilde - 0.717)**2/(0.2*l_M_tilde - 0.0299)**2) + 0.1*math.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
                 ),
             ),
             (
                 NumPyPrinter,
                 (
-                    '(0.814*numpy.exp(-19.0519737844841*(l_M_tilde - 1.06)**2'
-                    '/(0.390740740740741*l_M_tilde + 1)**2) '
-                    '+ 0.433*numpy.exp(-12.5*(l_M_tilde - 0.717)**2'
-                    '/(l_M_tilde - 0.1495)**2) '
-                    '+ 0.1*numpy.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
+                    '(0.814*numpy.exp(-1/2*(l_M_tilde - 1.06)**2/(0.0633*l_M_tilde + 0.162)**2) + 0.433*numpy.exp(-1/2*(l_M_tilde - 0.717)**2/(0.2*l_M_tilde - 0.0299)**2) + 0.1*numpy.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
                 ),
             ),
             (
                 SciPyPrinter,
                 (
-                    '(0.814*numpy.exp(-19.0519737844841*(l_M_tilde - 1.06)**2'
-                    '/(0.390740740740741*l_M_tilde + 1)**2) '
-                    '+ 0.433*numpy.exp(-12.5*(l_M_tilde - 0.717)**2'
-                    '/(l_M_tilde - 0.1495)**2) '
-                    '+ 0.1*numpy.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
+                    '(0.814*numpy.exp(-1/2*(l_M_tilde - 1.06)**2/(0.0633*l_M_tilde + 0.162)**2) + 0.433*numpy.exp(-1/2*(l_M_tilde - 0.717)**2/(0.2*l_M_tilde - 0.0299)**2) + 0.1*numpy.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
                 ),
             ),
             (
                 CuPyPrinter,
                 (
-                    '(0.814*cupy.exp(-19.0519737844841*(l_M_tilde - 1.06)**2'
-                    '/(0.390740740740741*l_M_tilde + 1)**2) '
-                    '+ 0.433*cupy.exp(-12.5*(l_M_tilde - 0.717)**2'
-                    '/(l_M_tilde - 0.1495)**2) '
-                    '+ 0.1*cupy.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
+                    '(0.814*cupy.exp(-1/2*(l_M_tilde - 1.06)**2/(0.0633*l_M_tilde + 0.162)**2) + 0.433*cupy.exp(-1/2*(l_M_tilde - 0.717)**2/(0.2*l_M_tilde - 0.0299)**2) + 0.1*cupy.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
                 ),
             ),
             (
                 JaxPrinter,
                 (
-                    '(0.814*jax.numpy.exp(-19.0519737844841*(l_M_tilde - 1.06)**2'
-                    '/(0.390740740740741*l_M_tilde + 1)**2) '
-                    '+ 0.433*jax.numpy.exp(-12.5*(l_M_tilde - 0.717)**2'
-                    '/(l_M_tilde - 0.1495)**2) '
-                    '+ 0.1*jax.numpy.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
+                    '(0.814*jax.numpy.exp(-1/2*(l_M_tilde - 1.06)**2/(0.0633*l_M_tilde + 0.162)**2) + 0.433*jax.numpy.exp(-1/2*(l_M_tilde - 0.717)**2/(0.2*l_M_tilde - 0.0299)**2) + 0.1*jax.numpy.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
                 ),
             ),
             (
                 MpmathPrinter,
                 (
-                    '(mpmath.mpf((0, 7331860193359167, -53, 53))'
-                    '*mpmath.exp(-mpmath.mpf((0, 5362653877279683, -48, 53))'
-                    '*(l_M_tilde + mpmath.mpf((1, 2386907802506363, -51, 52)))**2'
-                    '/(mpmath.mpf((0, 3519479708796943, -53, 52))*l_M_tilde + 1)**2) '
-                    '+ mpmath.mpf((0, 7800234554605699, -54, 53))'
-                    '*mpmath.exp(-mpmath.mpf((0, 7036874417766399, -49, 53))'
-                    '*(l_M_tilde + mpmath.mpf((1, 6458161865649291, -53, 53)))**2'
-                    '/(l_M_tilde + mpmath.mpf((1, 5386305154335113, -55, 53)))**2) '
-                    '+ mpmath.mpf((0, 3602879701896397, -55, 52))'
-                    '*mpmath.exp(-mpmath.mpf((0, 8984486472937407, -51, 53))'
-                    '*(l_M_tilde + mpmath.mpf((1, 1, 0, 1)))**2))'
+                    '(mpmath.mpf((0, 7331860193359167, -53, 53))*mpmath.exp(-mpmath.mpf(1)/mpmath.mpf(2)*(l_M_tilde + mpmath.mpf((1, 2386907802506363, -51, 52)))**2/(mpmath.mpf((0, 2280622851300419, -55, 52))*l_M_tilde + mpmath.mpf((0, 5836665117072163, -55, 53)))**2) + mpmath.mpf((0, 7800234554605699, -54, 53))*mpmath.exp(-mpmath.mpf(1)/mpmath.mpf(2)*(l_M_tilde + mpmath.mpf((1, 6458161865649291, -53, 53)))**2/(mpmath.mpf((0, 3602879701896397, -54, 52))*l_M_tilde + mpmath.mpf((1, 8618088246936181, -58, 53)))**2) + mpmath.mpf((0, 3602879701896397, -55, 52))*mpmath.exp(-mpmath.mpf((0, 8984486472937407, -51, 53))*(l_M_tilde + mpmath.mpf((1, 1, 0, 1)))**2))'
                 ),
             ),
             (
                 LambdaPrinter,
                 (
-                    '(0.814*math.exp(-19.0519737844841*(l_M_tilde - 1.06)**2'
-                    '/(0.390740740740741*l_M_tilde + 1)**2) '
-                    '+ 0.433*math.exp(-12.5*(l_M_tilde - 0.717)**2'
-                    '/(l_M_tilde - 0.1495)**2) '
-                    '+ 0.1*math.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
+                    '(0.814*math.exp(-1/2*(l_M_tilde - 1.06)**2/(0.0633*l_M_tilde + 0.162)**2) + 0.433*math.exp(-1/2*(l_M_tilde - 0.717)**2/(0.2*l_M_tilde - 0.0299)**2) + 0.1*math.exp(-3.98991349867535*(l_M_tilde - 1.0)**2))'
                 ),
             ),
         ]
@@ -1216,16 +1136,7 @@ def test_derivative_print_code(self):
         fl_M_act = FiberForceLengthActiveDeGroote2016.with_defaults(self.l_M_tilde)
         fl_M_act_dl_M_tilde = fl_M_act.diff(self.l_M_tilde)
         expected = (
-            '(0.79798269973507 - 0.79798269973507*l_M_tilde)'
-            '*math.exp(-3.98991349867535*(l_M_tilde - 1.0)**2) '
-            '+ (10.825*(0.717 - l_M_tilde)/(l_M_tilde - 0.1495)**2 '
-            '+ 10.825*(l_M_tilde - 0.717)**2/(l_M_tilde - 0.1495)**3)'
-            '*math.exp(-12.5*(l_M_tilde - 0.717)**2/(l_M_tilde - 0.1495)**2) '
-            '+ (31.0166133211401*(1.06 - l_M_tilde)/(0.390740740740741*l_M_tilde + 1)**2 '
-            '+ 13.6174190361677*(0.943396226415094*l_M_tilde - 1)**2'
-            '/(0.390740740740741*l_M_tilde + 1)**3)'
-            '*math.exp(-21.4067977442463*(0.943396226415094*l_M_tilde - 1)**2'
-            '/(0.390740740740741*l_M_tilde + 1)**2)'
+            '(0.79798269973507 - 0.79798269973507*l_M_tilde)*math.exp(-3.98991349867535*(l_M_tilde - 1.0)**2) + (0.433*(0.717 - l_M_tilde)/(0.2*l_M_tilde - 0.0299)**2 + 0.0866*(l_M_tilde - 0.717)**2/(0.2*l_M_tilde - 0.0299)**3)*math.exp(-1/2*(l_M_tilde - 0.717)**2/(0.2*l_M_tilde - 0.0299)**2) + (0.814*(1.06 - l_M_tilde)/(0.0633*l_M_tilde + 0.162)**2 + 0.0515262*(l_M_tilde - 1.06)**2/(0.0633*l_M_tilde + 0.162)**3)*math.exp(-1/2*(l_M_tilde - 1.06)**2/(0.0633*l_M_tilde + 0.162)**2)'
         )
         assert PythonCodePrinter().doprint(fl_M_act_dl_M_tilde) == expected
 
diff --git a/sympy/physics/control/tests/test_control_plots.py b/sympy/physics/control/tests/test_control_plots.py
index 82fe6683ce13..05836c806f93 100644
--- a/sympy/physics/control/tests/test_control_plots.py
+++ b/sympy/physics/control/tests/test_control_plots.py
@@ -322,7 +322,7 @@ def test_nichols_expr():
     m2, p2, w2 = nichols_plot_expr(tf2)
     m3, p3, w3 = nichols_plot_expr(tf3)
     m4, p4, w4 = nichols_plot_expr(tf4)
-    assert m1 == 20*log(1/(2*sqrt(w1**4/4 - 0.9375*w1**2 + 1)))/log(10)
+    assert m1 == 20*log(1/sqrt(w1**4 - 3.75*w1**2 + 4))/log(10)
     assert p1 == 180*arg(1/(-w1**2 + 0.5*w1*I + 2))/pi
     assert m2 == 20*log(Abs(w2)/sqrt(36*w2**4 - 3*w2**2 + 1))/log(10)
     assert p2 == 180*arg(w2*I/(-6*w2**2 + 3*w2*I + 1))/pi