Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.2% → 99.9%
Time: 13.5s
Alternatives: 21
Speedup: 1.6×

Specification

?
\[\begin{array}{l} \\ \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
	return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
	return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U):
	return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U)
	return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U)
end
function tmp = code(J, l, K, U)
	tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}

\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 21 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 86.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
	return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
	return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U):
	return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U)
	return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U)
end
function tmp = code(J, l, K, U)
	tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}

\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}

Alternative 1: 99.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \sinh \ell\right), J, U\right) \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (fma (* (cos (* K 0.5)) (* 2.0 (sinh l))) J U))
double code(double J, double l, double K, double U) {
	return fma((cos((K * 0.5)) * (2.0 * sinh(l))), J, U);
}
function code(J, l, K, U)
	return fma(Float64(cos(Float64(K * 0.5)) * Float64(2.0 * sinh(l))), J, U)
end
code[J_, l_, K_, U_] := N[(N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \sinh \ell\right), J, U\right)
\end{array}
Derivation
  1. Initial program 86.3%

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
    2. Final simplification100.0%

      \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \sinh \ell\right), J, U\right) \]
    3. Add Preprocessing

    Alternative 2: 97.4% accurate, 1.2× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \end{array} \]
    (FPCore (J l K U)
     :precision binary64
     (if (<= (cos (/ K 2.0)) 0.97)
       (fma
        (*
         (cos (* K 0.5))
         (*
          l
          (fma
           (* l l)
           (fma
            (* l l)
            (fma (* l l) 0.0003968253968253968 0.016666666666666666)
            0.3333333333333333)
           2.0)))
        J
        U)
       (fma (* 2.0 (sinh l)) J U)))
    double code(double J, double l, double K, double U) {
    	double tmp;
    	if (cos((K / 2.0)) <= 0.97) {
    		tmp = fma((cos((K * 0.5)) * (l * fma((l * l), fma((l * l), fma((l * l), 0.0003968253968253968, 0.016666666666666666), 0.3333333333333333), 2.0))), J, U);
    	} else {
    		tmp = fma((2.0 * sinh(l)), J, U);
    	}
    	return tmp;
    }
    
    function code(J, l, K, U)
    	tmp = 0.0
    	if (cos(Float64(K / 2.0)) <= 0.97)
    		tmp = fma(Float64(cos(Float64(K * 0.5)) * Float64(l * fma(Float64(l * l), fma(Float64(l * l), fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), 0.3333333333333333), 2.0))), J, U);
    	else
    		tmp = fma(Float64(2.0 * sinh(l)), J, U);
    	end
    	return tmp
    end
    
    code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.97], N[(N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(l * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\
    \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right), J, U\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.96999999999999997

      1. Initial program 86.8%

        \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. Applied egg-rr99.9%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
        2. Taylor expanded in l around 0

          \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
        3. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          2. +-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right) + 2\right)}\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          3. lower-fma.f64N/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \color{blue}{\mathsf{fma}\left({\ell}^{2}, \frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right), 2\right)}\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          4. unpow2N/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right), 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          5. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right), 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          6. +-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right) + \frac{1}{3}}, 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          7. lower-fma.f64N/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\mathsf{fma}\left({\ell}^{2}, \frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}, \frac{1}{3}\right)}, 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          8. unpow2N/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          9. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          10. +-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\frac{1}{2520} \cdot {\ell}^{2} + \frac{1}{60}}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          11. *-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}} + \frac{1}{60}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          12. lower-fma.f64N/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\mathsf{fma}\left({\ell}^{2}, \frac{1}{2520}, \frac{1}{60}\right)}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          13. unpow2N/A

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{2520}, \frac{1}{60}\right), \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
          14. lower-*.f6497.6

            \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right) \]
        4. Simplified97.6%

          \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right)} \cdot \cos \left(K \cdot 0.5\right), J, U\right) \]

        if 0.96999999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

        1. Initial program 85.9%

          \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. Applied egg-rr100.0%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
          2. Taylor expanded in K around 0

            \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
          3. Step-by-step derivation
            1. Simplified99.5%

              \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
            2. Step-by-step derivation
              1. lift-sinh.f64N/A

                \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot 1, J, U\right) \]
              2. *-commutativeN/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot 1, J, U\right) \]
              3. associate-*l*N/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot \left(2 \cdot 1\right)}, J, U\right) \]
              4. metadata-evalN/A

                \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot \color{blue}{2}, J, U\right) \]
              5. lower-*.f6499.5

                \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
            3. Applied egg-rr99.5%

              \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
          4. Recombined 2 regimes into one program.
          5. Final simplification98.6%

            \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \]
          6. Add Preprocessing

          Alternative 3: 97.1% accurate, 1.2× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\ell \cdot \ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), \cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot J\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \end{array} \]
          (FPCore (J l K U)
           :precision binary64
           (if (<= (cos (/ K 2.0)) 0.97)
             (fma
              (fma
               (* l (* l l))
               (fma (* l l) (* l 0.016666666666666666) 0.3333333333333333)
               2.0)
              (* (cos (* K 0.5)) (* l J))
              U)
             (fma (* 2.0 (sinh l)) J U)))
          double code(double J, double l, double K, double U) {
          	double tmp;
          	if (cos((K / 2.0)) <= 0.97) {
          		tmp = fma(fma((l * (l * l)), fma((l * l), (l * 0.016666666666666666), 0.3333333333333333), 2.0), (cos((K * 0.5)) * (l * J)), U);
          	} else {
          		tmp = fma((2.0 * sinh(l)), J, U);
          	}
          	return tmp;
          }
          
          function code(J, l, K, U)
          	tmp = 0.0
          	if (cos(Float64(K / 2.0)) <= 0.97)
          		tmp = fma(fma(Float64(l * Float64(l * l)), fma(Float64(l * l), Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0), Float64(cos(Float64(K * 0.5)) * Float64(l * J)), U);
          	else
          		tmp = fma(Float64(2.0 * sinh(l)), J, U);
          	end
          	return tmp
          end
          
          code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.97], N[(N[(N[(l * N[(l * l), $MachinePrecision]), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision] * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(l * J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\
          \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\ell \cdot \ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), \cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot J\right), U\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.96999999999999997

            1. Initial program 86.8%

              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            2. Add Preprocessing
            3. Taylor expanded in l around 0

              \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            4. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              2. +-commutativeN/A

                \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right) + 2\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              3. lower-fma.f64N/A

                \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left({\ell}^{2}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              4. unpow2N/A

                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              5. lower-*.f64N/A

                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              6. +-commutativeN/A

                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\frac{1}{60} \cdot {\ell}^{2} + \frac{1}{3}}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              7. *-commutativeN/A

                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{{\ell}^{2} \cdot \frac{1}{60}} + \frac{1}{3}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              8. unpow2N/A

                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60} + \frac{1}{3}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              9. associate-*l*N/A

                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{60}\right)} + \frac{1}{3}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              10. lower-fma.f64N/A

                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \frac{1}{60}, \frac{1}{3}\right)}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              11. lower-*.f6496.7

                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot 0.016666666666666666}, 0.3333333333333333\right), 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            5. Simplified96.7%

              \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            6. Taylor expanded in J around -inf

              \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{3} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}\right)\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
            7. Step-by-step derivation
              1. associate-*r*N/A

                \[\leadsto \color{blue}{\left(\left(J \cdot \ell\right) \cdot \left(2 + {\ell}^{3} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
              2. lower-*.f64N/A

                \[\leadsto \color{blue}{\left(\left(J \cdot \ell\right) \cdot \left(2 + {\ell}^{3} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
              3. lower-*.f64N/A

                \[\leadsto \left(\color{blue}{\left(J \cdot \ell\right)} \cdot \left(2 + {\ell}^{3} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              4. +-commutativeN/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \color{blue}{\left({\ell}^{3} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}\right) + 2\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              5. lower-fma.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \color{blue}{\mathsf{fma}\left({\ell}^{3}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              6. cube-multN/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \left(\ell \cdot \ell\right)}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              7. unpow2N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \color{blue}{{\ell}^{2}}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              8. lower-*.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot {\ell}^{2}}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              9. unpow2N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              10. lower-*.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              11. +-commutativeN/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \color{blue}{\frac{1}{60} \cdot {\ell}^{3} + \frac{1}{3}}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              12. lower-fma.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \color{blue}{\mathsf{fma}\left(\frac{1}{60}, {\ell}^{3}, \frac{1}{3}\right)}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              13. cube-multN/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \color{blue}{\ell \cdot \left(\ell \cdot \ell\right)}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              14. unpow2N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \ell \cdot \color{blue}{{\ell}^{2}}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              15. lower-*.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \color{blue}{\ell \cdot {\ell}^{2}}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              16. unpow2N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              17. lower-*.f6497.4

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(0.016666666666666666, \ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}, 0.3333333333333333\right), 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            8. Simplified97.4%

              \[\leadsto \color{blue}{\left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(0.016666666666666666, \ell \cdot \left(\ell \cdot \ell\right), 0.3333333333333333\right), 2\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
            9. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto \left(\color{blue}{\left(J \cdot \ell\right)} \cdot \left(\left(\ell \cdot \left(\ell \cdot \ell\right)\right) \cdot \left(\frac{1}{60} \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right) + \frac{1}{3}\right) + 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              2. lift-*.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \left(\left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \left(\frac{1}{60} \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right) + \frac{1}{3}\right) + 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              3. lift-*.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \left(\color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)} \cdot \left(\frac{1}{60} \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right) + \frac{1}{3}\right) + 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              4. lift-*.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \left(\left(\ell \cdot \left(\ell \cdot \ell\right)\right) \cdot \left(\frac{1}{60} \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) + \frac{1}{3}\right) + 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              5. lift-*.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \left(\left(\ell \cdot \left(\ell \cdot \ell\right)\right) \cdot \left(\frac{1}{60} \cdot \color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)} + \frac{1}{3}\right) + 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              6. lift-fma.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \left(\left(\ell \cdot \left(\ell \cdot \ell\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{60}, \ell \cdot \left(\ell \cdot \ell\right), \frac{1}{3}\right)} + 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              7. lift-fma.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \color{blue}{\mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \ell \cdot \left(\ell \cdot \ell\right), \frac{1}{3}\right), 2\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              8. lift-*.f64N/A

                \[\leadsto \color{blue}{\left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \ell \cdot \left(\ell \cdot \ell\right), \frac{1}{3}\right), 2\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
              9. lift-/.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \ell \cdot \left(\ell \cdot \ell\right), \frac{1}{3}\right), 2\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
              10. lift-cos.f64N/A

                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \ell \cdot \left(\ell \cdot \ell\right), \frac{1}{3}\right), 2\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
            10. Applied egg-rr97.4%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\ell \cdot \ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), \left(J \cdot \ell\right) \cdot \cos \left(K \cdot 0.5\right), U\right)} \]

            if 0.96999999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

            1. Initial program 85.9%

              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. Applied egg-rr100.0%

                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
              2. Taylor expanded in K around 0

                \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
              3. Step-by-step derivation
                1. Simplified99.5%

                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                2. Step-by-step derivation
                  1. lift-sinh.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot 1, J, U\right) \]
                  2. *-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot 1, J, U\right) \]
                  3. associate-*l*N/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot \left(2 \cdot 1\right)}, J, U\right) \]
                  4. metadata-evalN/A

                    \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot \color{blue}{2}, J, U\right) \]
                  5. lower-*.f6499.5

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                3. Applied egg-rr99.5%

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
              4. Recombined 2 regimes into one program.
              5. Final simplification98.5%

                \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\ell \cdot \ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), \cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot J\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \]
              6. Add Preprocessing

              Alternative 4: 96.5% accurate, 1.2× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.97:\\ \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \end{array} \]
              (FPCore (J l K U)
               :precision binary64
               (let* ((t_0 (cos (/ K 2.0))))
                 (if (<= t_0 0.97)
                   (+
                    U
                    (*
                     t_0
                     (*
                      J
                      (*
                       l
                       (fma
                        (* l l)
                        (fma l (* l 0.016666666666666666) 0.3333333333333333)
                        2.0)))))
                   (fma (* 2.0 (sinh l)) J U))))
              double code(double J, double l, double K, double U) {
              	double t_0 = cos((K / 2.0));
              	double tmp;
              	if (t_0 <= 0.97) {
              		tmp = U + (t_0 * (J * (l * fma((l * l), fma(l, (l * 0.016666666666666666), 0.3333333333333333), 2.0))));
              	} else {
              		tmp = fma((2.0 * sinh(l)), J, U);
              	}
              	return tmp;
              }
              
              function code(J, l, K, U)
              	t_0 = cos(Float64(K / 2.0))
              	tmp = 0.0
              	if (t_0 <= 0.97)
              		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0)))));
              	else
              		tmp = fma(Float64(2.0 * sinh(l)), J, U);
              	end
              	return tmp
              end
              
              code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.97], N[(U + N[(t$95$0 * N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \cos \left(\frac{K}{2}\right)\\
              \mathbf{if}\;t\_0 \leq 0.97:\\
              \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right)\right)\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.96999999999999997

                1. Initial program 86.8%

                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                2. Add Preprocessing
                3. Taylor expanded in l around 0

                  \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                4. Step-by-step derivation
                  1. lower-*.f64N/A

                    \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  2. +-commutativeN/A

                    \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right) + 2\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  3. lower-fma.f64N/A

                    \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left({\ell}^{2}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  4. unpow2N/A

                    \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  5. lower-*.f64N/A

                    \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  6. +-commutativeN/A

                    \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\frac{1}{60} \cdot {\ell}^{2} + \frac{1}{3}}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  7. *-commutativeN/A

                    \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{{\ell}^{2} \cdot \frac{1}{60}} + \frac{1}{3}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  8. unpow2N/A

                    \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60} + \frac{1}{3}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  9. associate-*l*N/A

                    \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{60}\right)} + \frac{1}{3}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  10. lower-fma.f64N/A

                    \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \frac{1}{60}, \frac{1}{3}\right)}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  11. lower-*.f6496.7

                    \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot 0.016666666666666666}, 0.3333333333333333\right), 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                5. Simplified96.7%

                  \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]

                if 0.96999999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                1. Initial program 85.9%

                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. Applied egg-rr100.0%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                  2. Taylor expanded in K around 0

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                  3. Step-by-step derivation
                    1. Simplified99.5%

                      \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                    2. Step-by-step derivation
                      1. lift-sinh.f64N/A

                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot 1, J, U\right) \]
                      2. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot 1, J, U\right) \]
                      3. associate-*l*N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot \left(2 \cdot 1\right)}, J, U\right) \]
                      4. metadata-evalN/A

                        \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot \color{blue}{2}, J, U\right) \]
                      5. lower-*.f6499.5

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                    3. Applied egg-rr99.5%

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                  4. Recombined 2 regimes into one program.
                  5. Final simplification98.2%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \]
                  6. Add Preprocessing

                  Alternative 5: 94.1% accurate, 1.3× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \mathsf{fma}\left(\ell, \left(\ell \cdot \ell\right) \cdot 0.16666666666666666, \ell\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \end{array} \]
                  (FPCore (J l K U)
                   :precision binary64
                   (if (<= (cos (/ K 2.0)) 0.97)
                     (fma
                      (* (cos (* K 0.5)) (* 2.0 (fma l (* (* l l) 0.16666666666666666) l)))
                      J
                      U)
                     (fma (* 2.0 (sinh l)) J U)))
                  double code(double J, double l, double K, double U) {
                  	double tmp;
                  	if (cos((K / 2.0)) <= 0.97) {
                  		tmp = fma((cos((K * 0.5)) * (2.0 * fma(l, ((l * l) * 0.16666666666666666), l))), J, U);
                  	} else {
                  		tmp = fma((2.0 * sinh(l)), J, U);
                  	}
                  	return tmp;
                  }
                  
                  function code(J, l, K, U)
                  	tmp = 0.0
                  	if (cos(Float64(K / 2.0)) <= 0.97)
                  		tmp = fma(Float64(cos(Float64(K * 0.5)) * Float64(2.0 * fma(l, Float64(Float64(l * l) * 0.16666666666666666), l))), J, U);
                  	else
                  		tmp = fma(Float64(2.0 * sinh(l)), J, U);
                  	end
                  	return tmp
                  end
                  
                  code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.97], N[(N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(2.0 * N[(l * N[(N[(l * l), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\
                  \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \mathsf{fma}\left(\ell, \left(\ell \cdot \ell\right) \cdot 0.16666666666666666, \ell\right)\right), J, U\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.96999999999999997

                    1. Initial program 86.8%

                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    2. Add Preprocessing
                    3. Step-by-step derivation
                      1. Applied egg-rr99.9%

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                      2. Taylor expanded in l around 0

                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\left(\ell \cdot \left(1 + \frac{1}{6} \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                      3. Step-by-step derivation
                        1. +-commutativeN/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{6} \cdot {\ell}^{2} + 1\right)}\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                        2. distribute-lft-inN/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{6} \cdot {\ell}^{2}\right) + \ell \cdot 1\right)}\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                        3. *-rgt-identityN/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \left(\ell \cdot \left(\frac{1}{6} \cdot {\ell}^{2}\right) + \color{blue}{\ell}\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                        4. lower-fma.f64N/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\mathsf{fma}\left(\ell, \frac{1}{6} \cdot {\ell}^{2}, \ell\right)}\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                        5. *-commutativeN/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \mathsf{fma}\left(\ell, \color{blue}{{\ell}^{2} \cdot \frac{1}{6}}, \ell\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                        6. lower-*.f64N/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \mathsf{fma}\left(\ell, \color{blue}{{\ell}^{2} \cdot \frac{1}{6}}, \ell\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                        7. unpow2N/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \mathsf{fma}\left(\ell, \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{6}, \ell\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                        8. lower-*.f6491.9

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \mathsf{fma}\left(\ell, \color{blue}{\left(\ell \cdot \ell\right)} \cdot 0.16666666666666666, \ell\right)\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right) \]
                      4. Simplified91.9%

                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\mathsf{fma}\left(\ell, \left(\ell \cdot \ell\right) \cdot 0.16666666666666666, \ell\right)}\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right) \]

                      if 0.96999999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                      1. Initial program 85.9%

                        \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                      2. Add Preprocessing
                      3. Step-by-step derivation
                        1. Applied egg-rr100.0%

                          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                        2. Taylor expanded in K around 0

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                        3. Step-by-step derivation
                          1. Simplified99.5%

                            \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                          2. Step-by-step derivation
                            1. lift-sinh.f64N/A

                              \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot 1, J, U\right) \]
                            2. *-commutativeN/A

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot 1, J, U\right) \]
                            3. associate-*l*N/A

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot \left(2 \cdot 1\right)}, J, U\right) \]
                            4. metadata-evalN/A

                              \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot \color{blue}{2}, J, U\right) \]
                            5. lower-*.f6499.5

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                          3. Applied egg-rr99.5%

                            \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                        4. Recombined 2 regimes into one program.
                        5. Final simplification95.9%

                          \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \mathsf{fma}\left(\ell, \left(\ell \cdot \ell\right) \cdot 0.16666666666666666, \ell\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \]
                        6. Add Preprocessing

                        Alternative 6: 94.1% accurate, 1.3× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \end{array} \]
                        (FPCore (J l K U)
                         :precision binary64
                         (if (<= (cos (/ K 2.0)) 0.97)
                           (fma (* (cos (* K 0.5)) (* l (fma 0.3333333333333333 (* l l) 2.0))) J U)
                           (fma (* 2.0 (sinh l)) J U)))
                        double code(double J, double l, double K, double U) {
                        	double tmp;
                        	if (cos((K / 2.0)) <= 0.97) {
                        		tmp = fma((cos((K * 0.5)) * (l * fma(0.3333333333333333, (l * l), 2.0))), J, U);
                        	} else {
                        		tmp = fma((2.0 * sinh(l)), J, U);
                        	}
                        	return tmp;
                        }
                        
                        function code(J, l, K, U)
                        	tmp = 0.0
                        	if (cos(Float64(K / 2.0)) <= 0.97)
                        		tmp = fma(Float64(cos(Float64(K * 0.5)) * Float64(l * fma(0.3333333333333333, Float64(l * l), 2.0))), J, U);
                        	else
                        		tmp = fma(Float64(2.0 * sinh(l)), J, U);
                        	end
                        	return tmp
                        end
                        
                        code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.97], N[(N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(l * N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\
                        \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right)\right), J, U\right)\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.96999999999999997

                          1. Initial program 86.8%

                            \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                          2. Add Preprocessing
                          3. Step-by-step derivation
                            1. Applied egg-rr99.9%

                              \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                            2. Taylor expanded in l around 0

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                            3. Step-by-step derivation
                              1. lower-*.f64N/A

                                \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                              2. +-commutativeN/A

                                \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)}\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                              3. lower-fma.f64N/A

                                \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{3}, {\ell}^{2}, 2\right)}\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                              4. unpow2N/A

                                \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(\frac{1}{3}, \color{blue}{\ell \cdot \ell}, 2\right)\right) \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                              5. lower-*.f6491.9

                                \[\leadsto \mathsf{fma}\left(\left(\ell \cdot \mathsf{fma}\left(0.3333333333333333, \color{blue}{\ell \cdot \ell}, 2\right)\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right) \]
                            4. Simplified91.9%

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right)\right)} \cdot \cos \left(K \cdot 0.5\right), J, U\right) \]

                            if 0.96999999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                            1. Initial program 85.9%

                              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                            2. Add Preprocessing
                            3. Step-by-step derivation
                              1. Applied egg-rr100.0%

                                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                              2. Taylor expanded in K around 0

                                \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                              3. Step-by-step derivation
                                1. Simplified99.5%

                                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                2. Step-by-step derivation
                                  1. lift-sinh.f64N/A

                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot 1, J, U\right) \]
                                  2. *-commutativeN/A

                                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot 1, J, U\right) \]
                                  3. associate-*l*N/A

                                    \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot \left(2 \cdot 1\right)}, J, U\right) \]
                                  4. metadata-evalN/A

                                    \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot \color{blue}{2}, J, U\right) \]
                                  5. lower-*.f6499.5

                                    \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                                3. Applied egg-rr99.5%

                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                              4. Recombined 2 regimes into one program.
                              5. Final simplification95.9%

                                \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \]
                              6. Add Preprocessing

                              Alternative 7: 92.4% accurate, 1.3× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;\mathsf{fma}\left(\ell, \cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \end{array} \]
                              (FPCore (J l K U)
                               :precision binary64
                               (if (<= (cos (/ K 2.0)) 0.97)
                                 (fma l (* (cos (* K 0.5)) (* J (fma l (* l 0.3333333333333333) 2.0))) U)
                                 (fma (* 2.0 (sinh l)) J U)))
                              double code(double J, double l, double K, double U) {
                              	double tmp;
                              	if (cos((K / 2.0)) <= 0.97) {
                              		tmp = fma(l, (cos((K * 0.5)) * (J * fma(l, (l * 0.3333333333333333), 2.0))), U);
                              	} else {
                              		tmp = fma((2.0 * sinh(l)), J, U);
                              	}
                              	return tmp;
                              }
                              
                              function code(J, l, K, U)
                              	tmp = 0.0
                              	if (cos(Float64(K / 2.0)) <= 0.97)
                              		tmp = fma(l, Float64(cos(Float64(K * 0.5)) * Float64(J * fma(l, Float64(l * 0.3333333333333333), 2.0))), U);
                              	else
                              		tmp = fma(Float64(2.0 * sinh(l)), J, U);
                              	end
                              	return tmp
                              end
                              
                              code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.97], N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\
                              \;\;\;\;\mathsf{fma}\left(\ell, \cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right), U\right)\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.96999999999999997

                                1. Initial program 86.8%

                                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                2. Add Preprocessing
                                3. Taylor expanded in l around 0

                                  \[\leadsto \color{blue}{U + \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                4. Step-by-step derivation
                                  1. +-commutativeN/A

                                    \[\leadsto \color{blue}{\ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                  2. associate-*r*N/A

                                    \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\left(J \cdot {\ell}^{2}\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                  3. associate-*r*N/A

                                    \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                  4. associate-*r*N/A

                                    \[\leadsto \ell \cdot \left(\color{blue}{\left(\left(\frac{1}{3} \cdot J\right) \cdot {\ell}^{2}\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                  5. *-commutativeN/A

                                    \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} \cdot J\right)\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                  6. associate-*r*N/A

                                    \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\left(\frac{1}{3} \cdot J\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                  7. associate-*r*N/A

                                    \[\leadsto \ell \cdot \left({\ell}^{2} \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                  8. lower-fma.f64N/A

                                    \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, {\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), U\right)} \]
                                5. Simplified90.4%

                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right), U\right)} \]

                                if 0.96999999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                1. Initial program 85.9%

                                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                2. Add Preprocessing
                                3. Step-by-step derivation
                                  1. Applied egg-rr100.0%

                                    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                                  2. Taylor expanded in K around 0

                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                  3. Step-by-step derivation
                                    1. Simplified99.5%

                                      \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                    2. Step-by-step derivation
                                      1. lift-sinh.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot 1, J, U\right) \]
                                      2. *-commutativeN/A

                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot 1, J, U\right) \]
                                      3. associate-*l*N/A

                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot \left(2 \cdot 1\right)}, J, U\right) \]
                                      4. metadata-evalN/A

                                        \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot \color{blue}{2}, J, U\right) \]
                                      5. lower-*.f6499.5

                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                                    3. Applied egg-rr99.5%

                                      \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                                  4. Recombined 2 regimes into one program.
                                  5. Final simplification95.2%

                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.97:\\ \;\;\;\;\mathsf{fma}\left(\ell, \cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \]
                                  6. Add Preprocessing

                                  Alternative 8: 90.0% accurate, 1.3× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \cos \left(K \cdot 0.5\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \end{array} \]
                                  (FPCore (J l K U)
                                   :precision binary64
                                   (if (<= (cos (/ K 2.0)) -0.01)
                                     (fma l (* (cos (* K 0.5)) (* 0.3333333333333333 (* J (* l l)))) U)
                                     (fma (* 2.0 (sinh l)) J U)))
                                  double code(double J, double l, double K, double U) {
                                  	double tmp;
                                  	if (cos((K / 2.0)) <= -0.01) {
                                  		tmp = fma(l, (cos((K * 0.5)) * (0.3333333333333333 * (J * (l * l)))), U);
                                  	} else {
                                  		tmp = fma((2.0 * sinh(l)), J, U);
                                  	}
                                  	return tmp;
                                  }
                                  
                                  function code(J, l, K, U)
                                  	tmp = 0.0
                                  	if (cos(Float64(K / 2.0)) <= -0.01)
                                  		tmp = fma(l, Float64(cos(Float64(K * 0.5)) * Float64(0.3333333333333333 * Float64(J * Float64(l * l)))), U);
                                  	else
                                  		tmp = fma(Float64(2.0 * sinh(l)), J, U);
                                  	end
                                  	return tmp
                                  end
                                  
                                  code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(0.3333333333333333 * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
                                  \;\;\;\;\mathsf{fma}\left(\ell, \cos \left(K \cdot 0.5\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right)\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002

                                    1. Initial program 95.0%

                                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in l around 0

                                      \[\leadsto \color{blue}{U + \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                    4. Step-by-step derivation
                                      1. +-commutativeN/A

                                        \[\leadsto \color{blue}{\ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                      2. associate-*r*N/A

                                        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\left(J \cdot {\ell}^{2}\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                      3. associate-*r*N/A

                                        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                      4. associate-*r*N/A

                                        \[\leadsto \ell \cdot \left(\color{blue}{\left(\left(\frac{1}{3} \cdot J\right) \cdot {\ell}^{2}\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                      5. *-commutativeN/A

                                        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} \cdot J\right)\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                      6. associate-*r*N/A

                                        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\left(\frac{1}{3} \cdot J\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                      7. associate-*r*N/A

                                        \[\leadsto \ell \cdot \left({\ell}^{2} \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                      8. lower-fma.f64N/A

                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, {\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), U\right)} \]
                                    5. Simplified89.4%

                                      \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right), U\right)} \]
                                    6. Taylor expanded in l around inf

                                      \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right)}, U\right) \]
                                    7. Step-by-step derivation
                                      1. lower-*.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right)}, U\right) \]
                                      2. lower-*.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(J \cdot {\ell}^{2}\right)}\right), U\right) \]
                                      3. unpow2N/A

                                        \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right), U\right) \]
                                      4. lower-*.f6483.5

                                        \[\leadsto \mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right), U\right) \]
                                    8. Simplified83.5%

                                      \[\leadsto \mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)}, U\right) \]

                                    if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                    1. Initial program 83.5%

                                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                    2. Add Preprocessing
                                    3. Step-by-step derivation
                                      1. Applied egg-rr100.0%

                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                                      2. Taylor expanded in K around 0

                                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                      3. Step-by-step derivation
                                        1. Simplified93.5%

                                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                        2. Step-by-step derivation
                                          1. lift-sinh.f64N/A

                                            \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot 1, J, U\right) \]
                                          2. *-commutativeN/A

                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot 1, J, U\right) \]
                                          3. associate-*l*N/A

                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot \left(2 \cdot 1\right)}, J, U\right) \]
                                          4. metadata-evalN/A

                                            \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot \color{blue}{2}, J, U\right) \]
                                          5. lower-*.f6493.5

                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                                        3. Applied egg-rr93.5%

                                          \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                                      4. Recombined 2 regimes into one program.
                                      5. Final simplification91.1%

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \cos \left(K \cdot 0.5\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \]
                                      6. Add Preprocessing

                                      Alternative 9: 88.3% accurate, 1.4× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \end{array} \]
                                      (FPCore (J l K U)
                                       :precision binary64
                                       (if (<= (cos (/ K 2.0)) -0.01)
                                         (fma l (* (* 0.3333333333333333 (* J (* l l))) (fma K (* K -0.125) 1.0)) U)
                                         (fma (* 2.0 (sinh l)) J U)))
                                      double code(double J, double l, double K, double U) {
                                      	double tmp;
                                      	if (cos((K / 2.0)) <= -0.01) {
                                      		tmp = fma(l, ((0.3333333333333333 * (J * (l * l))) * fma(K, (K * -0.125), 1.0)), U);
                                      	} else {
                                      		tmp = fma((2.0 * sinh(l)), J, U);
                                      	}
                                      	return tmp;
                                      }
                                      
                                      function code(J, l, K, U)
                                      	tmp = 0.0
                                      	if (cos(Float64(K / 2.0)) <= -0.01)
                                      		tmp = fma(l, Float64(Float64(0.3333333333333333 * Float64(J * Float64(l * l))) * fma(K, Float64(K * -0.125), 1.0)), U);
                                      	else
                                      		tmp = fma(Float64(2.0 * sinh(l)), J, U);
                                      	end
                                      	return tmp
                                      end
                                      
                                      code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(l * N[(N[(0.3333333333333333 * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
                                      \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002

                                        1. Initial program 95.0%

                                          \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in l around 0

                                          \[\leadsto \color{blue}{U + \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                        4. Step-by-step derivation
                                          1. +-commutativeN/A

                                            \[\leadsto \color{blue}{\ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                          2. associate-*r*N/A

                                            \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\left(J \cdot {\ell}^{2}\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                          3. associate-*r*N/A

                                            \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                          4. associate-*r*N/A

                                            \[\leadsto \ell \cdot \left(\color{blue}{\left(\left(\frac{1}{3} \cdot J\right) \cdot {\ell}^{2}\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                          5. *-commutativeN/A

                                            \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} \cdot J\right)\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                          6. associate-*r*N/A

                                            \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\left(\frac{1}{3} \cdot J\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                          7. associate-*r*N/A

                                            \[\leadsto \ell \cdot \left({\ell}^{2} \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                          8. lower-fma.f64N/A

                                            \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, {\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), U\right)} \]
                                        5. Simplified89.4%

                                          \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right), U\right)} \]
                                        6. Taylor expanded in l around inf

                                          \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right)}, U\right) \]
                                        7. Step-by-step derivation
                                          1. lower-*.f64N/A

                                            \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right)}, U\right) \]
                                          2. lower-*.f64N/A

                                            \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(J \cdot {\ell}^{2}\right)}\right), U\right) \]
                                          3. unpow2N/A

                                            \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right), U\right) \]
                                          4. lower-*.f6483.5

                                            \[\leadsto \mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right), U\right) \]
                                        8. Simplified83.5%

                                          \[\leadsto \mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)}, U\right) \]
                                        9. Taylor expanded in K around 0

                                          \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                        10. Step-by-step derivation
                                          1. +-commutativeN/A

                                            \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\left(\frac{-1}{8} \cdot {K}^{2} + 1\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                          2. *-commutativeN/A

                                            \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{{K}^{2} \cdot \frac{-1}{8}} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                          3. unpow2N/A

                                            \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{\left(K \cdot K\right)} \cdot \frac{-1}{8} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                          4. associate-*l*N/A

                                            \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                          5. lower-fma.f64N/A

                                            \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(K, K \cdot \frac{-1}{8}, 1\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                          6. lower-*.f6476.6

                                            \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(K, \color{blue}{K \cdot -0.125}, 1\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                        11. Simplified76.6%

                                          \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(K, K \cdot -0.125, 1\right)} \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]

                                        if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                        1. Initial program 83.5%

                                          \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                        2. Add Preprocessing
                                        3. Step-by-step derivation
                                          1. Applied egg-rr100.0%

                                            \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                                          2. Taylor expanded in K around 0

                                            \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                          3. Step-by-step derivation
                                            1. Simplified93.5%

                                              \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                            2. Step-by-step derivation
                                              1. lift-sinh.f64N/A

                                                \[\leadsto \mathsf{fma}\left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot 1, J, U\right) \]
                                              2. *-commutativeN/A

                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot 1, J, U\right) \]
                                              3. associate-*l*N/A

                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot \left(2 \cdot 1\right)}, J, U\right) \]
                                              4. metadata-evalN/A

                                                \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot \color{blue}{2}, J, U\right) \]
                                              5. lower-*.f6493.5

                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                                            3. Applied egg-rr93.5%

                                              \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
                                          4. Recombined 2 regimes into one program.
                                          5. Final simplification89.4%

                                            \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \end{array} \]
                                          6. Add Preprocessing

                                          Alternative 10: 86.9% accurate, 1.6× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \ell \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\\ t_1 := t\_0 \cdot t\_0\\ \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(t\_1, \mathsf{fma}\left(t\_1, 0.016666666666666666, 0.3333333333333333\right), 2\right), U\right)\\ \end{array} \end{array} \]
                                          (FPCore (J l K U)
                                           :precision binary64
                                           (let* ((t_0 (* l (* l (* l l)))) (t_1 (* t_0 t_0)))
                                             (if (<= (cos (/ K 2.0)) -0.01)
                                               (fma
                                                l
                                                (* (* 0.3333333333333333 (* J (* l l))) (fma K (* K -0.125) 1.0))
                                                U)
                                               (fma
                                                J
                                                (* l (fma t_1 (fma t_1 0.016666666666666666 0.3333333333333333) 2.0))
                                                U))))
                                          double code(double J, double l, double K, double U) {
                                          	double t_0 = l * (l * (l * l));
                                          	double t_1 = t_0 * t_0;
                                          	double tmp;
                                          	if (cos((K / 2.0)) <= -0.01) {
                                          		tmp = fma(l, ((0.3333333333333333 * (J * (l * l))) * fma(K, (K * -0.125), 1.0)), U);
                                          	} else {
                                          		tmp = fma(J, (l * fma(t_1, fma(t_1, 0.016666666666666666, 0.3333333333333333), 2.0)), U);
                                          	}
                                          	return tmp;
                                          }
                                          
                                          function code(J, l, K, U)
                                          	t_0 = Float64(l * Float64(l * Float64(l * l)))
                                          	t_1 = Float64(t_0 * t_0)
                                          	tmp = 0.0
                                          	if (cos(Float64(K / 2.0)) <= -0.01)
                                          		tmp = fma(l, Float64(Float64(0.3333333333333333 * Float64(J * Float64(l * l))) * fma(K, Float64(K * -0.125), 1.0)), U);
                                          	else
                                          		tmp = fma(J, Float64(l * fma(t_1, fma(t_1, 0.016666666666666666, 0.3333333333333333), 2.0)), U);
                                          	end
                                          	return tmp
                                          end
                                          
                                          code[J_, l_, K_, U_] := Block[{t$95$0 = N[(l * N[(l * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(l * N[(N[(0.3333333333333333 * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(l * N[(t$95$1 * N[(t$95$1 * 0.016666666666666666 + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          t_0 := \ell \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\\
                                          t_1 := t\_0 \cdot t\_0\\
                                          \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
                                          \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(t\_1, \mathsf{fma}\left(t\_1, 0.016666666666666666, 0.3333333333333333\right), 2\right), U\right)\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002

                                            1. Initial program 95.0%

                                              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in l around 0

                                              \[\leadsto \color{blue}{U + \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                            4. Step-by-step derivation
                                              1. +-commutativeN/A

                                                \[\leadsto \color{blue}{\ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                              2. associate-*r*N/A

                                                \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\left(J \cdot {\ell}^{2}\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              3. associate-*r*N/A

                                                \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              4. associate-*r*N/A

                                                \[\leadsto \ell \cdot \left(\color{blue}{\left(\left(\frac{1}{3} \cdot J\right) \cdot {\ell}^{2}\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              5. *-commutativeN/A

                                                \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} \cdot J\right)\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              6. associate-*r*N/A

                                                \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\left(\frac{1}{3} \cdot J\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              7. associate-*r*N/A

                                                \[\leadsto \ell \cdot \left({\ell}^{2} \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              8. lower-fma.f64N/A

                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, {\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), U\right)} \]
                                            5. Simplified89.4%

                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right), U\right)} \]
                                            6. Taylor expanded in l around inf

                                              \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right)}, U\right) \]
                                            7. Step-by-step derivation
                                              1. lower-*.f64N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right)}, U\right) \]
                                              2. lower-*.f64N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(J \cdot {\ell}^{2}\right)}\right), U\right) \]
                                              3. unpow2N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right), U\right) \]
                                              4. lower-*.f6483.5

                                                \[\leadsto \mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right), U\right) \]
                                            8. Simplified83.5%

                                              \[\leadsto \mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)}, U\right) \]
                                            9. Taylor expanded in K around 0

                                              \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                            10. Step-by-step derivation
                                              1. +-commutativeN/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\left(\frac{-1}{8} \cdot {K}^{2} + 1\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                              2. *-commutativeN/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{{K}^{2} \cdot \frac{-1}{8}} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                              3. unpow2N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{\left(K \cdot K\right)} \cdot \frac{-1}{8} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                              4. associate-*l*N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                              5. lower-fma.f64N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(K, K \cdot \frac{-1}{8}, 1\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                              6. lower-*.f6476.6

                                                \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(K, \color{blue}{K \cdot -0.125}, 1\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                            11. Simplified76.6%

                                              \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(K, K \cdot -0.125, 1\right)} \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]

                                            if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                            1. Initial program 83.5%

                                              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in l around 0

                                              \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                            4. Step-by-step derivation
                                              1. lower-*.f64N/A

                                                \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              2. +-commutativeN/A

                                                \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right) + 2\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              3. lower-fma.f64N/A

                                                \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left({\ell}^{2}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              4. unpow2N/A

                                                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              5. lower-*.f64N/A

                                                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              6. +-commutativeN/A

                                                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\frac{1}{60} \cdot {\ell}^{2} + \frac{1}{3}}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              7. *-commutativeN/A

                                                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{{\ell}^{2} \cdot \frac{1}{60}} + \frac{1}{3}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              8. unpow2N/A

                                                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60} + \frac{1}{3}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              9. associate-*l*N/A

                                                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{60}\right)} + \frac{1}{3}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              10. lower-fma.f64N/A

                                                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \frac{1}{60}, \frac{1}{3}\right)}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              11. lower-*.f6493.3

                                                \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot 0.016666666666666666}, 0.3333333333333333\right), 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                            5. Simplified93.3%

                                              \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                            6. Taylor expanded in J around -inf

                                              \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{3} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}\right)\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                                            7. Step-by-step derivation
                                              1. associate-*r*N/A

                                                \[\leadsto \color{blue}{\left(\left(J \cdot \ell\right) \cdot \left(2 + {\ell}^{3} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              2. lower-*.f64N/A

                                                \[\leadsto \color{blue}{\left(\left(J \cdot \ell\right) \cdot \left(2 + {\ell}^{3} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              3. lower-*.f64N/A

                                                \[\leadsto \left(\color{blue}{\left(J \cdot \ell\right)} \cdot \left(2 + {\ell}^{3} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              4. +-commutativeN/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \color{blue}{\left({\ell}^{3} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}\right) + 2\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              5. lower-fma.f64N/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \color{blue}{\mathsf{fma}\left({\ell}^{3}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              6. cube-multN/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \left(\ell \cdot \ell\right)}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              7. unpow2N/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \color{blue}{{\ell}^{2}}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              8. lower-*.f64N/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot {\ell}^{2}}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              9. unpow2N/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              10. lower-*.f64N/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{3}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              11. +-commutativeN/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \color{blue}{\frac{1}{60} \cdot {\ell}^{3} + \frac{1}{3}}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              12. lower-fma.f64N/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \color{blue}{\mathsf{fma}\left(\frac{1}{60}, {\ell}^{3}, \frac{1}{3}\right)}, 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              13. cube-multN/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \color{blue}{\ell \cdot \left(\ell \cdot \ell\right)}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              14. unpow2N/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \ell \cdot \color{blue}{{\ell}^{2}}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              15. lower-*.f64N/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \color{blue}{\ell \cdot {\ell}^{2}}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              16. unpow2N/A

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\frac{1}{60}, \ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}, \frac{1}{3}\right), 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                              17. lower-*.f6494.0

                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(0.016666666666666666, \ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}, 0.3333333333333333\right), 2\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                            8. Simplified94.0%

                                              \[\leadsto \color{blue}{\left(\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(0.016666666666666666, \ell \cdot \left(\ell \cdot \ell\right), 0.3333333333333333\right), 2\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                                            9. Taylor expanded in K around 0

                                              \[\leadsto \color{blue}{U + J \cdot \left(\ell \cdot \left(2 + {\ell}^{8} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{8}\right)\right)\right)} \]
                                            10. Step-by-step derivation
                                              1. +-commutativeN/A

                                                \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{8} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{8}\right)\right)\right) + U} \]
                                              2. lower-fma.f64N/A

                                                \[\leadsto \color{blue}{\mathsf{fma}\left(J, \ell \cdot \left(2 + {\ell}^{8} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{8}\right)\right), U\right)} \]
                                            11. Simplified91.7%

                                              \[\leadsto \color{blue}{\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\left(\left(\ell \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell\right) \cdot \left(\left(\ell \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell\right), \mathsf{fma}\left(\left(\left(\ell \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell\right) \cdot \left(\left(\ell \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell\right), 0.016666666666666666, 0.3333333333333333\right), 2\right), U\right)} \]
                                          3. Recombined 2 regimes into one program.
                                          4. Final simplification88.0%

                                            \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\left(\ell \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \left(\ell \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right), \mathsf{fma}\left(\left(\ell \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \left(\ell \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right), 0.016666666666666666, 0.3333333333333333\right), 2\right), U\right)\\ \end{array} \]
                                          5. Add Preprocessing

                                          Alternative 11: 84.7% accurate, 2.0× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), 0.3333333333333333\right), 2\right), J, U\right)\\ \end{array} \end{array} \]
                                          (FPCore (J l K U)
                                           :precision binary64
                                           (if (<= (cos (/ K 2.0)) -0.01)
                                             (fma l (* (* 0.3333333333333333 (* J (* l l))) (fma K (* K -0.125) 1.0)) U)
                                             (fma
                                              (*
                                               l
                                               (fma
                                                (* l l)
                                                (fma
                                                 (* l l)
                                                 (fma 0.0003968253968253968 (* l l) 0.016666666666666666)
                                                 0.3333333333333333)
                                                2.0))
                                              J
                                              U)))
                                          double code(double J, double l, double K, double U) {
                                          	double tmp;
                                          	if (cos((K / 2.0)) <= -0.01) {
                                          		tmp = fma(l, ((0.3333333333333333 * (J * (l * l))) * fma(K, (K * -0.125), 1.0)), U);
                                          	} else {
                                          		tmp = fma((l * fma((l * l), fma((l * l), fma(0.0003968253968253968, (l * l), 0.016666666666666666), 0.3333333333333333), 2.0)), J, U);
                                          	}
                                          	return tmp;
                                          }
                                          
                                          function code(J, l, K, U)
                                          	tmp = 0.0
                                          	if (cos(Float64(K / 2.0)) <= -0.01)
                                          		tmp = fma(l, Float64(Float64(0.3333333333333333 * Float64(J * Float64(l * l))) * fma(K, Float64(K * -0.125), 1.0)), U);
                                          	else
                                          		tmp = fma(Float64(l * fma(Float64(l * l), fma(Float64(l * l), fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), 0.3333333333333333), 2.0)), J, U);
                                          	end
                                          	return tmp
                                          end
                                          
                                          code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(l * N[(N[(0.3333333333333333 * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(l * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * N[(0.0003968253968253968 * N[(l * l), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
                                          \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), 0.3333333333333333\right), 2\right), J, U\right)\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002

                                            1. Initial program 95.0%

                                              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in l around 0

                                              \[\leadsto \color{blue}{U + \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                            4. Step-by-step derivation
                                              1. +-commutativeN/A

                                                \[\leadsto \color{blue}{\ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                              2. associate-*r*N/A

                                                \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\left(J \cdot {\ell}^{2}\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              3. associate-*r*N/A

                                                \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              4. associate-*r*N/A

                                                \[\leadsto \ell \cdot \left(\color{blue}{\left(\left(\frac{1}{3} \cdot J\right) \cdot {\ell}^{2}\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              5. *-commutativeN/A

                                                \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} \cdot J\right)\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              6. associate-*r*N/A

                                                \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\left(\frac{1}{3} \cdot J\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              7. associate-*r*N/A

                                                \[\leadsto \ell \cdot \left({\ell}^{2} \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                              8. lower-fma.f64N/A

                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, {\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), U\right)} \]
                                            5. Simplified89.4%

                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right), U\right)} \]
                                            6. Taylor expanded in l around inf

                                              \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right)}, U\right) \]
                                            7. Step-by-step derivation
                                              1. lower-*.f64N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right)}, U\right) \]
                                              2. lower-*.f64N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(J \cdot {\ell}^{2}\right)}\right), U\right) \]
                                              3. unpow2N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right), U\right) \]
                                              4. lower-*.f6483.5

                                                \[\leadsto \mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right), U\right) \]
                                            8. Simplified83.5%

                                              \[\leadsto \mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)}, U\right) \]
                                            9. Taylor expanded in K around 0

                                              \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                            10. Step-by-step derivation
                                              1. +-commutativeN/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\left(\frac{-1}{8} \cdot {K}^{2} + 1\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                              2. *-commutativeN/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{{K}^{2} \cdot \frac{-1}{8}} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                              3. unpow2N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{\left(K \cdot K\right)} \cdot \frac{-1}{8} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                              4. associate-*l*N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                              5. lower-fma.f64N/A

                                                \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(K, K \cdot \frac{-1}{8}, 1\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                              6. lower-*.f6476.6

                                                \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(K, \color{blue}{K \cdot -0.125}, 1\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                            11. Simplified76.6%

                                              \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(K, K \cdot -0.125, 1\right)} \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]

                                            if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                            1. Initial program 83.5%

                                              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                            2. Add Preprocessing
                                            3. Step-by-step derivation
                                              1. Applied egg-rr100.0%

                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                                              2. Taylor expanded in K around 0

                                                \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                              3. Step-by-step derivation
                                                1. Simplified93.5%

                                                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                                2. Taylor expanded in l around 0

                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}, J, U\right) \]
                                                3. Step-by-step derivation
                                                  1. lower-*.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}, J, U\right) \]
                                                  2. +-commutativeN/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right) + 2\right)}, J, U\right) \]
                                                  3. lower-fma.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \color{blue}{\mathsf{fma}\left({\ell}^{2}, \frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right), 2\right)}, J, U\right) \]
                                                  4. unpow2N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right), 2\right), J, U\right) \]
                                                  5. lower-*.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right), 2\right), J, U\right) \]
                                                  6. +-commutativeN/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right) + \frac{1}{3}}, 2\right), J, U\right) \]
                                                  7. lower-fma.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\mathsf{fma}\left({\ell}^{2}, \frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}, \frac{1}{3}\right)}, 2\right), J, U\right) \]
                                                  8. unpow2N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}, \frac{1}{3}\right), 2\right), J, U\right) \]
                                                  9. lower-*.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}, \frac{1}{3}\right), 2\right), J, U\right) \]
                                                  10. +-commutativeN/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\frac{1}{2520} \cdot {\ell}^{2} + \frac{1}{60}}, \frac{1}{3}\right), 2\right), J, U\right) \]
                                                  11. lower-fma.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\mathsf{fma}\left(\frac{1}{2520}, {\ell}^{2}, \frac{1}{60}\right)}, \frac{1}{3}\right), 2\right), J, U\right) \]
                                                  12. unpow2N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\frac{1}{2520}, \color{blue}{\ell \cdot \ell}, \frac{1}{60}\right), \frac{1}{3}\right), 2\right), J, U\right) \]
                                                  13. lower-*.f6489.0

                                                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(0.0003968253968253968, \color{blue}{\ell \cdot \ell}, 0.016666666666666666\right), 0.3333333333333333\right), 2\right), J, U\right) \]
                                                4. Simplified89.0%

                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)}, J, U\right) \]
                                              4. Recombined 2 regimes into one program.
                                              5. Final simplification86.0%

                                                \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), 0.3333333333333333\right), 2\right), J, U\right)\\ \end{array} \]
                                              6. Add Preprocessing

                                              Alternative 12: 83.3% accurate, 2.1× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), J, U\right)\\ \end{array} \end{array} \]
                                              (FPCore (J l K U)
                                               :precision binary64
                                               (if (<= (cos (/ K 2.0)) -0.01)
                                                 (fma l (* (* 0.3333333333333333 (* J (* l l))) (fma K (* K -0.125) 1.0)) U)
                                                 (fma
                                                  (*
                                                   l
                                                   (fma (* l l) (fma l (* l 0.016666666666666666) 0.3333333333333333) 2.0))
                                                  J
                                                  U)))
                                              double code(double J, double l, double K, double U) {
                                              	double tmp;
                                              	if (cos((K / 2.0)) <= -0.01) {
                                              		tmp = fma(l, ((0.3333333333333333 * (J * (l * l))) * fma(K, (K * -0.125), 1.0)), U);
                                              	} else {
                                              		tmp = fma((l * fma((l * l), fma(l, (l * 0.016666666666666666), 0.3333333333333333), 2.0)), J, U);
                                              	}
                                              	return tmp;
                                              }
                                              
                                              function code(J, l, K, U)
                                              	tmp = 0.0
                                              	if (cos(Float64(K / 2.0)) <= -0.01)
                                              		tmp = fma(l, Float64(Float64(0.3333333333333333 * Float64(J * Float64(l * l))) * fma(K, Float64(K * -0.125), 1.0)), U);
                                              	else
                                              		tmp = fma(Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0)), J, U);
                                              	end
                                              	return tmp
                                              end
                                              
                                              code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(l * N[(N[(0.3333333333333333 * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
                                              \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), J, U\right)\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 2 regimes
                                              2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002

                                                1. Initial program 95.0%

                                                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in l around 0

                                                  \[\leadsto \color{blue}{U + \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                4. Step-by-step derivation
                                                  1. +-commutativeN/A

                                                    \[\leadsto \color{blue}{\ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                                  2. associate-*r*N/A

                                                    \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\left(J \cdot {\ell}^{2}\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                                  3. associate-*r*N/A

                                                    \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                                  4. associate-*r*N/A

                                                    \[\leadsto \ell \cdot \left(\color{blue}{\left(\left(\frac{1}{3} \cdot J\right) \cdot {\ell}^{2}\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                                  5. *-commutativeN/A

                                                    \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} \cdot J\right)\right)} \cdot \cos \left(\frac{1}{2} \cdot K\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                                  6. associate-*r*N/A

                                                    \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\left(\frac{1}{3} \cdot J\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                                  7. associate-*r*N/A

                                                    \[\leadsto \ell \cdot \left({\ell}^{2} \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                                                  8. lower-fma.f64N/A

                                                    \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, {\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), U\right)} \]
                                                5. Simplified89.4%

                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right), U\right)} \]
                                                6. Taylor expanded in l around inf

                                                  \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right)}, U\right) \]
                                                7. Step-by-step derivation
                                                  1. lower-*.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right)\right)}, U\right) \]
                                                  2. lower-*.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(J \cdot {\ell}^{2}\right)}\right), U\right) \]
                                                  3. unpow2N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell, \cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right), U\right) \]
                                                  4. lower-*.f6483.5

                                                    \[\leadsto \mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right), U\right) \]
                                                8. Simplified83.5%

                                                  \[\leadsto \mathsf{fma}\left(\ell, \cos \left(0.5 \cdot K\right) \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)}, U\right) \]
                                                9. Taylor expanded in K around 0

                                                  \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                                10. Step-by-step derivation
                                                  1. +-commutativeN/A

                                                    \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\left(\frac{-1}{8} \cdot {K}^{2} + 1\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                                  2. *-commutativeN/A

                                                    \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{{K}^{2} \cdot \frac{-1}{8}} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                                  3. unpow2N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{\left(K \cdot K\right)} \cdot \frac{-1}{8} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                                  4. associate-*l*N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell, \left(\color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)} + 1\right) \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                                  5. lower-fma.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(K, K \cdot \frac{-1}{8}, 1\right)} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                                  6. lower-*.f6476.6

                                                    \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(K, \color{blue}{K \cdot -0.125}, 1\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]
                                                11. Simplified76.6%

                                                  \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(K, K \cdot -0.125, 1\right)} \cdot \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right), U\right) \]

                                                if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                1. Initial program 83.5%

                                                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                2. Add Preprocessing
                                                3. Step-by-step derivation
                                                  1. Applied egg-rr100.0%

                                                    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                                                  2. Taylor expanded in K around 0

                                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                                  3. Step-by-step derivation
                                                    1. Simplified93.5%

                                                      \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                                    2. Taylor expanded in l around 0

                                                      \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}, J, U\right) \]
                                                    3. Step-by-step derivation
                                                      1. lower-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}, J, U\right) \]
                                                      2. +-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right) + 2\right)}, J, U\right) \]
                                                      3. lower-fma.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \color{blue}{\mathsf{fma}\left({\ell}^{2}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)}, J, U\right) \]
                                                      4. unpow2N/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right), J, U\right) \]
                                                      5. lower-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right), J, U\right) \]
                                                      6. +-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\frac{1}{60} \cdot {\ell}^{2} + \frac{1}{3}}, 2\right), J, U\right) \]
                                                      7. *-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{{\ell}^{2} \cdot \frac{1}{60}} + \frac{1}{3}, 2\right), J, U\right) \]
                                                      8. unpow2N/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60} + \frac{1}{3}, 2\right), J, U\right) \]
                                                      9. associate-*r*N/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{60}\right)} + \frac{1}{3}, 2\right), J, U\right) \]
                                                      10. *-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \ell \cdot \color{blue}{\left(\frac{1}{60} \cdot \ell\right)} + \frac{1}{3}, 2\right), J, U\right) \]
                                                      11. lower-fma.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\mathsf{fma}\left(\ell, \frac{1}{60} \cdot \ell, \frac{1}{3}\right)}, 2\right), J, U\right) \]
                                                      12. *-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \frac{1}{60}}, \frac{1}{3}\right), 2\right), J, U\right) \]
                                                      13. lower-*.f6486.9

                                                        \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot 0.016666666666666666}, 0.3333333333333333\right), 2\right), J, U\right) \]
                                                    4. Simplified86.9%

                                                      \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right)}, J, U\right) \]
                                                  4. Recombined 2 regimes into one program.
                                                  5. Final simplification84.4%

                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \left(0.3333333333333333 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), J, U\right)\\ \end{array} \]
                                                  6. Add Preprocessing

                                                  Alternative 13: 81.2% accurate, 2.2× speedup?

                                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), J, U\right)\\ \end{array} \end{array} \]
                                                  (FPCore (J l K U)
                                                   :precision binary64
                                                   (if (<= (cos (/ K 2.0)) -0.01)
                                                     (fma (* (fma K (* K -0.125) 1.0) (* 2.0 l)) J U)
                                                     (fma
                                                      (*
                                                       l
                                                       (fma (* l l) (fma l (* l 0.016666666666666666) 0.3333333333333333) 2.0))
                                                      J
                                                      U)))
                                                  double code(double J, double l, double K, double U) {
                                                  	double tmp;
                                                  	if (cos((K / 2.0)) <= -0.01) {
                                                  		tmp = fma((fma(K, (K * -0.125), 1.0) * (2.0 * l)), J, U);
                                                  	} else {
                                                  		tmp = fma((l * fma((l * l), fma(l, (l * 0.016666666666666666), 0.3333333333333333), 2.0)), J, U);
                                                  	}
                                                  	return tmp;
                                                  }
                                                  
                                                  function code(J, l, K, U)
                                                  	tmp = 0.0
                                                  	if (cos(Float64(K / 2.0)) <= -0.01)
                                                  		tmp = fma(Float64(fma(K, Float64(K * -0.125), 1.0) * Float64(2.0 * l)), J, U);
                                                  	else
                                                  		tmp = fma(Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0)), J, U);
                                                  	end
                                                  	return tmp
                                                  end
                                                  
                                                  code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(N[(N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
                                                  
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  \begin{array}{l}
                                                  \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
                                                  \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\
                                                  
                                                  \mathbf{else}:\\
                                                  \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), J, U\right)\\
                                                  
                                                  
                                                  \end{array}
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Split input into 2 regimes
                                                  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002

                                                    1. Initial program 95.0%

                                                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                    2. Add Preprocessing
                                                    3. Taylor expanded in l around 0

                                                      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                    4. Step-by-step derivation
                                                      1. +-commutativeN/A

                                                        \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                                      2. associate-*r*N/A

                                                        \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                                                      3. associate-*r*N/A

                                                        \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                      4. *-commutativeN/A

                                                        \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                                                      5. lower-fma.f64N/A

                                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                                                      6. lower-cos.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                      7. lower-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                      8. *-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                                                      9. associate-*l*N/A

                                                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                      10. lower-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                      11. *-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                      12. lower-*.f6461.0

                                                        \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                    5. Simplified61.0%

                                                      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                                                    6. Taylor expanded in K around 0

                                                      \[\leadsto \mathsf{fma}\left(\color{blue}{1 + \frac{-1}{8} \cdot {K}^{2}}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                    7. Step-by-step derivation
                                                      1. +-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{8} \cdot {K}^{2} + 1}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                      2. lower-fma.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{-1}{8}, {K}^{2}, 1\right)}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                      3. unpow2N/A

                                                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{8}, \color{blue}{K \cdot K}, 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                      4. lower-*.f6470.9

                                                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-0.125, \color{blue}{K \cdot K}, 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                    8. Simplified70.9%

                                                      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(-0.125, K \cdot K, 1\right)}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                    9. Step-by-step derivation
                                                      1. lift-*.f64N/A

                                                        \[\leadsto \left(\frac{-1}{8} \cdot \color{blue}{\left(K \cdot K\right)} + 1\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right) + U \]
                                                      2. lift-fma.f64N/A

                                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right)} \cdot \left(J \cdot \left(\ell \cdot 2\right)\right) + U \]
                                                      3. lift-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot 2\right)}\right) + U \]
                                                      4. lift-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \color{blue}{\left(J \cdot \left(\ell \cdot 2\right)\right)} + U \]
                                                      5. lift-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \color{blue}{\left(J \cdot \left(\ell \cdot 2\right)\right)} + U \]
                                                      6. *-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \color{blue}{\left(\left(\ell \cdot 2\right) \cdot J\right)} + U \]
                                                      7. associate-*r*N/A

                                                        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \left(\ell \cdot 2\right)\right) \cdot J} + U \]
                                                      8. lower-fma.f64N/A

                                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \left(\ell \cdot 2\right), J, U\right)} \]
                                                      9. lower-*.f6470.9

                                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(-0.125, K \cdot K, 1\right) \cdot \left(\ell \cdot 2\right)}, J, U\right) \]
                                                      10. lift-fma.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{-1}{8} \cdot \left(K \cdot K\right) + 1\right)} \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                      11. lift-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\left(\frac{-1}{8} \cdot \color{blue}{\left(K \cdot K\right)} + 1\right) \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                      12. associate-*r*N/A

                                                        \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(\frac{-1}{8} \cdot K\right) \cdot K} + 1\right) \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                      13. *-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\left(\color{blue}{K \cdot \left(\frac{-1}{8} \cdot K\right)} + 1\right) \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                      14. lower-fma.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(K, \frac{-1}{8} \cdot K, 1\right)} \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                      15. *-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, \color{blue}{K \cdot \frac{-1}{8}}, 1\right) \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                      16. lower-*.f6470.9

                                                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, \color{blue}{K \cdot -0.125}, 1\right) \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                    10. Applied egg-rr70.9%

                                                      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right) \cdot \left(\ell \cdot 2\right), J, U\right)} \]

                                                    if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                    1. Initial program 83.5%

                                                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                    2. Add Preprocessing
                                                    3. Step-by-step derivation
                                                      1. Applied egg-rr100.0%

                                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                                                      2. Taylor expanded in K around 0

                                                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                                      3. Step-by-step derivation
                                                        1. Simplified93.5%

                                                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                                        2. Taylor expanded in l around 0

                                                          \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}, J, U\right) \]
                                                        3. Step-by-step derivation
                                                          1. lower-*.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}, J, U\right) \]
                                                          2. +-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \color{blue}{\left({\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right) + 2\right)}, J, U\right) \]
                                                          3. lower-fma.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \color{blue}{\mathsf{fma}\left({\ell}^{2}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right)}, J, U\right) \]
                                                          4. unpow2N/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right), J, U\right) \]
                                                          5. lower-*.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}, 2\right), J, U\right) \]
                                                          6. +-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\frac{1}{60} \cdot {\ell}^{2} + \frac{1}{3}}, 2\right), J, U\right) \]
                                                          7. *-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{{\ell}^{2} \cdot \frac{1}{60}} + \frac{1}{3}, 2\right), J, U\right) \]
                                                          8. unpow2N/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60} + \frac{1}{3}, 2\right), J, U\right) \]
                                                          9. associate-*r*N/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{60}\right)} + \frac{1}{3}, 2\right), J, U\right) \]
                                                          10. *-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \ell \cdot \color{blue}{\left(\frac{1}{60} \cdot \ell\right)} + \frac{1}{3}, 2\right), J, U\right) \]
                                                          11. lower-fma.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\mathsf{fma}\left(\ell, \frac{1}{60} \cdot \ell, \frac{1}{3}\right)}, 2\right), J, U\right) \]
                                                          12. *-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \frac{1}{60}}, \frac{1}{3}\right), 2\right), J, U\right) \]
                                                          13. lower-*.f6486.9

                                                            \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot 0.016666666666666666}, 0.3333333333333333\right), 2\right), J, U\right) \]
                                                        4. Simplified86.9%

                                                          \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right)}, J, U\right) \]
                                                      4. Recombined 2 regimes into one program.
                                                      5. Final simplification83.0%

                                                        \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), J, U\right)\\ \end{array} \]
                                                      6. Add Preprocessing

                                                      Alternative 14: 77.6% accurate, 2.3× speedup?

                                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), J, U\right)\\ \end{array} \end{array} \]
                                                      (FPCore (J l K U)
                                                       :precision binary64
                                                       (if (<= (cos (/ K 2.0)) -0.01)
                                                         (fma (* (fma K (* K -0.125) 1.0) (* 2.0 l)) J U)
                                                         (fma (* l (fma l (* l 0.3333333333333333) 2.0)) J U)))
                                                      double code(double J, double l, double K, double U) {
                                                      	double tmp;
                                                      	if (cos((K / 2.0)) <= -0.01) {
                                                      		tmp = fma((fma(K, (K * -0.125), 1.0) * (2.0 * l)), J, U);
                                                      	} else {
                                                      		tmp = fma((l * fma(l, (l * 0.3333333333333333), 2.0)), J, U);
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      function code(J, l, K, U)
                                                      	tmp = 0.0
                                                      	if (cos(Float64(K / 2.0)) <= -0.01)
                                                      		tmp = fma(Float64(fma(K, Float64(K * -0.125), 1.0) * Float64(2.0 * l)), J, U);
                                                      	else
                                                      		tmp = fma(Float64(l * fma(l, Float64(l * 0.3333333333333333), 2.0)), J, U);
                                                      	end
                                                      	return tmp
                                                      end
                                                      
                                                      code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(N[(N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(l * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
                                                      
                                                      \begin{array}{l}
                                                      
                                                      \\
                                                      \begin{array}{l}
                                                      \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
                                                      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\
                                                      
                                                      \mathbf{else}:\\
                                                      \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), J, U\right)\\
                                                      
                                                      
                                                      \end{array}
                                                      \end{array}
                                                      
                                                      Derivation
                                                      1. Split input into 2 regimes
                                                      2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002

                                                        1. Initial program 95.0%

                                                          \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                        2. Add Preprocessing
                                                        3. Taylor expanded in l around 0

                                                          \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                        4. Step-by-step derivation
                                                          1. +-commutativeN/A

                                                            \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                                          2. associate-*r*N/A

                                                            \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                                                          3. associate-*r*N/A

                                                            \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                          4. *-commutativeN/A

                                                            \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                                                          5. lower-fma.f64N/A

                                                            \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                                                          6. lower-cos.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                          7. lower-*.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                          8. *-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                                                          9. associate-*l*N/A

                                                            \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                          10. lower-*.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                          11. *-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                          12. lower-*.f6461.0

                                                            \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                        5. Simplified61.0%

                                                          \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                                                        6. Taylor expanded in K around 0

                                                          \[\leadsto \mathsf{fma}\left(\color{blue}{1 + \frac{-1}{8} \cdot {K}^{2}}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                        7. Step-by-step derivation
                                                          1. +-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{8} \cdot {K}^{2} + 1}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                          2. lower-fma.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{-1}{8}, {K}^{2}, 1\right)}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                          3. unpow2N/A

                                                            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{8}, \color{blue}{K \cdot K}, 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                          4. lower-*.f6470.9

                                                            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-0.125, \color{blue}{K \cdot K}, 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                        8. Simplified70.9%

                                                          \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(-0.125, K \cdot K, 1\right)}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                        9. Step-by-step derivation
                                                          1. lift-*.f64N/A

                                                            \[\leadsto \left(\frac{-1}{8} \cdot \color{blue}{\left(K \cdot K\right)} + 1\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right) + U \]
                                                          2. lift-fma.f64N/A

                                                            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right)} \cdot \left(J \cdot \left(\ell \cdot 2\right)\right) + U \]
                                                          3. lift-*.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot 2\right)}\right) + U \]
                                                          4. lift-*.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \color{blue}{\left(J \cdot \left(\ell \cdot 2\right)\right)} + U \]
                                                          5. lift-*.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \color{blue}{\left(J \cdot \left(\ell \cdot 2\right)\right)} + U \]
                                                          6. *-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \color{blue}{\left(\left(\ell \cdot 2\right) \cdot J\right)} + U \]
                                                          7. associate-*r*N/A

                                                            \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \left(\ell \cdot 2\right)\right) \cdot J} + U \]
                                                          8. lower-fma.f64N/A

                                                            \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{8}, K \cdot K, 1\right) \cdot \left(\ell \cdot 2\right), J, U\right)} \]
                                                          9. lower-*.f6470.9

                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(-0.125, K \cdot K, 1\right) \cdot \left(\ell \cdot 2\right)}, J, U\right) \]
                                                          10. lift-fma.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{-1}{8} \cdot \left(K \cdot K\right) + 1\right)} \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                          11. lift-*.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\left(\frac{-1}{8} \cdot \color{blue}{\left(K \cdot K\right)} + 1\right) \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                          12. associate-*r*N/A

                                                            \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(\frac{-1}{8} \cdot K\right) \cdot K} + 1\right) \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                          13. *-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\left(\color{blue}{K \cdot \left(\frac{-1}{8} \cdot K\right)} + 1\right) \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                          14. lower-fma.f64N/A

                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(K, \frac{-1}{8} \cdot K, 1\right)} \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                          15. *-commutativeN/A

                                                            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, \color{blue}{K \cdot \frac{-1}{8}}, 1\right) \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                          16. lower-*.f6470.9

                                                            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, \color{blue}{K \cdot -0.125}, 1\right) \cdot \left(\ell \cdot 2\right), J, U\right) \]
                                                        10. Applied egg-rr70.9%

                                                          \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right) \cdot \left(\ell \cdot 2\right), J, U\right)} \]

                                                        if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                        1. Initial program 83.5%

                                                          \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                        2. Add Preprocessing
                                                        3. Step-by-step derivation
                                                          1. Applied egg-rr100.0%

                                                            \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                                                          2. Taylor expanded in K around 0

                                                            \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                                          3. Step-by-step derivation
                                                            1. Simplified93.5%

                                                              \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                                            2. Taylor expanded in l around 0

                                                              \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}, J, U\right) \]
                                                            3. Step-by-step derivation
                                                              1. lower-*.f64N/A

                                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}, J, U\right) \]
                                                              2. +-commutativeN/A

                                                                \[\leadsto \mathsf{fma}\left(\ell \cdot \color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)}, J, U\right) \]
                                                              3. *-commutativeN/A

                                                                \[\leadsto \mathsf{fma}\left(\ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \frac{1}{3}} + 2\right), J, U\right) \]
                                                              4. unpow2N/A

                                                                \[\leadsto \mathsf{fma}\left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{3} + 2\right), J, U\right) \]
                                                              5. associate-*r*N/A

                                                                \[\leadsto \mathsf{fma}\left(\ell \cdot \left(\color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{3}\right)} + 2\right), J, U\right) \]
                                                              6. *-commutativeN/A

                                                                \[\leadsto \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{3} \cdot \ell\right)} + 2\right), J, U\right) \]
                                                              7. lower-fma.f64N/A

                                                                \[\leadsto \mathsf{fma}\left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \frac{1}{3} \cdot \ell, 2\right)}, J, U\right) \]
                                                              8. *-commutativeN/A

                                                                \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \frac{1}{3}}, 2\right), J, U\right) \]
                                                              9. lower-*.f6483.3

                                                                \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot 0.3333333333333333}, 2\right), J, U\right) \]
                                                            4. Simplified83.3%

                                                              \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)}, J, U\right) \]
                                                          4. Recombined 2 regimes into one program.
                                                          5. Final simplification80.3%

                                                            \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), J, U\right)\\ \end{array} \]
                                                          6. Add Preprocessing

                                                          Alternative 15: 22.2% accurate, 2.6× speedup?

                                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.055:\\ \;\;\;\;U \cdot \left(U \cdot U\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\ell \cdot J\right)\\ \end{array} \end{array} \]
                                                          (FPCore (J l K U)
                                                           :precision binary64
                                                           (if (<= (cos (/ K 2.0)) 0.055) (* U (* U U)) (* 2.0 (* l J))))
                                                          double code(double J, double l, double K, double U) {
                                                          	double tmp;
                                                          	if (cos((K / 2.0)) <= 0.055) {
                                                          		tmp = U * (U * U);
                                                          	} else {
                                                          		tmp = 2.0 * (l * J);
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          real(8) function code(j, l, k, u)
                                                              real(8), intent (in) :: j
                                                              real(8), intent (in) :: l
                                                              real(8), intent (in) :: k
                                                              real(8), intent (in) :: u
                                                              real(8) :: tmp
                                                              if (cos((k / 2.0d0)) <= 0.055d0) then
                                                                  tmp = u * (u * u)
                                                              else
                                                                  tmp = 2.0d0 * (l * j)
                                                              end if
                                                              code = tmp
                                                          end function
                                                          
                                                          public static double code(double J, double l, double K, double U) {
                                                          	double tmp;
                                                          	if (Math.cos((K / 2.0)) <= 0.055) {
                                                          		tmp = U * (U * U);
                                                          	} else {
                                                          		tmp = 2.0 * (l * J);
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          def code(J, l, K, U):
                                                          	tmp = 0
                                                          	if math.cos((K / 2.0)) <= 0.055:
                                                          		tmp = U * (U * U)
                                                          	else:
                                                          		tmp = 2.0 * (l * J)
                                                          	return tmp
                                                          
                                                          function code(J, l, K, U)
                                                          	tmp = 0.0
                                                          	if (cos(Float64(K / 2.0)) <= 0.055)
                                                          		tmp = Float64(U * Float64(U * U));
                                                          	else
                                                          		tmp = Float64(2.0 * Float64(l * J));
                                                          	end
                                                          	return tmp
                                                          end
                                                          
                                                          function tmp_2 = code(J, l, K, U)
                                                          	tmp = 0.0;
                                                          	if (cos((K / 2.0)) <= 0.055)
                                                          		tmp = U * (U * U);
                                                          	else
                                                          		tmp = 2.0 * (l * J);
                                                          	end
                                                          	tmp_2 = tmp;
                                                          end
                                                          
                                                          code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.055], N[(U * N[(U * U), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]]
                                                          
                                                          \begin{array}{l}
                                                          
                                                          \\
                                                          \begin{array}{l}
                                                          \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.055:\\
                                                          \;\;\;\;U \cdot \left(U \cdot U\right)\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;2 \cdot \left(\ell \cdot J\right)\\
                                                          
                                                          
                                                          \end{array}
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 2 regimes
                                                          2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0550000000000000003

                                                            1. Initial program 95.1%

                                                              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                            2. Add Preprocessing
                                                            3. Taylor expanded in l around 0

                                                              \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                            4. Step-by-step derivation
                                                              1. +-commutativeN/A

                                                                \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                                              2. associate-*r*N/A

                                                                \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                                                              3. associate-*r*N/A

                                                                \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                              4. *-commutativeN/A

                                                                \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                                                              5. lower-fma.f64N/A

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                                                              6. lower-cos.f64N/A

                                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                              7. lower-*.f64N/A

                                                                \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                              8. *-commutativeN/A

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                                                              9. associate-*l*N/A

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                              10. lower-*.f64N/A

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                              11. *-commutativeN/A

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                              12. lower-*.f6459.3

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                            5. Simplified59.3%

                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                                                            6. Taylor expanded in K around 0

                                                              \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)} \]
                                                            7. Step-by-step derivation
                                                              1. +-commutativeN/A

                                                                \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right) + U} \]
                                                              2. lower-fma.f64N/A

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                              3. lower-*.f6434.8

                                                                \[\leadsto \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right) \]
                                                            8. Simplified34.8%

                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                            9. Step-by-step derivation
                                                              1. lift-*.f64N/A

                                                                \[\leadsto 2 \cdot \color{blue}{\left(J \cdot \ell\right)} + U \]
                                                              2. flip-+N/A

                                                                \[\leadsto \color{blue}{\frac{\left(2 \cdot \left(J \cdot \ell\right)\right) \cdot \left(2 \cdot \left(J \cdot \ell\right)\right) - U \cdot U}{2 \cdot \left(J \cdot \ell\right) - U}} \]
                                                              3. lower-/.f64N/A

                                                                \[\leadsto \color{blue}{\frac{\left(2 \cdot \left(J \cdot \ell\right)\right) \cdot \left(2 \cdot \left(J \cdot \ell\right)\right) - U \cdot U}{2 \cdot \left(J \cdot \ell\right) - U}} \]
                                                              4. cancel-sign-sub-invN/A

                                                                \[\leadsto \frac{\color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right) \cdot \left(2 \cdot \left(J \cdot \ell\right)\right) + \left(\mathsf{neg}\left(U\right)\right) \cdot U}}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              5. swap-sqrN/A

                                                                \[\leadsto \frac{\color{blue}{\left(2 \cdot 2\right) \cdot \left(\left(J \cdot \ell\right) \cdot \left(J \cdot \ell\right)\right)} + \left(\mathsf{neg}\left(U\right)\right) \cdot U}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              6. lower-fma.f64N/A

                                                                \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(2 \cdot 2, \left(J \cdot \ell\right) \cdot \left(J \cdot \ell\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              7. metadata-evalN/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{4}, \left(J \cdot \ell\right) \cdot \left(J \cdot \ell\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              8. lower-*.f64N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \color{blue}{\left(J \cdot \ell\right) \cdot \left(J \cdot \ell\right)}, \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              9. lift-*.f64N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \color{blue}{\left(J \cdot \ell\right)} \cdot \left(J \cdot \ell\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              10. *-commutativeN/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \color{blue}{\left(\ell \cdot J\right)} \cdot \left(J \cdot \ell\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              11. lower-*.f64N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \color{blue}{\left(\ell \cdot J\right)} \cdot \left(J \cdot \ell\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              12. lift-*.f64N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \color{blue}{\left(J \cdot \ell\right)}, \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              13. *-commutativeN/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \color{blue}{\left(\ell \cdot J\right)}, \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              14. lower-*.f64N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \color{blue}{\left(\ell \cdot J\right)}, \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              15. lower-*.f64N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right), \color{blue}{\left(\mathsf{neg}\left(U\right)\right) \cdot U}\right)}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              16. lower-neg.f64N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right), \color{blue}{\left(\mathsf{neg}\left(U\right)\right)} \cdot U\right)}{2 \cdot \left(J \cdot \ell\right) - U} \]
                                                              17. sub-negN/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{\color{blue}{2 \cdot \left(J \cdot \ell\right) + \left(\mathsf{neg}\left(U\right)\right)}} \]
                                                              18. lift-*.f64N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{2 \cdot \color{blue}{\left(J \cdot \ell\right)} + \left(\mathsf{neg}\left(U\right)\right)} \]
                                                              19. associate-*r*N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{\color{blue}{\left(2 \cdot J\right) \cdot \ell} + \left(\mathsf{neg}\left(U\right)\right)} \]
                                                              20. *-commutativeN/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{\color{blue}{\ell \cdot \left(2 \cdot J\right)} + \left(\mathsf{neg}\left(U\right)\right)} \]
                                                              21. lower-fma.f64N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{\color{blue}{\mathsf{fma}\left(\ell, 2 \cdot J, \mathsf{neg}\left(U\right)\right)}} \]
                                                              22. lower-*.f64N/A

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right), \left(\mathsf{neg}\left(U\right)\right) \cdot U\right)}{\mathsf{fma}\left(\ell, \color{blue}{2 \cdot J}, \mathsf{neg}\left(U\right)\right)} \]
                                                              23. lower-neg.f6420.0

                                                                \[\leadsto \frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right), \left(-U\right) \cdot U\right)}{\mathsf{fma}\left(\ell, 2 \cdot J, \color{blue}{-U}\right)} \]
                                                            10. Applied egg-rr20.0%

                                                              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(4, \left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right), \left(-U\right) \cdot U\right)}{\mathsf{fma}\left(\ell, 2 \cdot J, -U\right)}} \]
                                                            11. Taylor expanded in l around 0

                                                              \[\leadsto \color{blue}{{U}^{3}} \]
                                                            12. Step-by-step derivation
                                                              1. cube-multN/A

                                                                \[\leadsto \color{blue}{U \cdot \left(U \cdot U\right)} \]
                                                              2. unpow2N/A

                                                                \[\leadsto U \cdot \color{blue}{{U}^{2}} \]
                                                              3. lower-*.f64N/A

                                                                \[\leadsto \color{blue}{U \cdot {U}^{2}} \]
                                                              4. unpow2N/A

                                                                \[\leadsto U \cdot \color{blue}{\left(U \cdot U\right)} \]
                                                              5. lower-*.f6415.5

                                                                \[\leadsto U \cdot \color{blue}{\left(U \cdot U\right)} \]
                                                            13. Simplified15.5%

                                                              \[\leadsto \color{blue}{U \cdot \left(U \cdot U\right)} \]

                                                            if 0.0550000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                            1. Initial program 83.3%

                                                              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                            2. Add Preprocessing
                                                            3. Taylor expanded in l around 0

                                                              \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                            4. Step-by-step derivation
                                                              1. +-commutativeN/A

                                                                \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                                              2. associate-*r*N/A

                                                                \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                                                              3. associate-*r*N/A

                                                                \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                              4. *-commutativeN/A

                                                                \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                                                              5. lower-fma.f64N/A

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                                                              6. lower-cos.f64N/A

                                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                              7. lower-*.f64N/A

                                                                \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                              8. *-commutativeN/A

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                                                              9. associate-*l*N/A

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                              10. lower-*.f64N/A

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                              11. *-commutativeN/A

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                              12. lower-*.f6468.6

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                            5. Simplified68.6%

                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                                                            6. Taylor expanded in K around 0

                                                              \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)} \]
                                                            7. Step-by-step derivation
                                                              1. +-commutativeN/A

                                                                \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right) + U} \]
                                                              2. lower-fma.f64N/A

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                              3. lower-*.f6462.3

                                                                \[\leadsto \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right) \]
                                                            8. Simplified62.3%

                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                            9. Taylor expanded in l around inf

                                                              \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                            10. Step-by-step derivation
                                                              1. lower-*.f64N/A

                                                                \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                              2. lower-*.f6429.3

                                                                \[\leadsto 2 \cdot \color{blue}{\left(J \cdot \ell\right)} \]
                                                            11. Simplified29.3%

                                                              \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                          3. Recombined 2 regimes into one program.
                                                          4. Final simplification25.8%

                                                            \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.055:\\ \;\;\;\;U \cdot \left(U \cdot U\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\ell \cdot J\right)\\ \end{array} \]
                                                          5. Add Preprocessing

                                                          Alternative 16: 72.4% accurate, 14.3× speedup?

                                                          \[\begin{array}{l} \\ \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), J, U\right) \end{array} \]
                                                          (FPCore (J l K U)
                                                           :precision binary64
                                                           (fma (* l (fma l (* l 0.3333333333333333) 2.0)) J U))
                                                          double code(double J, double l, double K, double U) {
                                                          	return fma((l * fma(l, (l * 0.3333333333333333), 2.0)), J, U);
                                                          }
                                                          
                                                          function code(J, l, K, U)
                                                          	return fma(Float64(l * fma(l, Float64(l * 0.3333333333333333), 2.0)), J, U)
                                                          end
                                                          
                                                          code[J_, l_, K_, U_] := N[(N[(l * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]
                                                          
                                                          \begin{array}{l}
                                                          
                                                          \\
                                                          \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), J, U\right)
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Initial program 86.3%

                                                            \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                          2. Add Preprocessing
                                                          3. Step-by-step derivation
                                                            1. Applied egg-rr100.0%

                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)} \]
                                                            2. Taylor expanded in K around 0

                                                              \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                                            3. Step-by-step derivation
                                                              1. Simplified79.1%

                                                                \[\leadsto \mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{1}, J, U\right) \]
                                                              2. Taylor expanded in l around 0

                                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}, J, U\right) \]
                                                              3. Step-by-step derivation
                                                                1. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}, J, U\right) \]
                                                                2. +-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\ell \cdot \color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)}, J, U\right) \]
                                                                3. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \frac{1}{3}} + 2\right), J, U\right) \]
                                                                4. unpow2N/A

                                                                  \[\leadsto \mathsf{fma}\left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{3} + 2\right), J, U\right) \]
                                                                5. associate-*r*N/A

                                                                  \[\leadsto \mathsf{fma}\left(\ell \cdot \left(\color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{3}\right)} + 2\right), J, U\right) \]
                                                                6. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{3} \cdot \ell\right)} + 2\right), J, U\right) \]
                                                                7. lower-fma.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \frac{1}{3} \cdot \ell, 2\right)}, J, U\right) \]
                                                                8. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \frac{1}{3}}, 2\right), J, U\right) \]
                                                                9. lower-*.f6471.5

                                                                  \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot 0.3333333333333333}, 2\right), J, U\right) \]
                                                              4. Simplified71.5%

                                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)}, J, U\right) \]
                                                              5. Add Preprocessing

                                                              Alternative 17: 54.3% accurate, 27.5× speedup?

                                                              \[\begin{array}{l} \\ \mathsf{fma}\left(2 \cdot \ell, J, U\right) \end{array} \]
                                                              (FPCore (J l K U) :precision binary64 (fma (* 2.0 l) J U))
                                                              double code(double J, double l, double K, double U) {
                                                              	return fma((2.0 * l), J, U);
                                                              }
                                                              
                                                              function code(J, l, K, U)
                                                              	return fma(Float64(2.0 * l), J, U)
                                                              end
                                                              
                                                              code[J_, l_, K_, U_] := N[(N[(2.0 * l), $MachinePrecision] * J + U), $MachinePrecision]
                                                              
                                                              \begin{array}{l}
                                                              
                                                              \\
                                                              \mathsf{fma}\left(2 \cdot \ell, J, U\right)
                                                              \end{array}
                                                              
                                                              Derivation
                                                              1. Initial program 86.3%

                                                                \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                              2. Add Preprocessing
                                                              3. Taylor expanded in l around 0

                                                                \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                              4. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                                                2. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                                                                3. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                                4. *-commutativeN/A

                                                                  \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                                                                5. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                                                                6. lower-cos.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                                7. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                                8. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                                                                9. associate-*l*N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                                10. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                                11. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                                12. lower-*.f6466.3

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                              5. Simplified66.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                                                              6. Taylor expanded in K around 0

                                                                \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)} \]
                                                              7. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right) + U} \]
                                                                2. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                                3. lower-*.f6455.3

                                                                  \[\leadsto \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right) \]
                                                              8. Simplified55.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                              9. Step-by-step derivation
                                                                1. lift-*.f64N/A

                                                                  \[\leadsto 2 \cdot \color{blue}{\left(J \cdot \ell\right)} + U \]
                                                                2. lift-*.f64N/A

                                                                  \[\leadsto 2 \cdot \color{blue}{\left(J \cdot \ell\right)} + U \]
                                                                3. *-commutativeN/A

                                                                  \[\leadsto 2 \cdot \color{blue}{\left(\ell \cdot J\right)} + U \]
                                                                4. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(2 \cdot \ell\right) \cdot J} + U \]
                                                                5. *-commutativeN/A

                                                                  \[\leadsto \color{blue}{\left(\ell \cdot 2\right)} \cdot J + U \]
                                                                6. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\ell \cdot 2, J, U\right)} \]
                                                                7. lower-*.f6455.3

                                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot 2}, J, U\right) \]
                                                              10. Applied egg-rr55.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\ell \cdot 2, J, U\right)} \]
                                                              11. Final simplification55.3%

                                                                \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                                                              12. Add Preprocessing

                                                              Alternative 18: 54.3% accurate, 27.5× speedup?

                                                              \[\begin{array}{l} \\ \mathsf{fma}\left(2, \ell \cdot J, U\right) \end{array} \]
                                                              (FPCore (J l K U) :precision binary64 (fma 2.0 (* l J) U))
                                                              double code(double J, double l, double K, double U) {
                                                              	return fma(2.0, (l * J), U);
                                                              }
                                                              
                                                              function code(J, l, K, U)
                                                              	return fma(2.0, Float64(l * J), U)
                                                              end
                                                              
                                                              code[J_, l_, K_, U_] := N[(2.0 * N[(l * J), $MachinePrecision] + U), $MachinePrecision]
                                                              
                                                              \begin{array}{l}
                                                              
                                                              \\
                                                              \mathsf{fma}\left(2, \ell \cdot J, U\right)
                                                              \end{array}
                                                              
                                                              Derivation
                                                              1. Initial program 86.3%

                                                                \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                              2. Add Preprocessing
                                                              3. Taylor expanded in l around 0

                                                                \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                              4. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                                                2. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                                                                3. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                                4. *-commutativeN/A

                                                                  \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                                                                5. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                                                                6. lower-cos.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                                7. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                                8. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                                                                9. associate-*l*N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                                10. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                                11. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                                12. lower-*.f6466.3

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                              5. Simplified66.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                                                              6. Taylor expanded in K around 0

                                                                \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)} \]
                                                              7. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right) + U} \]
                                                                2. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                                3. lower-*.f6455.3

                                                                  \[\leadsto \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right) \]
                                                              8. Simplified55.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                              9. Final simplification55.3%

                                                                \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, U\right) \]
                                                              10. Add Preprocessing

                                                              Alternative 19: 19.8% accurate, 30.0× speedup?

                                                              \[\begin{array}{l} \\ 2 \cdot \left(\ell \cdot J\right) \end{array} \]
                                                              (FPCore (J l K U) :precision binary64 (* 2.0 (* l J)))
                                                              double code(double J, double l, double K, double U) {
                                                              	return 2.0 * (l * J);
                                                              }
                                                              
                                                              real(8) function code(j, l, k, u)
                                                                  real(8), intent (in) :: j
                                                                  real(8), intent (in) :: l
                                                                  real(8), intent (in) :: k
                                                                  real(8), intent (in) :: u
                                                                  code = 2.0d0 * (l * j)
                                                              end function
                                                              
                                                              public static double code(double J, double l, double K, double U) {
                                                              	return 2.0 * (l * J);
                                                              }
                                                              
                                                              def code(J, l, K, U):
                                                              	return 2.0 * (l * J)
                                                              
                                                              function code(J, l, K, U)
                                                              	return Float64(2.0 * Float64(l * J))
                                                              end
                                                              
                                                              function tmp = code(J, l, K, U)
                                                              	tmp = 2.0 * (l * J);
                                                              end
                                                              
                                                              code[J_, l_, K_, U_] := N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]
                                                              
                                                              \begin{array}{l}
                                                              
                                                              \\
                                                              2 \cdot \left(\ell \cdot J\right)
                                                              \end{array}
                                                              
                                                              Derivation
                                                              1. Initial program 86.3%

                                                                \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                              2. Add Preprocessing
                                                              3. Taylor expanded in l around 0

                                                                \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                              4. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                                                2. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                                                                3. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                                4. *-commutativeN/A

                                                                  \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                                                                5. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                                                                6. lower-cos.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                                7. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                                8. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                                                                9. associate-*l*N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                                10. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                                11. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                                12. lower-*.f6466.3

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                              5. Simplified66.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                                                              6. Taylor expanded in K around 0

                                                                \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)} \]
                                                              7. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right) + U} \]
                                                                2. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                                3. lower-*.f6455.3

                                                                  \[\leadsto \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right) \]
                                                              8. Simplified55.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                              9. Taylor expanded in l around inf

                                                                \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                              10. Step-by-step derivation
                                                                1. lower-*.f64N/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                                2. lower-*.f6422.2

                                                                  \[\leadsto 2 \cdot \color{blue}{\left(J \cdot \ell\right)} \]
                                                              11. Simplified22.2%

                                                                \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                              12. Final simplification22.2%

                                                                \[\leadsto 2 \cdot \left(\ell \cdot J\right) \]
                                                              13. Add Preprocessing

                                                              Alternative 20: 3.0% accurate, 55.0× speedup?

                                                              \[\begin{array}{l} \\ 2 \cdot J \end{array} \]
                                                              (FPCore (J l K U) :precision binary64 (* 2.0 J))
                                                              double code(double J, double l, double K, double U) {
                                                              	return 2.0 * J;
                                                              }
                                                              
                                                              real(8) function code(j, l, k, u)
                                                                  real(8), intent (in) :: j
                                                                  real(8), intent (in) :: l
                                                                  real(8), intent (in) :: k
                                                                  real(8), intent (in) :: u
                                                                  code = 2.0d0 * j
                                                              end function
                                                              
                                                              public static double code(double J, double l, double K, double U) {
                                                              	return 2.0 * J;
                                                              }
                                                              
                                                              def code(J, l, K, U):
                                                              	return 2.0 * J
                                                              
                                                              function code(J, l, K, U)
                                                              	return Float64(2.0 * J)
                                                              end
                                                              
                                                              function tmp = code(J, l, K, U)
                                                              	tmp = 2.0 * J;
                                                              end
                                                              
                                                              code[J_, l_, K_, U_] := N[(2.0 * J), $MachinePrecision]
                                                              
                                                              \begin{array}{l}
                                                              
                                                              \\
                                                              2 \cdot J
                                                              \end{array}
                                                              
                                                              Derivation
                                                              1. Initial program 86.3%

                                                                \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                              2. Add Preprocessing
                                                              3. Taylor expanded in l around 0

                                                                \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                              4. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                                                2. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                                                                3. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                                4. *-commutativeN/A

                                                                  \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                                                                5. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                                                                6. lower-cos.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                                7. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                                8. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                                                                9. associate-*l*N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                                10. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                                11. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                                12. lower-*.f6466.3

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                              5. Simplified66.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                                                              6. Taylor expanded in K around 0

                                                                \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)} \]
                                                              7. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right) + U} \]
                                                                2. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                                3. lower-*.f6455.3

                                                                  \[\leadsto \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right) \]
                                                              8. Simplified55.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                              9. Taylor expanded in J around inf

                                                                \[\leadsto \color{blue}{2 \cdot J} \]
                                                              10. Step-by-step derivation
                                                                1. lower-*.f643.1

                                                                  \[\leadsto \color{blue}{2 \cdot J} \]
                                                              11. Simplified3.1%

                                                                \[\leadsto \color{blue}{2 \cdot J} \]
                                                              12. Add Preprocessing

                                                              Alternative 21: 3.0% accurate, 110.0× speedup?

                                                              \[\begin{array}{l} \\ -J \end{array} \]
                                                              (FPCore (J l K U) :precision binary64 (- J))
                                                              double code(double J, double l, double K, double U) {
                                                              	return -J;
                                                              }
                                                              
                                                              real(8) function code(j, l, k, u)
                                                                  real(8), intent (in) :: j
                                                                  real(8), intent (in) :: l
                                                                  real(8), intent (in) :: k
                                                                  real(8), intent (in) :: u
                                                                  code = -j
                                                              end function
                                                              
                                                              public static double code(double J, double l, double K, double U) {
                                                              	return -J;
                                                              }
                                                              
                                                              def code(J, l, K, U):
                                                              	return -J
                                                              
                                                              function code(J, l, K, U)
                                                              	return Float64(-J)
                                                              end
                                                              
                                                              function tmp = code(J, l, K, U)
                                                              	tmp = -J;
                                                              end
                                                              
                                                              code[J_, l_, K_, U_] := (-J)
                                                              
                                                              \begin{array}{l}
                                                              
                                                              \\
                                                              -J
                                                              \end{array}
                                                              
                                                              Derivation
                                                              1. Initial program 86.3%

                                                                \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                              2. Add Preprocessing
                                                              3. Taylor expanded in l around 0

                                                                \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                              4. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                                                                2. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                                                                3. associate-*r*N/A

                                                                  \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                                4. *-commutativeN/A

                                                                  \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                                                                5. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                                                                6. lower-cos.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                                7. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                                                                8. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                                                                9. associate-*l*N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                                10. lower-*.f64N/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                                                                11. *-commutativeN/A

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                                12. lower-*.f6466.3

                                                                  \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                                                              5. Simplified66.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                                                              6. Taylor expanded in K around 0

                                                                \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)} \]
                                                              7. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right) + U} \]
                                                                2. lower-fma.f64N/A

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                                3. lower-*.f6455.3

                                                                  \[\leadsto \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right) \]
                                                              8. Simplified55.3%

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)} \]
                                                              9. Taylor expanded in J around inf

                                                                \[\leadsto \color{blue}{2 \cdot J} \]
                                                              10. Step-by-step derivation
                                                                1. lower-*.f643.1

                                                                  \[\leadsto \color{blue}{2 \cdot J} \]
                                                              11. Simplified3.1%

                                                                \[\leadsto \color{blue}{2 \cdot J} \]
                                                              12. Taylor expanded in J around -inf

                                                                \[\leadsto \color{blue}{-1 \cdot J} \]
                                                              13. Step-by-step derivation
                                                                1. mul-1-negN/A

                                                                  \[\leadsto \color{blue}{\mathsf{neg}\left(J\right)} \]
                                                                2. lower-neg.f643.1

                                                                  \[\leadsto \color{blue}{-J} \]
                                                              14. Simplified3.1%

                                                                \[\leadsto \color{blue}{-J} \]
                                                              15. Add Preprocessing

                                                              Reproduce

                                                              ?
                                                              herbie shell --seed 2024214 
                                                              (FPCore (J l K U)
                                                                :name "Maksimov and Kolovsky, Equation (4)"
                                                                :precision binary64
                                                                (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))