Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.9% → 99.9%
Time: 12.8s
Alternatives: 26
Speedup: 1.5×

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 26 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.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\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 87.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-+.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} \]
    2. 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 \]
    3. 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 \]
    4. 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 \]
    5. *-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 \]
    6. 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: 72.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right)\\
t_1 := \mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+74}:\\
\;\;\;\;\mathsf{fma}\left(2, \ell \cdot J, U\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < -inf.0 or 1.9999999999999999e74 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U)

    1. Initial program 99.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-+.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} \]
      2. 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 \]
      3. 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 \]
      4. 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 \]
      5. *-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 \]
      6. 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 rewrites81.4%

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

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

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

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

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

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

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

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

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

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

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

        if -inf.0 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < 1.9999999999999999e74

        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. 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-*.f6499.9

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

          \[\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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
        7. Step-by-step derivation
          1. Applied rewrites86.1%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \leq -\infty:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\ \mathbf{elif}\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \leq 2 \cdot 10^{+74}:\\ \;\;\;\;\mathsf{fma}\left(2, \ell \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\ \end{array} \]
        10. Add Preprocessing

        Alternative 3: 58.8% accurate, 0.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right)\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\ell \cdot \mathsf{fma}\left(2, J, J \cdot \left(\left(K \cdot K\right) \cdot -0.25\right)\right)\\ \mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+303}:\\ \;\;\;\;\mathsf{fma}\left(2, \ell \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right)\\ \end{array} \end{array} \]
        (FPCore (J l K U)
         :precision binary64
         (let* ((t_0 (+ U (* (cos (/ K 2.0)) (* J (- (exp l) (exp (- l))))))))
           (if (<= t_0 (- INFINITY))
             (* l (fma 2.0 J (* J (* (* K K) -0.25))))
             (if (<= t_0 4e+303) (fma 2.0 (* l J) U) (* J (fma 2.0 l (/ U J)))))))
        double code(double J, double l, double K, double U) {
        	double t_0 = U + (cos((K / 2.0)) * (J * (exp(l) - exp(-l))));
        	double tmp;
        	if (t_0 <= -((double) INFINITY)) {
        		tmp = l * fma(2.0, J, (J * ((K * K) * -0.25)));
        	} else if (t_0 <= 4e+303) {
        		tmp = fma(2.0, (l * J), U);
        	} else {
        		tmp = J * fma(2.0, l, (U / J));
        	}
        	return tmp;
        }
        
        function code(J, l, K, U)
        	t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(exp(l) - exp(Float64(-l))))))
        	tmp = 0.0
        	if (t_0 <= Float64(-Inf))
        		tmp = Float64(l * fma(2.0, J, Float64(J * Float64(Float64(K * K) * -0.25))));
        	elseif (t_0 <= 4e+303)
        		tmp = fma(2.0, Float64(l * J), U);
        	else
        		tmp = Float64(J * fma(2.0, l, Float64(U / J)));
        	end
        	return tmp
        end
        
        code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(l * N[(2.0 * J + N[(J * N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+303], N[(2.0 * N[(l * J), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(2.0 * l + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right)\\
        \mathbf{if}\;t\_0 \leq -\infty:\\
        \;\;\;\;\ell \cdot \mathsf{fma}\left(2, J, J \cdot \left(\left(K \cdot K\right) \cdot -0.25\right)\right)\\
        
        \mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+303}:\\
        \;\;\;\;\mathsf{fma}\left(2, \ell \cdot J, U\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < -inf.0

          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. 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-*.f6425.5

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

            \[\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 U + \color{blue}{\left(2 \cdot \left(J \cdot \ell\right) + {K}^{2} \cdot \left(\frac{-1}{4} \cdot \left(J \cdot \ell\right) + {K}^{2} \cdot \left(\frac{-1}{23040} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + \frac{1}{192} \cdot \left(J \cdot \ell\right)\right)\right)\right)} \]
          7. Step-by-step derivation
            1. Applied rewrites16.3%

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

              \[\leadsto J \cdot \left(2 \cdot \ell + \color{blue}{{K}^{2} \cdot \left(\frac{-1}{4} \cdot \ell + {K}^{2} \cdot \left(\ell \cdot \left(\frac{1}{192} + \frac{-1}{23040} \cdot {K}^{2}\right)\right)\right)}\right) \]
            3. Step-by-step derivation
              1. Applied rewrites29.8%

                \[\leadsto \ell \cdot \mathsf{fma}\left(2, \color{blue}{J}, \left(K \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(K, K \cdot \mathsf{fma}\left(K \cdot K, -4.340277777777778 \cdot 10^{-5}, 0.005208333333333333\right), -0.25\right)\right)\right) \]
              2. Taylor expanded in K around 0

                \[\leadsto \ell \cdot \mathsf{fma}\left(2, J, \frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right)\right) \]
              3. Step-by-step derivation
                1. Applied rewrites27.2%

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

                if -inf.0 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < 4e303

                1. Initial program 72.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 + 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-*.f6499.9

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

                  \[\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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                7. Step-by-step derivation
                  1. Applied rewrites88.1%

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

                  if 4e303 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U)

                  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. 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-*.f6423.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 rewrites23.0%

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

                    \[\leadsto U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                  7. Step-by-step derivation
                    1. Applied rewrites19.8%

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

                      \[\leadsto J \cdot \left(2 \cdot \ell + \color{blue}{\frac{U}{J}}\right) \]
                    3. Step-by-step derivation
                      1. Applied rewrites30.4%

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

                      \[\leadsto \begin{array}{l} \mathbf{if}\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \leq -\infty:\\ \;\;\;\;\ell \cdot \mathsf{fma}\left(2, J, J \cdot \left(\left(K \cdot K\right) \cdot -0.25\right)\right)\\ \mathbf{elif}\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \leq 4 \cdot 10^{+303}:\\ \;\;\;\;\mathsf{fma}\left(2, \ell \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right)\\ \end{array} \]
                    6. Add Preprocessing

                    Alternative 4: 58.8% accurate, 0.5× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right)\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot J, \mathsf{fma}\left(-0.25, K \cdot K, 2\right), U\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-93}:\\ \;\;\;\;\mathsf{fma}\left(2, \ell \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right)\\ \end{array} \end{array} \]
                    (FPCore (J l K U)
                     :precision binary64
                     (let* ((t_0 (* (cos (/ K 2.0)) (* J (- (exp l) (exp (- l)))))))
                       (if (<= t_0 (- INFINITY))
                         (fma (* l J) (fma -0.25 (* K K) 2.0) U)
                         (if (<= t_0 5e-93) (fma 2.0 (* l J) U) (* J (fma 2.0 l (/ U J)))))))
                    double code(double J, double l, double K, double U) {
                    	double t_0 = cos((K / 2.0)) * (J * (exp(l) - exp(-l)));
                    	double tmp;
                    	if (t_0 <= -((double) INFINITY)) {
                    		tmp = fma((l * J), fma(-0.25, (K * K), 2.0), U);
                    	} else if (t_0 <= 5e-93) {
                    		tmp = fma(2.0, (l * J), U);
                    	} else {
                    		tmp = J * fma(2.0, l, (U / J));
                    	}
                    	return tmp;
                    }
                    
                    function code(J, l, K, U)
                    	t_0 = Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(exp(l) - exp(Float64(-l)))))
                    	tmp = 0.0
                    	if (t_0 <= Float64(-Inf))
                    		tmp = fma(Float64(l * J), fma(-0.25, Float64(K * K), 2.0), U);
                    	elseif (t_0 <= 5e-93)
                    		tmp = fma(2.0, Float64(l * J), U);
                    	else
                    		tmp = Float64(J * fma(2.0, l, Float64(U / J)));
                    	end
                    	return tmp
                    end
                    
                    code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(l * J), $MachinePrecision] * N[(-0.25 * N[(K * K), $MachinePrecision] + 2.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 5e-93], N[(2.0 * N[(l * J), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(2.0 * l + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    t_0 := \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right)\\
                    \mathbf{if}\;t\_0 \leq -\infty:\\
                    \;\;\;\;\mathsf{fma}\left(\ell \cdot J, \mathsf{fma}\left(-0.25, K \cdot K, 2\right), U\right)\\
                    
                    \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-93}:\\
                    \;\;\;\;\mathsf{fma}\left(2, \ell \cdot J, U\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right)\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 3 regimes
                    2. if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < -inf.0

                      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. 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-*.f6425.5

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

                        \[\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 U + \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                      7. Step-by-step derivation
                        1. Applied rewrites27.1%

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

                        if -inf.0 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < 4.99999999999999994e-93

                        1. Initial program 73.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-*.f6499.9

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

                          \[\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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                        7. Step-by-step derivation
                          1. Applied rewrites88.0%

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

                          if 4.99999999999999994e-93 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64))))

                          1. Initial program 99.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}{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-*.f6424.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 rewrites24.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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                          7. Step-by-step derivation
                            1. Applied rewrites20.9%

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

                              \[\leadsto J \cdot \left(2 \cdot \ell + \color{blue}{\frac{U}{J}}\right) \]
                            3. Step-by-step derivation
                              1. Applied rewrites31.4%

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

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

                            Alternative 5: 95.9% 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:\\ \;\;\;\;U + t\_0 \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)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot 1, 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.02)
                                 (+
                                  U
                                  (*
                                   t_0
                                   (*
                                    J
                                    (*
                                     l
                                     (fma
                                      (* l l)
                                      (fma
                                       l
                                       (* l (fma (* l l) 0.0003968253968253968 0.016666666666666666))
                                       0.3333333333333333)
                                      2.0)))))
                                 (fma (* (* 2.0 (sinh l)) 1.0) 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.02) {
                            		tmp = U + (t_0 * (J * (l * fma((l * l), fma(l, (l * fma((l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333), 2.0))));
                            	} else {
                            		tmp = fma(((2.0 * sinh(l)) * 1.0), J, 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 = Float64(U + Float64(t_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)))));
                            	else
                            		tmp = fma(Float64(Float64(2.0 * sinh(l)) * 1.0), 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.02], N[(U + N[(t$95$0 * 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], N[(N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] * J + U), $MachinePrecision]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_0 := \cos \left(\frac{K}{2}\right)\\
                            \mathbf{if}\;t\_0 \leq 0.02:\\
                            \;\;\;\;U + t\_0 \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)\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot 1, 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 87.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 \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-*.f6497.2

                                  \[\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 rewrites97.2%

                                \[\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 \]

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

                              1. Initial program 87.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-+.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} \]
                                2. 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 \]
                                3. 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 \]
                                4. 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 \]
                                5. *-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 \]
                                6. 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 rewrites97.2%

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

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

                              Alternative 6: 76.7% accurate, 1.2× speedup?

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

                                1. Initial program 88.3%

                                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                2. Add Preprocessing
                                3. Step-by-step derivation
                                  1. 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} \]
                                  2. 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 \]
                                  3. 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 \]
                                  4. 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 \]
                                  5. *-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 \]
                                  6. 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 rewrites44.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  if -2e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.5

                                  1. Initial program 94.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    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-+.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} \]
                                      2. 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 \]
                                      3. 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 \]
                                      4. 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 \]
                                      5. *-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 \]
                                      6. 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 rewrites97.1%

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

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

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

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

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

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

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

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

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

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

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

                                    Alternative 7: 75.3% accurate, 1.2× speedup?

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

                                      1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + J \cdot \ell, 2, U\right) \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites58.9%

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

                                          if -2e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.5

                                          1. Initial program 94.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            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-+.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} \]
                                              2. 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 \]
                                              3. 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 \]
                                              4. 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 \]
                                              5. *-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 \]
                                              6. 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 rewrites97.1%

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

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

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

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

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

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

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

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

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

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

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

                                            Alternative 8: 75.3% accurate, 1.2× speedup?

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

                                              1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + J \cdot \ell, 2, U\right) \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites58.9%

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

                                                  if -2e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.5

                                                  1. Initial program 94.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \mathsf{fma}\left(\frac{1}{384} \cdot {K}^{4}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites73.6%

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

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

                                                      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-+.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} \]
                                                        2. 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 \]
                                                        3. 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 \]
                                                        4. 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 \]
                                                        5. *-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 \]
                                                        6. 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 rewrites97.1%

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

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

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

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

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

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

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

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

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

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

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

                                                      Alternative 9: 95.4% 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:\\ \;\;\;\;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(\left(2 \cdot \sinh \ell\right) \cdot 1, 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.02)
                                                           (+
                                                            U
                                                            (*
                                                             t_0
                                                             (*
                                                              J
                                                              (*
                                                               l
                                                               (fma
                                                                (* l l)
                                                                (fma (* l l) 0.016666666666666666 0.3333333333333333)
                                                                2.0)))))
                                                           (fma (* (* 2.0 (sinh l)) 1.0) 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.02) {
                                                      		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)) * 1.0), J, 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 = 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(Float64(2.0 * sinh(l)) * 1.0), 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.02], 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[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] * J + U), $MachinePrecision]]]
                                                      
                                                      \begin{array}{l}
                                                      
                                                      \\
                                                      \begin{array}{l}
                                                      t_0 := \cos \left(\frac{K}{2}\right)\\
                                                      \mathbf{if}\;t\_0 \leq 0.02:\\
                                                      \;\;\;\;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(\left(2 \cdot \sinh \ell\right) \cdot 1, 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 87.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 \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.4

                                                            \[\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.4%

                                                          \[\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.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                        1. Initial program 87.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-+.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} \]
                                                          2. 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 \]
                                                          3. 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 \]
                                                          4. 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 \]
                                                          5. *-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 \]
                                                          6. 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 rewrites97.2%

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

                                                          \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.02:\\ \;\;\;\;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(\left(2 \cdot \sinh \ell\right) \cdot 1, J, U\right)\\ \end{array} \]
                                                        9. Add Preprocessing

                                                        Alternative 10: 93.9% accurate, 1.3× speedup?

                                                        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -0.002:\\ \;\;\;\;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(\left(2 \cdot \sinh \ell\right) \cdot 1, 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.002)
                                                             (+ U (* t_0 (* J (* l (fma l (* l 0.3333333333333333) 2.0)))))
                                                             (fma (* (* 2.0 (sinh l)) 1.0) 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.002) {
                                                        		tmp = U + (t_0 * (J * (l * fma(l, (l * 0.3333333333333333), 2.0))));
                                                        	} else {
                                                        		tmp = fma(((2.0 * sinh(l)) * 1.0), J, U);
                                                        	}
                                                        	return tmp;
                                                        }
                                                        
                                                        function code(J, l, K, U)
                                                        	t_0 = cos(Float64(K / 2.0))
                                                        	tmp = 0.0
                                                        	if (t_0 <= -0.002)
                                                        		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * fma(l, Float64(l * 0.3333333333333333), 2.0)))));
                                                        	else
                                                        		tmp = fma(Float64(Float64(2.0 * sinh(l)) * 1.0), 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.002], 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[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] * J + U), $MachinePrecision]]]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        \begin{array}{l}
                                                        t_0 := \cos \left(\frac{K}{2}\right)\\
                                                        \mathbf{if}\;t\_0 \leq -0.002:\\
                                                        \;\;\;\;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(\left(2 \cdot \sinh \ell\right) \cdot 1, J, U\right)\\
                                                        
                                                        
                                                        \end{array}
                                                        \end{array}
                                                        
                                                        Derivation
                                                        1. Split input into 2 regimes
                                                        2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -2e-3

                                                          1. Initial program 88.3%

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

                                                            \[\leadsto \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-*.f6492.7

                                                              \[\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 rewrites92.7%

                                                            \[\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 -2e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                          1. Initial program 87.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-+.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} \]
                                                            2. 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 \]
                                                            3. 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 \]
                                                            4. 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 \]
                                                            5. *-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 \]
                                                            6. 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) \]
                                                          7. Recombined 2 regimes into one program.
                                                          8. Final simplification95.7%

                                                            \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.002:\\ \;\;\;\;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(\left(2 \cdot \sinh \ell\right) \cdot 1, J, U\right)\\ \end{array} \]
                                                          9. Add Preprocessing

                                                          Alternative 11: 93.3% accurate, 1.3× speedup?

                                                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -0.002:\\ \;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot 1, 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.002)
                                                               (+ U (* t_0 (* l (* J (fma l (* l 0.3333333333333333) 2.0)))))
                                                               (fma (* (* 2.0 (sinh l)) 1.0) 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.002) {
                                                          		tmp = U + (t_0 * (l * (J * fma(l, (l * 0.3333333333333333), 2.0))));
                                                          	} else {
                                                          		tmp = fma(((2.0 * sinh(l)) * 1.0), J, U);
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          function code(J, l, K, U)
                                                          	t_0 = cos(Float64(K / 2.0))
                                                          	tmp = 0.0
                                                          	if (t_0 <= -0.002)
                                                          		tmp = Float64(U + Float64(t_0 * Float64(l * Float64(J * fma(l, Float64(l * 0.3333333333333333), 2.0)))));
                                                          	else
                                                          		tmp = fma(Float64(Float64(2.0 * sinh(l)) * 1.0), 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.002], N[(U + N[(t$95$0 * N[(l * N[(J * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] * J + U), $MachinePrecision]]]
                                                          
                                                          \begin{array}{l}
                                                          
                                                          \\
                                                          \begin{array}{l}
                                                          t_0 := \cos \left(\frac{K}{2}\right)\\
                                                          \mathbf{if}\;t\_0 \leq -0.002:\\
                                                          \;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right)\right)\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot 1, J, U\right)\\
                                                          
                                                          
                                                          \end{array}
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 2 regimes
                                                          2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -2e-3

                                                            1. Initial program 88.3%

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

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

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

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

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

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

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

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

                                                                \[\leadsto \left(\ell \cdot \left(J \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 \]
                                                              9. associate-*r*N/A

                                                                \[\leadsto \left(\ell \cdot \left(J \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 \]
                                                              10. *-commutativeN/A

                                                                \[\leadsto \left(\ell \cdot \left(J \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 \]
                                                              11. lower-fma.f64N/A

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

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

                                                                \[\leadsto \left(\ell \cdot \left(J \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 rewrites87.0%

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

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

                                                            1. Initial program 87.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-+.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} \]
                                                              2. 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 \]
                                                              3. 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 \]
                                                              4. 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 \]
                                                              5. *-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 \]
                                                              6. 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) \]
                                                            7. Recombined 2 regimes into one program.
                                                            8. Final simplification94.2%

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

                                                            Alternative 12: 93.3% accurate, 1.3× speedup?

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

                                                              1. Initial program 88.3%

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

                                                                \[\leadsto \color{blue}{U + \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 rewrites87.0%

                                                                \[\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 -2e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                              1. Initial program 87.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-+.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} \]
                                                                2. 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 \]
                                                                3. 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 \]
                                                                4. 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 \]
                                                                5. *-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 \]
                                                                6. 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) \]
                                                              7. Recombined 2 regimes into one program.
                                                              8. Final simplification94.2%

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

                                                              Alternative 13: 87.7% accurate, 1.4× speedup?

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

                                                                1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                1. Initial program 87.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-+.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} \]
                                                                  2. 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 \]
                                                                  3. 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 \]
                                                                  4. 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 \]
                                                                  5. *-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 \]
                                                                  6. 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) \]
                                                                7. Recombined 2 regimes into one program.
                                                                8. Final simplification89.4%

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

                                                                Alternative 14: 87.5% accurate, 1.4× speedup?

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

                                                                  1. Initial program 88.3%

                                                                    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                                  2. Add Preprocessing
                                                                  3. Step-by-step derivation
                                                                    1. 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} \]
                                                                    2. 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 \]
                                                                    3. 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 \]
                                                                    4. 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 \]
                                                                    5. *-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 \]
                                                                    6. 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 rewrites44.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                    1. Initial program 87.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-+.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} \]
                                                                      2. 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 \]
                                                                      3. 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 \]
                                                                      4. 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 \]
                                                                      5. *-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 \]
                                                                      6. 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) \]
                                                                    7. Recombined 2 regimes into one program.
                                                                    8. Add Preprocessing

                                                                    Alternative 15: 84.1% accurate, 1.9× speedup?

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

                                                                      1. Initial program 88.3%

                                                                        \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                                      2. Add Preprocessing
                                                                      3. Step-by-step derivation
                                                                        1. 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} \]
                                                                        2. 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 \]
                                                                        3. 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 \]
                                                                        4. 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 \]
                                                                        5. *-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 \]
                                                                        6. 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 rewrites44.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                        1. Initial program 87.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-+.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} \]
                                                                          2. 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 \]
                                                                          3. 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 \]
                                                                          4. 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 \]
                                                                          5. *-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 \]
                                                                          6. 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. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right)} \cdot 1, J, U\right) \]
                                                                        7. Recombined 2 regimes into one program.
                                                                        8. Final simplification81.3%

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

                                                                        Alternative 16: 83.6% accurate, 2.0× speedup?

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

                                                                          1. Initial program 88.3%

                                                                            \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                                          2. Add Preprocessing
                                                                          3. Step-by-step derivation
                                                                            1. 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} \]
                                                                            2. 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 \]
                                                                            3. 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 \]
                                                                            4. 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 \]
                                                                            5. *-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 \]
                                                                            6. 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 rewrites44.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                            1. Initial program 87.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-+.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} \]
                                                                              2. 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 \]
                                                                              3. 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 \]
                                                                              4. 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 \]
                                                                              5. *-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 \]
                                                                              6. 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. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                            Alternative 17: 83.6% accurate, 2.0× speedup?

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

                                                                              1. Initial program 88.3%

                                                                                \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                                              2. Add Preprocessing
                                                                              3. Step-by-step derivation
                                                                                1. 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} \]
                                                                                2. 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 \]
                                                                                3. 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 \]
                                                                                4. 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 \]
                                                                                5. *-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 \]
                                                                                6. 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 rewrites44.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                1. Initial program 87.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-+.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} \]
                                                                                  2. 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 \]
                                                                                  3. 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 \]
                                                                                  4. 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 \]
                                                                                  5. *-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 \]
                                                                                  6. 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. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                  Alternative 18: 82.1% accurate, 2.1× speedup?

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

                                                                                    1. Initial program 88.3%

                                                                                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                                                    2. Add Preprocessing
                                                                                    3. Step-by-step derivation
                                                                                      1. 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} \]
                                                                                      2. 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 \]
                                                                                      3. 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 \]
                                                                                      4. 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 \]
                                                                                      5. *-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 \]
                                                                                      6. 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 rewrites44.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                      1. Initial program 87.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-+.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} \]
                                                                                        2. 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 \]
                                                                                        3. 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 \]
                                                                                        4. 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 \]
                                                                                        5. *-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 \]
                                                                                        6. 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. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

                                                                                            \[\leadsto \mathsf{fma}\left(\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) \cdot 1, J, U\right) \]
                                                                                        4. Applied rewrites86.1%

                                                                                          \[\leadsto \mathsf{fma}\left(\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)} \cdot 1, J, U\right) \]
                                                                                      7. Recombined 2 regimes into one program.
                                                                                      8. Final simplification79.4%

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

                                                                                      Alternative 19: 77.3% accurate, 2.2× speedup?

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

                                                                                        1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                            \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + J \cdot \ell, 2, U\right) \]
                                                                                          3. Step-by-step derivation
                                                                                            1. Applied rewrites58.9%

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

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

                                                                                            1. Initial program 87.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-+.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} \]
                                                                                              2. 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 \]
                                                                                              3. 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 \]
                                                                                              4. 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 \]
                                                                                              5. *-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 \]
                                                                                              6. 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. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

                                                                                            Alternative 20: 75.3% accurate, 2.3× speedup?

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

                                                                                              1. Initial program 89.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-*.f6464.7

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

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

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

                                                                                                  \[\leadsto \mathsf{fma}\left(\left(J + \frac{-1}{8} \cdot \left(J \cdot {K}^{2}\right)\right) \cdot \ell, 2, U\right) \]
                                                                                                3. Step-by-step derivation
                                                                                                  1. Applied rewrites60.4%

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

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

                                                                                                  1. Initial program 87.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-+.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} \]
                                                                                                    2. 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 \]
                                                                                                    3. 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 \]
                                                                                                    4. 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 \]
                                                                                                    5. *-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 \]
                                                                                                    6. 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 rewrites92.9%

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

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

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

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

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

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

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

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

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

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

                                                                                                  Alternative 21: 71.4% accurate, 8.2× speedup?

                                                                                                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\ \mathbf{if}\;\ell \leq -6 \cdot 10^{+24}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 1.46 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(U, \frac{2 \cdot \left(\ell \cdot J\right)}{U}, U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                                                                                  (FPCore (J l K U)
                                                                                                   :precision binary64
                                                                                                   (let* ((t_0 (fma (* 1.0 (* l (* (* l l) 0.3333333333333333))) J U)))
                                                                                                     (if (<= l -6e+24)
                                                                                                       t_0
                                                                                                       (if (<= l 1.46e-9) (fma U (/ (* 2.0 (* l J)) U) U) t_0))))
                                                                                                  double code(double J, double l, double K, double U) {
                                                                                                  	double t_0 = fma((1.0 * (l * ((l * l) * 0.3333333333333333))), J, U);
                                                                                                  	double tmp;
                                                                                                  	if (l <= -6e+24) {
                                                                                                  		tmp = t_0;
                                                                                                  	} else if (l <= 1.46e-9) {
                                                                                                  		tmp = fma(U, ((2.0 * (l * J)) / U), U);
                                                                                                  	} else {
                                                                                                  		tmp = t_0;
                                                                                                  	}
                                                                                                  	return tmp;
                                                                                                  }
                                                                                                  
                                                                                                  function code(J, l, K, U)
                                                                                                  	t_0 = fma(Float64(1.0 * Float64(l * Float64(Float64(l * l) * 0.3333333333333333))), J, U)
                                                                                                  	tmp = 0.0
                                                                                                  	if (l <= -6e+24)
                                                                                                  		tmp = t_0;
                                                                                                  	elseif (l <= 1.46e-9)
                                                                                                  		tmp = fma(U, Float64(Float64(2.0 * Float64(l * J)) / U), U);
                                                                                                  	else
                                                                                                  		tmp = t_0;
                                                                                                  	end
                                                                                                  	return tmp
                                                                                                  end
                                                                                                  
                                                                                                  code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(1.0 * N[(l * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]}, If[LessEqual[l, -6e+24], t$95$0, If[LessEqual[l, 1.46e-9], N[(U * N[(N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision] + U), $MachinePrecision], t$95$0]]]
                                                                                                  
                                                                                                  \begin{array}{l}
                                                                                                  
                                                                                                  \\
                                                                                                  \begin{array}{l}
                                                                                                  t_0 := \mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\
                                                                                                  \mathbf{if}\;\ell \leq -6 \cdot 10^{+24}:\\
                                                                                                  \;\;\;\;t\_0\\
                                                                                                  
                                                                                                  \mathbf{elif}\;\ell \leq 1.46 \cdot 10^{-9}:\\
                                                                                                  \;\;\;\;\mathsf{fma}\left(U, \frac{2 \cdot \left(\ell \cdot J\right)}{U}, U\right)\\
                                                                                                  
                                                                                                  \mathbf{else}:\\
                                                                                                  \;\;\;\;t\_0\\
                                                                                                  
                                                                                                  
                                                                                                  \end{array}
                                                                                                  \end{array}
                                                                                                  
                                                                                                  Derivation
                                                                                                  1. Split input into 2 regimes
                                                                                                  2. if l < -5.9999999999999999e24 or 1.4599999999999999e-9 < 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-+.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} \]
                                                                                                      2. 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 \]
                                                                                                      3. 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 \]
                                                                                                      4. 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 \]
                                                                                                      5. *-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 \]
                                                                                                      6. 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 rewrites79.2%

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

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

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

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

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

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

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

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

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

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

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

                                                                                                        if -5.9999999999999999e24 < l < 1.4599999999999999e-9

                                                                                                        1. Initial program 75.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}{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-*.f6489.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 rewrites89.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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                                                                        7. Step-by-step derivation
                                                                                                          1. Applied rewrites78.8%

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

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

                                                                                                              \[\leadsto U \cdot \left(1 + \color{blue}{2 \cdot \frac{J \cdot \ell}{U}}\right) \]
                                                                                                            3. Step-by-step derivation
                                                                                                              1. Applied rewrites80.8%

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

                                                                                                              \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6 \cdot 10^{+24}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 1.46 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(U, \frac{2 \cdot \left(\ell \cdot J\right)}{U}, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\ \end{array} \]
                                                                                                            6. Add Preprocessing

                                                                                                            Alternative 22: 71.4% accurate, 8.2× speedup?

                                                                                                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\ \mathbf{if}\;\ell \leq -6 \cdot 10^{+24}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 1.46 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(U, \frac{\ell \cdot \left(2 \cdot J\right)}{U}, U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                                                                                            (FPCore (J l K U)
                                                                                                             :precision binary64
                                                                                                             (let* ((t_0 (fma (* 1.0 (* l (* (* l l) 0.3333333333333333))) J U)))
                                                                                                               (if (<= l -6e+24)
                                                                                                                 t_0
                                                                                                                 (if (<= l 1.46e-9) (fma U (/ (* l (* 2.0 J)) U) U) t_0))))
                                                                                                            double code(double J, double l, double K, double U) {
                                                                                                            	double t_0 = fma((1.0 * (l * ((l * l) * 0.3333333333333333))), J, U);
                                                                                                            	double tmp;
                                                                                                            	if (l <= -6e+24) {
                                                                                                            		tmp = t_0;
                                                                                                            	} else if (l <= 1.46e-9) {
                                                                                                            		tmp = fma(U, ((l * (2.0 * J)) / U), U);
                                                                                                            	} else {
                                                                                                            		tmp = t_0;
                                                                                                            	}
                                                                                                            	return tmp;
                                                                                                            }
                                                                                                            
                                                                                                            function code(J, l, K, U)
                                                                                                            	t_0 = fma(Float64(1.0 * Float64(l * Float64(Float64(l * l) * 0.3333333333333333))), J, U)
                                                                                                            	tmp = 0.0
                                                                                                            	if (l <= -6e+24)
                                                                                                            		tmp = t_0;
                                                                                                            	elseif (l <= 1.46e-9)
                                                                                                            		tmp = fma(U, Float64(Float64(l * Float64(2.0 * J)) / U), U);
                                                                                                            	else
                                                                                                            		tmp = t_0;
                                                                                                            	end
                                                                                                            	return tmp
                                                                                                            end
                                                                                                            
                                                                                                            code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(1.0 * N[(l * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]}, If[LessEqual[l, -6e+24], t$95$0, If[LessEqual[l, 1.46e-9], N[(U * N[(N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision] + U), $MachinePrecision], t$95$0]]]
                                                                                                            
                                                                                                            \begin{array}{l}
                                                                                                            
                                                                                                            \\
                                                                                                            \begin{array}{l}
                                                                                                            t_0 := \mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\
                                                                                                            \mathbf{if}\;\ell \leq -6 \cdot 10^{+24}:\\
                                                                                                            \;\;\;\;t\_0\\
                                                                                                            
                                                                                                            \mathbf{elif}\;\ell \leq 1.46 \cdot 10^{-9}:\\
                                                                                                            \;\;\;\;\mathsf{fma}\left(U, \frac{\ell \cdot \left(2 \cdot J\right)}{U}, U\right)\\
                                                                                                            
                                                                                                            \mathbf{else}:\\
                                                                                                            \;\;\;\;t\_0\\
                                                                                                            
                                                                                                            
                                                                                                            \end{array}
                                                                                                            \end{array}
                                                                                                            
                                                                                                            Derivation
                                                                                                            1. Split input into 2 regimes
                                                                                                            2. if l < -5.9999999999999999e24 or 1.4599999999999999e-9 < 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-+.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} \]
                                                                                                                2. 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 \]
                                                                                                                3. 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 \]
                                                                                                                4. 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 \]
                                                                                                                5. *-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 \]
                                                                                                                6. 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 rewrites79.2%

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

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

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

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

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

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

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

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

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

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

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

                                                                                                                  if -5.9999999999999999e24 < l < 1.4599999999999999e-9

                                                                                                                  1. Initial program 75.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}{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-*.f6489.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 rewrites89.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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                                                                                  7. Step-by-step derivation
                                                                                                                    1. Applied rewrites78.8%

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

                                                                                                                      \[\leadsto U \cdot \left(1 + \color{blue}{2 \cdot \frac{J \cdot \ell}{U}}\right) \]
                                                                                                                    3. Step-by-step derivation
                                                                                                                      1. Applied rewrites80.1%

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

                                                                                                                      \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6 \cdot 10^{+24}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 1.46 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(U, \frac{\ell \cdot \left(2 \cdot J\right)}{U}, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right), J, U\right)\\ \end{array} \]
                                                                                                                    6. Add Preprocessing

                                                                                                                    Alternative 23: 55.5% accurate, 11.4× speedup?

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

                                                                                                                      1. Initial program 83.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}{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-*.f6469.8

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

                                                                                                                        \[\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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                                                                                      7. Step-by-step derivation
                                                                                                                        1. Applied rewrites60.9%

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

                                                                                                                        if 3.7e18 < 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. 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-*.f6426.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 rewrites26.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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                                                                                        7. Step-by-step derivation
                                                                                                                          1. Applied rewrites19.1%

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

                                                                                                                            \[\leadsto J \cdot \left(2 \cdot \ell + \color{blue}{\frac{U}{J}}\right) \]
                                                                                                                          3. Step-by-step derivation
                                                                                                                            1. Applied rewrites31.4%

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

                                                                                                                            \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 3.7 \cdot 10^{+18}:\\ \;\;\;\;\mathsf{fma}\left(2, \ell \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right)\\ \end{array} \]
                                                                                                                          6. Add Preprocessing

                                                                                                                          Alternative 24: 54.1% accurate, 27.5× speedup?

                                                                                                                          \[\begin{array}{l} \\ \mathsf{fma}\left(2, \ell \cdot J, U\right) \end{array} \]
                                                                                                                          (FPCore (J l K U) :precision binary64 (fma 2.0 (* l J) U))
                                                                                                                          double code(double J, double l, double K, double U) {
                                                                                                                          	return fma(2.0, (l * J), U);
                                                                                                                          }
                                                                                                                          
                                                                                                                          function code(J, l, K, U)
                                                                                                                          	return fma(2.0, Float64(l * J), U)
                                                                                                                          end
                                                                                                                          
                                                                                                                          code[J_, l_, K_, U_] := N[(2.0 * N[(l * J), $MachinePrecision] + U), $MachinePrecision]
                                                                                                                          
                                                                                                                          \begin{array}{l}
                                                                                                                          
                                                                                                                          \\
                                                                                                                          \mathsf{fma}\left(2, \ell \cdot J, U\right)
                                                                                                                          \end{array}
                                                                                                                          
                                                                                                                          Derivation
                                                                                                                          1. Initial program 87.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}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                                                                                          4. Step-by-step derivation
                                                                                                                            1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                                            \[\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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                                                                                          7. Step-by-step derivation
                                                                                                                            1. Applied rewrites50.9%

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

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

                                                                                                                            Alternative 25: 19.0% accurate, 30.0× speedup?

                                                                                                                            \[\begin{array}{l} \\ 2 \cdot \left(\ell \cdot J\right) \end{array} \]
                                                                                                                            (FPCore (J l K U) :precision binary64 (* 2.0 (* l J)))
                                                                                                                            double code(double J, double l, double K, double U) {
                                                                                                                            	return 2.0 * (l * J);
                                                                                                                            }
                                                                                                                            
                                                                                                                            real(8) function code(j, l, k, u)
                                                                                                                                real(8), intent (in) :: j
                                                                                                                                real(8), intent (in) :: l
                                                                                                                                real(8), intent (in) :: k
                                                                                                                                real(8), intent (in) :: u
                                                                                                                                code = 2.0d0 * (l * j)
                                                                                                                            end function
                                                                                                                            
                                                                                                                            public static double code(double J, double l, double K, double U) {
                                                                                                                            	return 2.0 * (l * J);
                                                                                                                            }
                                                                                                                            
                                                                                                                            def code(J, l, K, U):
                                                                                                                            	return 2.0 * (l * J)
                                                                                                                            
                                                                                                                            function code(J, l, K, U)
                                                                                                                            	return Float64(2.0 * Float64(l * J))
                                                                                                                            end
                                                                                                                            
                                                                                                                            function tmp = code(J, l, K, U)
                                                                                                                            	tmp = 2.0 * (l * J);
                                                                                                                            end
                                                                                                                            
                                                                                                                            code[J_, l_, K_, U_] := N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]
                                                                                                                            
                                                                                                                            \begin{array}{l}
                                                                                                                            
                                                                                                                            \\
                                                                                                                            2 \cdot \left(\ell \cdot J\right)
                                                                                                                            \end{array}
                                                                                                                            
                                                                                                                            Derivation
                                                                                                                            1. Initial program 87.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}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                                                                                            4. Step-by-step derivation
                                                                                                                              1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                                              \[\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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                                                                                            7. Step-by-step derivation
                                                                                                                              1. Applied rewrites50.9%

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

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

                                                                                                                                  \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) \]
                                                                                                                                3. Step-by-step derivation
                                                                                                                                  1. Applied rewrites18.4%

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

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

                                                                                                                                  Alternative 26: 19.0% accurate, 30.0× speedup?

                                                                                                                                  \[\begin{array}{l} \\ \ell \cdot \left(2 \cdot J\right) \end{array} \]
                                                                                                                                  (FPCore (J l K U) :precision binary64 (* l (* 2.0 J)))
                                                                                                                                  double code(double J, double l, double K, double U) {
                                                                                                                                  	return l * (2.0 * J);
                                                                                                                                  }
                                                                                                                                  
                                                                                                                                  real(8) function code(j, l, k, u)
                                                                                                                                      real(8), intent (in) :: j
                                                                                                                                      real(8), intent (in) :: l
                                                                                                                                      real(8), intent (in) :: k
                                                                                                                                      real(8), intent (in) :: u
                                                                                                                                      code = l * (2.0d0 * j)
                                                                                                                                  end function
                                                                                                                                  
                                                                                                                                  public static double code(double J, double l, double K, double U) {
                                                                                                                                  	return l * (2.0 * J);
                                                                                                                                  }
                                                                                                                                  
                                                                                                                                  def code(J, l, K, U):
                                                                                                                                  	return l * (2.0 * J)
                                                                                                                                  
                                                                                                                                  function code(J, l, K, U)
                                                                                                                                  	return Float64(l * Float64(2.0 * J))
                                                                                                                                  end
                                                                                                                                  
                                                                                                                                  function tmp = code(J, l, K, U)
                                                                                                                                  	tmp = l * (2.0 * J);
                                                                                                                                  end
                                                                                                                                  
                                                                                                                                  code[J_, l_, K_, U_] := N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]
                                                                                                                                  
                                                                                                                                  \begin{array}{l}
                                                                                                                                  
                                                                                                                                  \\
                                                                                                                                  \ell \cdot \left(2 \cdot J\right)
                                                                                                                                  \end{array}
                                                                                                                                  
                                                                                                                                  Derivation
                                                                                                                                  1. Initial program 87.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}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                                                                                                                                  4. Step-by-step derivation
                                                                                                                                    1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                                                    \[\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 U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                                                                                                                                  7. Step-by-step derivation
                                                                                                                                    1. Applied rewrites50.9%

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

                                                                                                                                      \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) \]
                                                                                                                                    3. Step-by-step derivation
                                                                                                                                      1. Applied rewrites18.0%

                                                                                                                                        \[\leadsto \ell \cdot \left(2 \cdot \color{blue}{J}\right) \]
                                                                                                                                      2. Add Preprocessing

                                                                                                                                      Reproduce

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