Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.2% → 100.0%
Time: 13.7s
Alternatives: 23
Speedup: 1.8×

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 23 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: 100.0% accurate, 1.5× speedup?

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

\\
\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)
\end{array}
Derivation
  1. Initial program 85.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. lift-exp.f64N/A

      \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. lift-neg.f64N/A

      \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. lift-exp.f64N/A

      \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. lift--.f64N/A

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

      \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    6. lift-/.f64N/A

      \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
    7. lift-cos.f64N/A

      \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
    8. lift-*.f64N/A

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
  4. Applied rewrites100.0%

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

Alternative 2: 87.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := 2 \cdot \sinh \ell\\ \mathbf{if}\;t\_0 \leq -0.88:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\ \mathbf{elif}\;t\_0 \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(t\_1 \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t\_1, J, U\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))) (t_1 (* 2.0 (sinh l))))
   (if (<= t_0 -0.88)
     (fma (* (cos (* K 0.5)) (* 2.0 l)) J U)
     (if (<= t_0 -0.02)
       (fma (* t_1 (fma K (* K -0.125) 1.0)) J U)
       (fma t_1 J U)))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = 2.0 * sinh(l);
	double tmp;
	if (t_0 <= -0.88) {
		tmp = fma((cos((K * 0.5)) * (2.0 * l)), J, U);
	} else if (t_0 <= -0.02) {
		tmp = fma((t_1 * fma(K, (K * -0.125), 1.0)), J, U);
	} else {
		tmp = fma(t_1, J, U);
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(2.0 * sinh(l))
	tmp = 0.0
	if (t_0 <= -0.88)
		tmp = fma(Float64(cos(Float64(K * 0.5)) * Float64(2.0 * l)), J, U);
	elseif (t_0 <= -0.02)
		tmp = fma(Float64(t_1 * fma(K, Float64(K * -0.125), 1.0)), J, U);
	else
		tmp = fma(t_1, J, U);
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.88], N[(N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[t$95$0, -0.02], N[(N[(t$95$1 * N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(t$95$1 * J + U), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := 2 \cdot \sinh \ell\\
\mathbf{if}\;t\_0 \leq -0.88:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\

\mathbf{elif}\;t\_0 \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(t\_1 \cdot \mathsf{fma}\left(K, K \cdot -0.125, 1\right), J, U\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, J, U\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.880000000000000004

    1. Initial program 67.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. lift-exp.f64N/A

        \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. lift-neg.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. lift-exp.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. lift--.f64N/A

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

        \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. lift-/.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
      7. lift-cos.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
      8. lift-*.f64N/A

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
    4. Applied rewrites100.0%

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot 0.5\right), J, U\right) \]
    7. Applied rewrites85.1%

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

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

    1. Initial program 91.2%

      \[\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. lift-exp.f64N/A

        \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. lift-neg.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. lift-exp.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. lift--.f64N/A

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

        \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. lift-/.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
      7. lift-cos.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
      8. lift-*.f64N/A

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
    4. Applied rewrites100.0%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 85.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. lift-exp.f64N/A

        \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. lift-neg.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. lift-exp.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. lift--.f64N/A

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

        \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. lift-/.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
      7. lift-cos.f64N/A

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
      8. lift-*.f64N/A

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
    4. Applied rewrites99.9%

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

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

        \[\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. associate-*l*N/A

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

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

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

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

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

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

    Alternative 3: 87.3% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -0.87:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\ \mathbf{elif}\;t\_0 \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), \ell \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 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
     (let* ((t_0 (cos (/ K 2.0))))
       (if (<= t_0 -0.87)
         (fma (* (cos (* K 0.5)) (* 2.0 l)) J U)
         (if (<= t_0 -0.02)
           (fma
            (fma K (* K -0.125) 1.0)
            (*
             l
             (*
              J
              (fma
               l
               (*
                l
                (fma
                 (* l l)
                 (fma l (* l 0.0003968253968253968) 0.016666666666666666)
                 0.3333333333333333))
               2.0)))
            U)
           (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.87) {
    		tmp = fma((cos((K * 0.5)) * (2.0 * l)), J, U);
    	} else if (t_0 <= -0.02) {
    		tmp = fma(fma(K, (K * -0.125), 1.0), (l * (J * fma(l, (l * fma((l * l), fma(l, (l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0))), U);
    	} 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.87)
    		tmp = fma(Float64(cos(Float64(K * 0.5)) * Float64(2.0 * l)), J, U);
    	elseif (t_0 <= -0.02)
    		tmp = fma(fma(K, Float64(K * -0.125), 1.0), Float64(l * Float64(J * fma(l, Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0))), U);
    	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.87], N[(N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[t$95$0, -0.02], N[(N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[(l * N[(J * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.0003968253968253968), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $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}
    t_0 := \cos \left(\frac{K}{2}\right)\\
    \mathbf{if}\;t\_0 \leq -0.87:\\
    \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\
    
    \mathbf{elif}\;t\_0 \leq -0.02:\\
    \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), \ell \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 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 3 regimes
    2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.869999999999999996

      1. Initial program 72.1%

        \[\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. lift-exp.f64N/A

          \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        2. lift-neg.f64N/A

          \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        3. lift-exp.f64N/A

          \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        4. lift--.f64N/A

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

          \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
        6. lift-/.f64N/A

          \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
        7. lift-cos.f64N/A

          \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
        8. lift-*.f64N/A

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
      4. Applied rewrites100.0%

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot 0.5\right), J, U\right) \]
      7. Applied rewrites80.1%

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

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

      1. Initial program 90.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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + {\ell}^{2} \cdot \left(\frac{1}{2520} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{60} \cdot J\right)\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + J \cdot \left({\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) + U \]
      8. Applied rewrites76.8%

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

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

      1. Initial program 85.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. lift-exp.f64N/A

          \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        2. lift-neg.f64N/A

          \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        3. lift-exp.f64N/A

          \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        4. lift--.f64N/A

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

          \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
        6. lift-/.f64N/A

          \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
        7. lift-cos.f64N/A

          \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
        8. lift-*.f64N/A

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
      4. Applied rewrites99.9%

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

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

          \[\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. associate-*l*N/A

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
      7. Recombined 3 regimes into one program.
      8. Final simplification92.0%

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

      Alternative 4: 87.3% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -0.87:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right), J \cdot \left(2 \cdot \ell\right), U\right)\\ \mathbf{elif}\;t\_0 \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), \ell \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 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
       (let* ((t_0 (cos (/ K 2.0))))
         (if (<= t_0 -0.87)
           (fma (cos (* K 0.5)) (* J (* 2.0 l)) U)
           (if (<= t_0 -0.02)
             (fma
              (fma K (* K -0.125) 1.0)
              (*
               l
               (*
                J
                (fma
                 l
                 (*
                  l
                  (fma
                   (* l l)
                   (fma l (* l 0.0003968253968253968) 0.016666666666666666)
                   0.3333333333333333))
                 2.0)))
              U)
             (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.87) {
      		tmp = fma(cos((K * 0.5)), (J * (2.0 * l)), U);
      	} else if (t_0 <= -0.02) {
      		tmp = fma(fma(K, (K * -0.125), 1.0), (l * (J * fma(l, (l * fma((l * l), fma(l, (l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0))), U);
      	} 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.87)
      		tmp = fma(cos(Float64(K * 0.5)), Float64(J * Float64(2.0 * l)), U);
      	elseif (t_0 <= -0.02)
      		tmp = fma(fma(K, Float64(K * -0.125), 1.0), Float64(l * Float64(J * fma(l, Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0))), U);
      	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.87], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, -0.02], N[(N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[(l * N[(J * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.0003968253968253968), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $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}
      t_0 := \cos \left(\frac{K}{2}\right)\\
      \mathbf{if}\;t\_0 \leq -0.87:\\
      \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right), J \cdot \left(2 \cdot \ell\right), U\right)\\
      
      \mathbf{elif}\;t\_0 \leq -0.02:\\
      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), \ell \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 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 3 regimes
      2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.869999999999999996

        1. Initial program 72.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-*.f6480.0

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

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

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

        1. Initial program 90.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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + {\ell}^{2} \cdot \left(\frac{1}{2520} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{60} \cdot J\right)\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
        4. Step-by-step derivation
          1. lower-*.f64N/A

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + J \cdot \left({\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) + U \]
        8. Applied rewrites76.8%

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

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

        1. Initial program 85.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. lift-exp.f64N/A

            \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
          2. lift-neg.f64N/A

            \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
          3. lift-exp.f64N/A

            \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
          4. lift--.f64N/A

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

            \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
          6. lift-/.f64N/A

            \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
          7. lift-cos.f64N/A

            \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
          8. lift-*.f64N/A

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
        4. Applied rewrites99.9%

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

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

            \[\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. associate-*l*N/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{\sinh \ell \cdot 2}, J, U\right) \]
        7. Recombined 3 regimes into one program.
        8. Final simplification92.0%

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

        Alternative 5: 96.1% accurate, 1.2× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.984:\\ \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 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.984)
             (+
              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.984) {
        		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.984)
        		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * fma(Float64(l * l), fma(Float64(l * 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.984], N[(U + N[(t$95$0 * N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.016666666666666666 + 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.984:\\
        \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 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.98399999999999999

          1. Initial program 84.9%

            \[\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. lower-fma.f64N/A

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

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

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

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

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

          1. Initial program 86.4%

            \[\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. lift-exp.f64N/A

              \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            2. lift-neg.f64N/A

              \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            3. lift-exp.f64N/A

              \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            4. lift--.f64N/A

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

              \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
            6. lift-/.f64N/A

              \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
            7. lift-cos.f64N/A

              \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
            8. lift-*.f64N/A

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
          4. Applied rewrites100.0%

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

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

              \[\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. associate-*l*N/A

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

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

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

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

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

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

          Alternative 6: 77.2% accurate, 1.2× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\ \mathbf{elif}\;t\_0 \leq 0.999999998:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \left(\ell \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\ \end{array} \end{array} \]
          (FPCore (J l K U)
           :precision binary64
           (let* ((t_0 (cos (/ K 2.0))))
             (if (<= t_0 -0.02)
               (fma (* l (* -0.25 (* K K))) J U)
               (if (<= t_0 0.999999998)
                 (fma J (* l (* l (* l (* (* l l) 0.016666666666666666)))) U)
                 (fma J (* l (fma l (* l 0.3333333333333333) 2.0)) U)))))
          double code(double J, double l, double K, double U) {
          	double t_0 = cos((K / 2.0));
          	double tmp;
          	if (t_0 <= -0.02) {
          		tmp = fma((l * (-0.25 * (K * K))), J, U);
          	} else if (t_0 <= 0.999999998) {
          		tmp = fma(J, (l * (l * (l * ((l * l) * 0.016666666666666666)))), U);
          	} else {
          		tmp = fma(J, (l * fma(l, (l * 0.3333333333333333), 2.0)), U);
          	}
          	return tmp;
          }
          
          function code(J, l, K, U)
          	t_0 = cos(Float64(K / 2.0))
          	tmp = 0.0
          	if (t_0 <= -0.02)
          		tmp = fma(Float64(l * Float64(-0.25 * Float64(K * K))), J, U);
          	elseif (t_0 <= 0.999999998)
          		tmp = fma(J, Float64(l * Float64(l * Float64(l * Float64(Float64(l * l) * 0.016666666666666666)))), U);
          	else
          		tmp = fma(J, Float64(l * fma(l, Float64(l * 0.3333333333333333), 2.0)), 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.02], N[(N[(l * N[(-0.25 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[t$95$0, 0.999999998], N[(J * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(l * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \cos \left(\frac{K}{2}\right)\\
          \mathbf{if}\;t\_0 \leq -0.02:\\
          \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\
          
          \mathbf{elif}\;t\_0 \leq 0.999999998:\\
          \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \left(\ell \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right), U\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0200000000000000004

            1. Initial program 85.6%

              \[\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. lift-exp.f64N/A

                \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              2. lift-neg.f64N/A

                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              3. lift-exp.f64N/A

                \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              4. lift--.f64N/A

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

                \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
              6. lift-/.f64N/A

                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
              7. lift-cos.f64N/A

                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
              8. lift-*.f64N/A

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
            4. Applied rewrites100.0%

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

              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
            6. Step-by-step derivation
              1. lower-*.f6463.0

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

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

              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell}, J, U\right) \]
            9. Step-by-step derivation
              1. associate-*r*N/A

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, -0.25, 2\right), J, U\right) \]
            10. Applied rewrites60.8%

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \color{blue}{\left(K \cdot K\right)}\right), J, U\right) \]
            13. Applied rewrites60.8%

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

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

            1. Initial program 85.2%

              \[\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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{3} \cdot J\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
            4. Step-by-step derivation
              1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(J, \ell \cdot \color{blue}{\left(\frac{1}{60} \cdot {\ell}^{4}\right)}, U\right) \]
            10. Step-by-step derivation
              1. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\ell \cdot \left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60}\right)\right)\right), U\right) \]
              12. lower-*.f6479.1

                \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\ell \cdot \left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot 0.016666666666666666\right)\right)\right), U\right) \]
            11. Applied rewrites79.1%

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

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

            1. Initial program 86.2%

              \[\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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{3} \cdot J\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
            4. Step-by-step derivation
              1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 7: 93.7% accurate, 1.3× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.625:\\ \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 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.625)
               (+ U (* t_0 (* J (* l (fma l (* l 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.625) {
          		tmp = U + (t_0 * (J * (l * fma(l, (l * 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.625)
          		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * fma(l, Float64(l * 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.625], N[(U + N[(t$95$0 * N[(J * N[(l * N[(l * N[(l * 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.625:\\
          \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 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.625

            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. Taylor expanded in l around 0

              \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\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 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              2. +-commutativeN/A

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

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

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

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

                \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \frac{1}{3} \cdot \ell, 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, \color{blue}{\ell \cdot \frac{1}{3}}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              8. lower-*.f6490.3

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

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

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

            1. Initial program 85.7%

              \[\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. lift-exp.f64N/A

                \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              2. lift-neg.f64N/A

                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              3. lift-exp.f64N/A

                \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              4. lift--.f64N/A

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

                \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
              6. lift-/.f64N/A

                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
              7. lift-cos.f64N/A

                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
              8. lift-*.f64N/A

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
            4. Applied rewrites100.0%

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

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

                \[\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. associate-*l*N/A

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

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

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

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

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

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

            Alternative 8: 92.8% accurate, 1.3× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.625:\\ \;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right) \cdot \left(\cos \left(K \cdot 0.5\right) \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.625)
               (fma l (* (fma l (* l 0.3333333333333333) 2.0) (* (cos (* K 0.5)) 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.625) {
            		tmp = fma(l, (fma(l, (l * 0.3333333333333333), 2.0) * (cos((K * 0.5)) * 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.625)
            		tmp = fma(l, Float64(fma(l, Float64(l * 0.3333333333333333), 2.0) * Float64(cos(Float64(K * 0.5)) * 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.625], N[(l * N[(N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision] * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * 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.625:\\
            \;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right) \cdot \left(\cos \left(K \cdot 0.5\right) \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.625

              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. 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. *-commutativeN/A

                  \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\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(\frac{1}{3} \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot {\ell}^{2}\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
                4. associate-*l*N/A

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

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

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

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

              1. Initial program 85.7%

                \[\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. lift-exp.f64N/A

                  \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                2. lift-neg.f64N/A

                  \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                3. lift-exp.f64N/A

                  \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                4. lift--.f64N/A

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

                  \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                6. lift-/.f64N/A

                  \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                7. lift-cos.f64N/A

                  \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                8. lift-*.f64N/A

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

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

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
              4. Applied rewrites100.0%

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

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

                  \[\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. associate-*l*N/A

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

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

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

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

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

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

              Alternative 9: 57.7% accurate, 1.4× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq 0.004:\\ \;\;\;\;\mathsf{fma}\left(\ell, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\ell \cdot J\right) \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\\ \end{array} \end{array} \]
              (FPCore (J l K U)
               :precision binary64
               (if (<= (- (exp l) (exp (- l))) 0.004)
                 (fma l (* 2.0 J) U)
                 (* (* l J) (fma -0.25 (* K K) 2.0))))
              double code(double J, double l, double K, double U) {
              	double tmp;
              	if ((exp(l) - exp(-l)) <= 0.004) {
              		tmp = fma(l, (2.0 * J), U);
              	} else {
              		tmp = (l * J) * fma(-0.25, (K * K), 2.0);
              	}
              	return tmp;
              }
              
              function code(J, l, K, U)
              	tmp = 0.0
              	if (Float64(exp(l) - exp(Float64(-l))) <= 0.004)
              		tmp = fma(l, Float64(2.0 * J), U);
              	else
              		tmp = Float64(Float64(l * J) * fma(-0.25, Float64(K * K), 2.0));
              	end
              	return tmp
              end
              
              code[J_, l_, K_, U_] := If[LessEqual[N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], 0.004], N[(l * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(l * J), $MachinePrecision] * N[(-0.25 * N[(K * K), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;e^{\ell} - e^{-\ell} \leq 0.004:\\
              \;\;\;\;\mathsf{fma}\left(\ell, 2 \cdot J, U\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(\ell \cdot J\right) \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0040000000000000001

                1. Initial program 81.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-*.f6475.1

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

                  \[\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. *-commutativeN/A

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

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

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

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

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

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

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

                if 0.0040000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

                1. Initial program 100.0%

                  \[\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. lift-exp.f64N/A

                    \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  2. lift-neg.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  3. lift-exp.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  4. lift--.f64N/A

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

                    \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                  6. lift-/.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                  7. lift-cos.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                  8. lift-*.f64N/A

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

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

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                4. Applied rewrites100.0%

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

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

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot 0.5\right), J, U\right) \]
                7. Applied rewrites21.1%

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

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell}, J, U\right) \]
                9. Step-by-step derivation
                  1. associate-*r*N/A

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, -0.25, 2\right), J, U\right) \]
                10. Applied rewrites32.0%

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(\ell \cdot J\right) \cdot \mathsf{fma}\left(-0.25, \color{blue}{K \cdot K}, 2\right) \]
                13. Applied rewrites30.5%

                  \[\leadsto \color{blue}{\left(\ell \cdot J\right) \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)} \]
              3. Recombined 2 regimes into one program.
              4. Add Preprocessing

              Alternative 10: 54.1% accurate, 1.4× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq 0.004:\\ \;\;\;\;\mathsf{fma}\left(\ell, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-0.25 \cdot \left(K \cdot K\right)\right) \cdot \left(\ell \cdot J\right)\\ \end{array} \end{array} \]
              (FPCore (J l K U)
               :precision binary64
               (if (<= (- (exp l) (exp (- l))) 0.004)
                 (fma l (* 2.0 J) U)
                 (* (* -0.25 (* K K)) (* l J))))
              double code(double J, double l, double K, double U) {
              	double tmp;
              	if ((exp(l) - exp(-l)) <= 0.004) {
              		tmp = fma(l, (2.0 * J), U);
              	} else {
              		tmp = (-0.25 * (K * K)) * (l * J);
              	}
              	return tmp;
              }
              
              function code(J, l, K, U)
              	tmp = 0.0
              	if (Float64(exp(l) - exp(Float64(-l))) <= 0.004)
              		tmp = fma(l, Float64(2.0 * J), U);
              	else
              		tmp = Float64(Float64(-0.25 * Float64(K * K)) * Float64(l * J));
              	end
              	return tmp
              end
              
              code[J_, l_, K_, U_] := If[LessEqual[N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], 0.004], N[(l * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(-0.25 * N[(K * K), $MachinePrecision]), $MachinePrecision] * N[(l * J), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;e^{\ell} - e^{-\ell} \leq 0.004:\\
              \;\;\;\;\mathsf{fma}\left(\ell, 2 \cdot J, U\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(-0.25 \cdot \left(K \cdot K\right)\right) \cdot \left(\ell \cdot J\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0040000000000000001

                1. Initial program 81.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-*.f6475.1

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

                  \[\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. *-commutativeN/A

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

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

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

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

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

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

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

                if 0.0040000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

                1. Initial program 100.0%

                  \[\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. lift-exp.f64N/A

                    \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  2. lift-neg.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  3. lift-exp.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  4. lift--.f64N/A

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

                    \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                  6. lift-/.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                  7. lift-cos.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                  8. lift-*.f64N/A

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

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

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                4. Applied rewrites100.0%

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

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

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot 0.5\right), J, U\right) \]
                7. Applied rewrites21.1%

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

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell}, J, U\right) \]
                9. Step-by-step derivation
                  1. associate-*r*N/A

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, -0.25, 2\right), J, U\right) \]
                10. Applied rewrites32.0%

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\left(\ell \cdot J\right)} \cdot \left(\frac{-1}{4} \cdot {K}^{2}\right) \]
                  8. lower-*.f64N/A

                    \[\leadsto \color{blue}{\left(\ell \cdot J\right)} \cdot \left(\frac{-1}{4} \cdot {K}^{2}\right) \]
                  9. lower-*.f64N/A

                    \[\leadsto \left(\ell \cdot J\right) \cdot \color{blue}{\left(\frac{-1}{4} \cdot {K}^{2}\right)} \]
                  10. unpow2N/A

                    \[\leadsto \left(\ell \cdot J\right) \cdot \left(\frac{-1}{4} \cdot \color{blue}{\left(K \cdot K\right)}\right) \]
                  11. lower-*.f6421.0

                    \[\leadsto \left(\ell \cdot J\right) \cdot \left(-0.25 \cdot \color{blue}{\left(K \cdot K\right)}\right) \]
                13. Applied rewrites21.0%

                  \[\leadsto \color{blue}{\left(\ell \cdot J\right) \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right)} \]
              3. Recombined 2 regimes into one program.
              4. Final simplification54.0%

                \[\leadsto \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq 0.004:\\ \;\;\;\;\mathsf{fma}\left(\ell, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-0.25 \cdot \left(K \cdot K\right)\right) \cdot \left(\ell \cdot J\right)\\ \end{array} \]
              5. Add Preprocessing

              Alternative 11: 87.1% accurate, 1.4× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), \ell \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 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.02)
                 (fma
                  (fma K (* K -0.125) 1.0)
                  (*
                   l
                   (*
                    J
                    (fma
                     l
                     (*
                      l
                      (fma
                       (* l l)
                       (fma l (* l 0.0003968253968253968) 0.016666666666666666)
                       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.02) {
              		tmp = fma(fma(K, (K * -0.125), 1.0), (l * (J * fma(l, (l * fma((l * l), fma(l, (l * 0.0003968253968253968), 0.016666666666666666), 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.02)
              		tmp = fma(fma(K, Float64(K * -0.125), 1.0), Float64(l * Float64(J * fma(l, Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.0003968253968253968), 0.016666666666666666), 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.02], N[(N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[(l * N[(J * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.0003968253968253968), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $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.02:\\
              \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), \ell \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 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.0200000000000000004

                1. Initial program 85.6%

                  \[\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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + {\ell}^{2} \cdot \left(\frac{1}{2520} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{60} \cdot J\right)\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                4. Step-by-step derivation
                  1. lower-*.f64N/A

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + J \cdot \left({\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) + U \]
                8. Applied rewrites66.2%

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

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

                1. Initial program 85.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. lift-exp.f64N/A

                    \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  2. lift-neg.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  3. lift-exp.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  4. lift--.f64N/A

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

                    \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                  6. lift-/.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                  7. lift-cos.f64N/A

                    \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                  8. lift-*.f64N/A

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

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

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                4. Applied rewrites99.9%

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

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

                    \[\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. associate-*l*N/A

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

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

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

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

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

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

                Alternative 12: 88.7% accurate, 1.7× speedup?

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

                  1. Initial program 84.7%

                    \[\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. lift-exp.f64N/A

                      \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    2. lift-neg.f64N/A

                      \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    3. lift-exp.f64N/A

                      \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    4. lift--.f64N/A

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

                      \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                    6. lift-/.f64N/A

                      \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                    7. lift-cos.f64N/A

                      \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                    8. lift-*.f64N/A

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

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

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

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                  4. Applied rewrites100.0%

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

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

                      \[\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. associate-*l*N/A

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

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

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

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

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

                    if 1e-8 < (/.f64 K #s(literal 2 binary64))

                    1. Initial program 89.4%

                      \[\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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + {\ell}^{2} \cdot \left(\frac{1}{2520} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{60} \cdot J\right)\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                    4. Step-by-step derivation
                      1. lower-*.f64N/A

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

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

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

                      \[\leadsto \color{blue}{\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(J \cdot \left(\ell \cdot \ell\right), \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), J \cdot 0.3333333333333333\right), J \cdot 2\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                  7. Recombined 2 regimes into one program.
                  8. Final simplification87.9%

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

                  Alternative 13: 89.1% accurate, 1.8× speedup?

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

                    1. Initial program 84.7%

                      \[\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. lift-exp.f64N/A

                        \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                      2. lift-neg.f64N/A

                        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                      3. lift-exp.f64N/A

                        \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                      4. lift--.f64N/A

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

                        \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                      6. lift-/.f64N/A

                        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                      7. lift-cos.f64N/A

                        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                      8. lift-*.f64N/A

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

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

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

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                    4. Applied rewrites100.0%

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

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

                        \[\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. associate-*l*N/A

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

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

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

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

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

                      if 1e-8 < (/.f64 K #s(literal 2 binary64))

                      1. Initial program 89.4%

                        \[\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} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\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} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\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} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\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} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right), 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} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right), 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} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right), 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}{{\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right) + \frac{1}{3}}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                        7. unpow2N/A

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

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

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

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

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

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

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

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

                        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    7. Recombined 2 regimes into one program.
                    8. Final simplification87.9%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{K}{2} \leq 10^{-8}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\ \mathbf{else}:\\ \;\;\;\;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 \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right)\right)\\ \end{array} \]
                    9. Add Preprocessing

                    Alternative 14: 83.3% accurate, 1.9× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), \ell \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\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(\ell \cdot \ell, 0.0003968253968253968, 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.02)
                       (fma
                        (fma K (* K -0.125) 1.0)
                        (*
                         l
                         (*
                          J
                          (fma
                           l
                           (*
                            l
                            (fma
                             (* l l)
                             (fma l (* l 0.0003968253968253968) 0.016666666666666666)
                             0.3333333333333333))
                           2.0)))
                        U)
                       (fma
                        (*
                         l
                         (fma
                          (* l l)
                          (fma
                           (* l l)
                           (fma (* l l) 0.0003968253968253968 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.02) {
                    		tmp = fma(fma(K, (K * -0.125), 1.0), (l * (J * fma(l, (l * fma((l * l), fma(l, (l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0))), U);
                    	} else {
                    		tmp = fma((l * fma((l * l), fma((l * l), fma((l * l), 0.0003968253968253968, 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.02)
                    		tmp = fma(fma(K, Float64(K * -0.125), 1.0), Float64(l * Float64(J * fma(l, Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0))), U);
                    	else
                    		tmp = fma(Float64(l * fma(Float64(l * l), fma(Float64(l * l), fma(Float64(l * l), 0.0003968253968253968, 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.02], N[(N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[(l * N[(J * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.0003968253968253968), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(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] * J + U), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
                    \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), \ell \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\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(\ell \cdot \ell, 0.0003968253968253968, 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.0200000000000000004

                      1. Initial program 85.6%

                        \[\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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + {\ell}^{2} \cdot \left(\frac{1}{2520} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{60} \cdot J\right)\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                      4. Step-by-step derivation
                        1. lower-*.f64N/A

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

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

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

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

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

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

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

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

                          \[\leadsto \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + J \cdot \left({\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) + U \]
                      8. Applied rewrites66.2%

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

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

                      1. Initial program 85.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. lift-exp.f64N/A

                          \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                        2. lift-neg.f64N/A

                          \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                        3. lift-exp.f64N/A

                          \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                        4. lift--.f64N/A

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

                          \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                        6. lift-/.f64N/A

                          \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                        7. lift-cos.f64N/A

                          \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                        8. lift-*.f64N/A

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

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

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

                          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                      4. Applied rewrites99.9%

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

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

                          \[\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. *-commutativeN/A

                            \[\leadsto \mathsf{fma}\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), J, U\right) \]
                          12. 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({\ell}^{2}, \frac{1}{2520}, \frac{1}{60}\right)}, \frac{1}{3}\right), 2\right), J, U\right) \]
                          13. unpow2N/A

                            \[\leadsto \mathsf{fma}\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), J, U\right) \]
                          14. lower-*.f6490.6

                            \[\leadsto \mathsf{fma}\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), J, U\right) \]
                        4. Applied rewrites90.6%

                          \[\leadsto \mathsf{fma}\left(\color{blue}{\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)}, J, U\right) \]
                      7. Recombined 2 regimes into one program.
                      8. Add Preprocessing

                      Alternative 15: 83.1% accurate, 2.0× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), 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), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\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), J, U\right)\\ \end{array} \end{array} \]
                      (FPCore (J l K U)
                       :precision binary64
                       (if (<= (cos (/ K 2.0)) -0.02)
                         (fma
                          (fma K (* K -0.125) 1.0)
                          (*
                           J
                           (*
                            l
                            (fma (* l l) (fma l (* l 0.016666666666666666) 0.3333333333333333) 2.0)))
                          U)
                         (fma
                          (*
                           l
                           (fma
                            (* l l)
                            (fma
                             (* l l)
                             (fma (* l l) 0.0003968253968253968 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.02) {
                      		tmp = fma(fma(K, (K * -0.125), 1.0), (J * (l * fma((l * l), fma(l, (l * 0.016666666666666666), 0.3333333333333333), 2.0))), U);
                      	} else {
                      		tmp = fma((l * fma((l * l), fma((l * l), fma((l * l), 0.0003968253968253968, 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.02)
                      		tmp = fma(fma(K, Float64(K * -0.125), 1.0), Float64(J * Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0))), U);
                      	else
                      		tmp = fma(Float64(l * fma(Float64(l * l), fma(Float64(l * l), fma(Float64(l * l), 0.0003968253968253968, 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.02], N[(N[(K * N[(K * -0.125), $MachinePrecision] + 1.0), $MachinePrecision] * N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(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] * J + U), $MachinePrecision]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
                      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), 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), U\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\mathsf{fma}\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), 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.0200000000000000004

                        1. Initial program 85.6%

                          \[\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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{3} \cdot J\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                        4. Step-by-step derivation
                          1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot -0.125, 1\right), 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), U\right)} \]

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

                        1. Initial program 85.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. lift-exp.f64N/A

                            \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                          2. lift-neg.f64N/A

                            \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                          3. lift-exp.f64N/A

                            \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                          4. lift--.f64N/A

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

                            \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                          6. lift-/.f64N/A

                            \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                          7. lift-cos.f64N/A

                            \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                          8. lift-*.f64N/A

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

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

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

                            \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                        4. Applied rewrites99.9%

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

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

                            \[\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. *-commutativeN/A

                              \[\leadsto \mathsf{fma}\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), J, U\right) \]
                            12. 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({\ell}^{2}, \frac{1}{2520}, \frac{1}{60}\right)}, \frac{1}{3}\right), 2\right), J, U\right) \]
                            13. unpow2N/A

                              \[\leadsto \mathsf{fma}\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), J, U\right) \]
                            14. lower-*.f6490.6

                              \[\leadsto \mathsf{fma}\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), J, U\right) \]
                          4. Applied rewrites90.6%

                            \[\leadsto \mathsf{fma}\left(\color{blue}{\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)}, J, U\right) \]
                        7. Recombined 2 regimes into one program.
                        8. Add Preprocessing

                        Alternative 16: 81.7% accurate, 2.0× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\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), J, U\right)\\ \end{array} \end{array} \]
                        (FPCore (J l K U)
                         :precision binary64
                         (if (<= (cos (/ K 2.0)) -0.02)
                           (fma (* l (* -0.25 (* K K))) J U)
                           (fma
                            (*
                             l
                             (fma
                              (* l l)
                              (fma
                               (* l l)
                               (fma (* l l) 0.0003968253968253968 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.02) {
                        		tmp = fma((l * (-0.25 * (K * K))), J, U);
                        	} else {
                        		tmp = fma((l * fma((l * l), fma((l * l), fma((l * l), 0.0003968253968253968, 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.02)
                        		tmp = fma(Float64(l * Float64(-0.25 * Float64(K * K))), J, U);
                        	else
                        		tmp = fma(Float64(l * fma(Float64(l * l), fma(Float64(l * l), fma(Float64(l * l), 0.0003968253968253968, 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.02], N[(N[(l * N[(-0.25 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(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] * J + U), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
                        \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\mathsf{fma}\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), 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.0200000000000000004

                          1. Initial program 85.6%

                            \[\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. lift-exp.f64N/A

                              \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                            2. lift-neg.f64N/A

                              \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                            3. lift-exp.f64N/A

                              \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                            4. lift--.f64N/A

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

                              \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                            6. lift-/.f64N/A

                              \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                            7. lift-cos.f64N/A

                              \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                            8. lift-*.f64N/A

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

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

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

                              \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                          4. Applied rewrites100.0%

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

                            \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                          6. Step-by-step derivation
                            1. lower-*.f6463.0

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

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

                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell}, J, U\right) \]
                          9. Step-by-step derivation
                            1. associate-*r*N/A

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

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, -0.25, 2\right), J, U\right) \]
                          10. Applied rewrites60.8%

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \color{blue}{\left(K \cdot K\right)}\right), J, U\right) \]
                          13. Applied rewrites60.8%

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

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

                          1. Initial program 85.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. lift-exp.f64N/A

                              \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                            2. lift-neg.f64N/A

                              \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                            3. lift-exp.f64N/A

                              \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                            4. lift--.f64N/A

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

                              \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                            6. lift-/.f64N/A

                              \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                            7. lift-cos.f64N/A

                              \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                            8. lift-*.f64N/A

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

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

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

                              \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                          4. Applied rewrites99.9%

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

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

                              \[\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. *-commutativeN/A

                                \[\leadsto \mathsf{fma}\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), J, U\right) \]
                              12. 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({\ell}^{2}, \frac{1}{2520}, \frac{1}{60}\right)}, \frac{1}{3}\right), 2\right), J, U\right) \]
                              13. unpow2N/A

                                \[\leadsto \mathsf{fma}\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), J, U\right) \]
                              14. lower-*.f6490.6

                                \[\leadsto \mathsf{fma}\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), J, U\right) \]
                            4. Applied rewrites90.6%

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\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)}, J, U\right) \]
                          7. Recombined 2 regimes into one program.
                          8. Add Preprocessing

                          Alternative 17: 81.3% accurate, 2.0× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell, J \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right), U\right)\\ \end{array} \end{array} \]
                          (FPCore (J l K U)
                           :precision binary64
                           (if (<= (cos (/ K 2.0)) -0.02)
                             (fma (* l (* -0.25 (* K K))) J U)
                             (fma
                              l
                              (*
                               J
                               (fma
                                l
                                (*
                                 l
                                 (fma
                                  (* l l)
                                  (fma l (* l 0.0003968253968253968) 0.016666666666666666)
                                  0.3333333333333333))
                                2.0))
                              U)))
                          double code(double J, double l, double K, double U) {
                          	double tmp;
                          	if (cos((K / 2.0)) <= -0.02) {
                          		tmp = fma((l * (-0.25 * (K * K))), J, U);
                          	} else {
                          		tmp = fma(l, (J * fma(l, (l * fma((l * l), fma(l, (l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0)), U);
                          	}
                          	return tmp;
                          }
                          
                          function code(J, l, K, U)
                          	tmp = 0.0
                          	if (cos(Float64(K / 2.0)) <= -0.02)
                          		tmp = fma(Float64(l * Float64(-0.25 * Float64(K * K))), J, U);
                          	else
                          		tmp = fma(l, Float64(J * fma(l, Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0)), U);
                          	end
                          	return tmp
                          end
                          
                          code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(N[(l * N[(-0.25 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(l * N[(J * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.0003968253968253968), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
                          \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\mathsf{fma}\left(\ell, J \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 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.0200000000000000004

                            1. Initial program 85.6%

                              \[\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. lift-exp.f64N/A

                                \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              2. lift-neg.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              3. lift-exp.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              4. lift--.f64N/A

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

                                \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                              6. lift-/.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                              7. lift-cos.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                              8. lift-*.f64N/A

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

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

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

                                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                            4. Applied rewrites100.0%

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                            6. Step-by-step derivation
                              1. lower-*.f6463.0

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

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell}, J, U\right) \]
                            9. Step-by-step derivation
                              1. associate-*r*N/A

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

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

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, -0.25, 2\right), J, U\right) \]
                            10. Applied rewrites60.8%

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \color{blue}{\left(K \cdot K\right)}\right), J, U\right) \]
                            13. Applied rewrites60.8%

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

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

                            1. Initial program 85.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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + {\ell}^{2} \cdot \left(\frac{1}{2520} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{60} \cdot J\right)\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                            4. Step-by-step derivation
                              1. lower-*.f64N/A

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

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

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

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

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

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

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

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

                          Alternative 18: 80.3% accurate, 2.2× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), U\right)\\ \end{array} \end{array} \]
                          (FPCore (J l K U)
                           :precision binary64
                           (if (<= (cos (/ K 2.0)) -0.02)
                             (fma (* l (* -0.25 (* K K))) J U)
                             (fma
                              J
                              (*
                               l
                               (fma (* l l) (fma l (* l 0.016666666666666666) 0.3333333333333333) 2.0))
                              U)))
                          double code(double J, double l, double K, double U) {
                          	double tmp;
                          	if (cos((K / 2.0)) <= -0.02) {
                          		tmp = fma((l * (-0.25 * (K * K))), J, U);
                          	} else {
                          		tmp = fma(J, (l * fma((l * l), fma(l, (l * 0.016666666666666666), 0.3333333333333333), 2.0)), U);
                          	}
                          	return tmp;
                          }
                          
                          function code(J, l, K, U)
                          	tmp = 0.0
                          	if (cos(Float64(K / 2.0)) <= -0.02)
                          		tmp = fma(Float64(l * Float64(-0.25 * Float64(K * K))), J, U);
                          	else
                          		tmp = fma(J, Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0)), U);
                          	end
                          	return tmp
                          end
                          
                          code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(N[(l * N[(-0.25 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
                          \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 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.0200000000000000004

                            1. Initial program 85.6%

                              \[\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. lift-exp.f64N/A

                                \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              2. lift-neg.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              3. lift-exp.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              4. lift--.f64N/A

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

                                \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                              6. lift-/.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                              7. lift-cos.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                              8. lift-*.f64N/A

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

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

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

                                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                            4. Applied rewrites100.0%

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                            6. Step-by-step derivation
                              1. lower-*.f6463.0

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

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell}, J, U\right) \]
                            9. Step-by-step derivation
                              1. associate-*r*N/A

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

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

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, -0.25, 2\right), J, U\right) \]
                            10. Applied rewrites60.8%

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \color{blue}{\left(K \cdot K\right)}\right), J, U\right) \]
                            13. Applied rewrites60.8%

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

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

                            1. Initial program 85.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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{3} \cdot J\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                            4. Step-by-step derivation
                              1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          Alternative 19: 80.3% accurate, 2.2× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \left(\ell \cdot \ell\right) \cdot 0.016666666666666666, 2\right), U\right)\\ \end{array} \end{array} \]
                          (FPCore (J l K U)
                           :precision binary64
                           (if (<= (cos (/ K 2.0)) -0.02)
                             (fma (* l (* -0.25 (* K K))) J U)
                             (fma J (* l (fma (* l l) (* (* l l) 0.016666666666666666) 2.0)) U)))
                          double code(double J, double l, double K, double U) {
                          	double tmp;
                          	if (cos((K / 2.0)) <= -0.02) {
                          		tmp = fma((l * (-0.25 * (K * K))), J, U);
                          	} else {
                          		tmp = fma(J, (l * fma((l * l), ((l * l) * 0.016666666666666666), 2.0)), U);
                          	}
                          	return tmp;
                          }
                          
                          function code(J, l, K, U)
                          	tmp = 0.0
                          	if (cos(Float64(K / 2.0)) <= -0.02)
                          		tmp = fma(Float64(l * Float64(-0.25 * Float64(K * K))), J, U);
                          	else
                          		tmp = fma(J, Float64(l * fma(Float64(l * l), Float64(Float64(l * l) * 0.016666666666666666), 2.0)), U);
                          	end
                          	return tmp
                          end
                          
                          code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(N[(l * N[(-0.25 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
                          \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \left(\ell \cdot \ell\right) \cdot 0.016666666666666666, 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.0200000000000000004

                            1. Initial program 85.6%

                              \[\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. lift-exp.f64N/A

                                \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              2. lift-neg.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              3. lift-exp.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              4. lift--.f64N/A

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

                                \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                              6. lift-/.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                              7. lift-cos.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                              8. lift-*.f64N/A

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

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

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

                                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                            4. Applied rewrites100.0%

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                            6. Step-by-step derivation
                              1. lower-*.f6463.0

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

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell}, J, U\right) \]
                            9. Step-by-step derivation
                              1. associate-*r*N/A

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

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

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, -0.25, 2\right), J, U\right) \]
                            10. Applied rewrites60.8%

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \color{blue}{\left(K \cdot K\right)}\right), J, U\right) \]
                            13. Applied rewrites60.8%

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

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

                            1. Initial program 85.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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{3} \cdot J\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                            4. Step-by-step derivation
                              1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \color{blue}{\left(\ell \cdot \ell\right)} \cdot 0.016666666666666666, 2\right), U\right) \]
                            11. Applied rewrites89.6%

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

                          Alternative 20: 76.6% accurate, 2.4× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\ \end{array} \end{array} \]
                          (FPCore (J l K U)
                           :precision binary64
                           (if (<= (cos (/ K 2.0)) -0.02)
                             (fma (* l (* -0.25 (* K K))) J U)
                             (fma J (* l (fma l (* l 0.3333333333333333) 2.0)) U)))
                          double code(double J, double l, double K, double U) {
                          	double tmp;
                          	if (cos((K / 2.0)) <= -0.02) {
                          		tmp = fma((l * (-0.25 * (K * K))), J, U);
                          	} else {
                          		tmp = fma(J, (l * fma(l, (l * 0.3333333333333333), 2.0)), U);
                          	}
                          	return tmp;
                          }
                          
                          function code(J, l, K, U)
                          	tmp = 0.0
                          	if (cos(Float64(K / 2.0)) <= -0.02)
                          		tmp = fma(Float64(l * Float64(-0.25 * Float64(K * K))), J, U);
                          	else
                          		tmp = fma(J, Float64(l * fma(l, Float64(l * 0.3333333333333333), 2.0)), U);
                          	end
                          	return tmp
                          end
                          
                          code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(N[(l * N[(-0.25 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(J * N[(l * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
                          \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 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.0200000000000000004

                            1. Initial program 85.6%

                              \[\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. lift-exp.f64N/A

                                \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              2. lift-neg.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              3. lift-exp.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              4. lift--.f64N/A

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

                                \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                              6. lift-/.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                              7. lift-cos.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                              8. lift-*.f64N/A

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

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

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

                                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                            4. Applied rewrites100.0%

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                            6. Step-by-step derivation
                              1. lower-*.f6463.0

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

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell}, J, U\right) \]
                            9. Step-by-step derivation
                              1. associate-*r*N/A

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

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

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, -0.25, 2\right), J, U\right) \]
                            10. Applied rewrites60.8%

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \color{blue}{\left(K \cdot K\right)}\right), J, U\right) \]
                            13. Applied rewrites60.8%

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

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

                            1. Initial program 85.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}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{3} \cdot J\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                            4. Step-by-step derivation
                              1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          Alternative 21: 59.2% accurate, 2.4× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell, 2 \cdot J, U\right)\\ \end{array} \end{array} \]
                          (FPCore (J l K U)
                           :precision binary64
                           (if (<= (cos (/ K 2.0)) -0.02)
                             (fma (* l (* -0.25 (* K K))) J U)
                             (fma l (* 2.0 J) U)))
                          double code(double J, double l, double K, double U) {
                          	double tmp;
                          	if (cos((K / 2.0)) <= -0.02) {
                          		tmp = fma((l * (-0.25 * (K * K))), J, U);
                          	} else {
                          		tmp = fma(l, (2.0 * J), U);
                          	}
                          	return tmp;
                          }
                          
                          function code(J, l, K, U)
                          	tmp = 0.0
                          	if (cos(Float64(K / 2.0)) <= -0.02)
                          		tmp = fma(Float64(l * Float64(-0.25 * Float64(K * K))), J, U);
                          	else
                          		tmp = fma(l, Float64(2.0 * J), U);
                          	end
                          	return tmp
                          end
                          
                          code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(N[(l * N[(-0.25 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(l * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
                          \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right), J, U\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\mathsf{fma}\left(\ell, 2 \cdot 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.0200000000000000004

                            1. Initial program 85.6%

                              \[\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. lift-exp.f64N/A

                                \[\leadsto \left(J \cdot \left(\color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              2. lift-neg.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              3. lift-exp.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                              4. lift--.f64N/A

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

                                \[\leadsto \color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
                              6. lift-/.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)} + U \]
                              7. lift-cos.f64N/A

                                \[\leadsto \left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)} + U \]
                              8. lift-*.f64N/A

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

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

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

                                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
                            4. Applied rewrites100.0%

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                            6. Step-by-step derivation
                              1. lower-*.f6463.0

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

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell}, J, U\right) \]
                            9. Step-by-step derivation
                              1. associate-*r*N/A

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

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

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, -0.25, 2\right), J, U\right) \]
                            10. Applied rewrites60.8%

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\ell \cdot \left(-0.25 \cdot \color{blue}{\left(K \cdot K\right)}\right), J, U\right) \]
                            13. Applied rewrites60.8%

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

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

                            1. Initial program 85.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 + 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.3

                                \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                            5. Applied rewrites61.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. *-commutativeN/A

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

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

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

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

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

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

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

                          Alternative 22: 54.3% accurate, 27.5× speedup?

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

                              \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                          5. Applied rewrites61.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. *-commutativeN/A

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

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

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

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

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

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

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

                          Alternative 23: 19.7% accurate, 30.0× speedup?

                          \[\begin{array}{l} \\ J \cdot \left(2 \cdot \ell\right) \end{array} \]
                          (FPCore (J l K U) :precision binary64 (* J (* 2.0 l)))
                          double code(double J, double l, double K, double U) {
                          	return J * (2.0 * l);
                          }
                          
                          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 * (2.0d0 * l)
                          end function
                          
                          public static double code(double J, double l, double K, double U) {
                          	return J * (2.0 * l);
                          }
                          
                          def code(J, l, K, U):
                          	return J * (2.0 * l)
                          
                          function code(J, l, K, U)
                          	return Float64(J * Float64(2.0 * l))
                          end
                          
                          function tmp = code(J, l, K, U)
                          	tmp = J * (2.0 * l);
                          end
                          
                          code[J_, l_, K_, U_] := N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          J \cdot \left(2 \cdot \ell\right)
                          \end{array}
                          
                          Derivation
                          1. Initial program 85.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 + 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.6

                              \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                          5. Applied rewrites61.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. *-commutativeN/A

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

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

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

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

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

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

                            \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, 2 \cdot J, 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. *-commutativeN/A

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

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

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

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

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

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

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

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

                          Reproduce

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