Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 87.0% → 99.9%
Time: 13.9s
Alternatives: 20
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 20 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: 87.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{K}{2}\right)} \cdot 2, \sinh \ell \cdot J, U\right) \]
    9. div-invN/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot \frac{1}{2}\right) \cdot 2, \color{blue}{J \cdot \sinh \ell}, U\right) \]
    14. sinh-lowering-sinh.f64100.0

      \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot 2, J \cdot \color{blue}{\sinh \ell}, U\right) \]
  4. Applied egg-rr100.0%

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

Alternative 2: 97.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.96:\\ \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, J \cdot \sinh \ell, U\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 0.96)
     (+
      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 (* J (sinh l)) U))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double tmp;
	if (t_0 <= 0.96) {
		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, (J * sinh(l)), U);
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= 0.96)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * fma(Float64(l * l), fma(Float64(l * l), fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), 0.3333333333333333), 2.0)))));
	else
		tmp = fma(2.0, Float64(J * sinh(l)), 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.96], N[(U + N[(t$95$0 * N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.96:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, J \cdot \sinh \ell, U\right)\\


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

    1. Initial program 89.4%

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

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

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

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

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

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

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

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

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

    1. Initial program 90.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. *-commutativeN/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{K}{2}\right)} \cdot 2, \sinh \ell \cdot J, U\right) \]
      9. div-invN/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot \frac{1}{2}\right) \cdot 2, \color{blue}{J \cdot \sinh \ell}, U\right) \]
      14. sinh-lowering-sinh.f64100.0

        \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot 2, J \cdot \color{blue}{\sinh \ell}, U\right) \]
    4. Applied egg-rr100.0%

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

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

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

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

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

      1. Initial program 89.4%

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

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. Step-by-step derivation
        1. *-lowering-*.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. accelerator-lowering-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. *-lowering-*.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. accelerator-lowering-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. *-lowering-*.f6492.9

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

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

      1. Initial program 90.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. *-commutativeN/A

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{K}{2}\right)} \cdot 2, \sinh \ell \cdot J, U\right) \]
        9. div-invN/A

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot \frac{1}{2}\right) \cdot 2, \color{blue}{J \cdot \sinh \ell}, U\right) \]
        14. sinh-lowering-sinh.f64100.0

          \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot 2, J \cdot \color{blue}{\sinh \ell}, U\right) \]
      4. Applied egg-rr100.0%

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{2}, J \cdot \sinh \ell, 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.96:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.016666666666666666, 0.3333333333333333\right), 2\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, J \cdot \sinh \ell, U\right)\\ \end{array} \]
      9. Add Preprocessing

      Alternative 4: 94.1% accurate, 1.3× speedup?

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

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

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

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

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

            \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \frac{1}{3}, 2\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
          7. *-lowering-*.f6493.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. Simplified93.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 -0.050000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

        1. Initial program 89.4%

          \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. *-commutativeN/A

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{K}{2}\right)} \cdot 2, \sinh \ell \cdot J, U\right) \]
          9. div-invN/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot \frac{1}{2}\right) \cdot 2, \color{blue}{J \cdot \sinh \ell}, U\right) \]
          14. sinh-lowering-sinh.f64100.0

            \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot 2, J \cdot \color{blue}{\sinh \ell}, U\right) \]
        4. Applied egg-rr100.0%

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

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

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

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

        Alternative 5: 93.4% accurate, 1.3× speedup?

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

          1. Initial program 92.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 + \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. accelerator-lowering-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. Simplified81.3%

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

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

          1. Initial program 89.4%

            \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. *-commutativeN/A

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{K}{2}\right)} \cdot 2, \sinh \ell \cdot J, U\right) \]
            9. div-invN/A

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot \frac{1}{2}\right) \cdot 2, \color{blue}{J \cdot \sinh \ell}, U\right) \]
            14. sinh-lowering-sinh.f64100.0

              \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot 2, J \cdot \color{blue}{\sinh \ell}, U\right) \]
          4. Applied egg-rr100.0%

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

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

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

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

          Alternative 6: 87.9% accurate, 1.4× speedup?

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

            1. Initial program 92.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}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
            4. Step-by-step derivation
              1. associate-*r*N/A

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

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

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

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

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

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

                \[\leadsto \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)} + U \]
              8. *-lowering-*.f6471.9

                \[\leadsto \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \color{blue}{\left(J \cdot \ell\right)}\right) + U \]
            5. Simplified71.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            1. Initial program 89.4%

              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. *-commutativeN/A

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{K}{2}\right)} \cdot 2, \sinh \ell \cdot J, U\right) \]
              9. div-invN/A

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot \frac{1}{2}\right) \cdot 2, \color{blue}{J \cdot \sinh \ell}, U\right) \]
              14. sinh-lowering-sinh.f64100.0

                \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot 2, J \cdot \color{blue}{\sinh \ell}, U\right) \]
            4. Applied egg-rr100.0%

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

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

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

            Alternative 7: 87.9% accurate, 1.4× speedup?

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

              1. Initial program 92.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 2 \cdot \color{blue}{\left(\left(J \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                3. associate-*r*N/A

                  \[\leadsto \color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\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(2 \cdot \left(J \cdot \ell\right)\right)} + U \]
                5. accelerator-lowering-fma.f64N/A

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

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

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

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

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

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

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

              1. Initial program 89.4%

                \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              2. Add Preprocessing
              3. Step-by-step derivation
                1. *-commutativeN/A

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{K}{2}\right)} \cdot 2, \sinh \ell \cdot J, U\right) \]
                9. div-invN/A

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot \frac{1}{2}\right) \cdot 2, \color{blue}{J \cdot \sinh \ell}, U\right) \]
                14. sinh-lowering-sinh.f64100.0

                  \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot 2, J \cdot \color{blue}{\sinh \ell}, U\right) \]
              4. Applied egg-rr100.0%

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

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

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

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

              Alternative 8: 56.6% accurate, 1.4× speedup?

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

                1. Initial program 85.9%

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

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

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

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

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

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

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

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

                    \[\leadsto \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)} + U \]
                  8. *-lowering-*.f6482.9

                    \[\leadsto \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \color{blue}{\left(J \cdot \ell\right)}\right) + U \]
                5. Simplified82.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

                if 5.00000000000000033e-38 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))))

                1. Initial program 100.0%

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

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

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

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

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

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

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

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

                    \[\leadsto \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)} + U \]
                  8. *-lowering-*.f6436.3

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

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

                  \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                7. Step-by-step derivation
                  1. *-lowering-*.f64N/A

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

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

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

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

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

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

                    \[\leadsto 2 \cdot \left(\cos \color{blue}{\left(K \cdot \frac{1}{2}\right)} \cdot \left(J \cdot \ell\right)\right) \]
                  8. *-lowering-*.f6435.9

                    \[\leadsto 2 \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \color{blue}{\left(J \cdot \ell\right)}\right) \]
                8. Simplified35.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 9: 87.5% accurate, 1.4× speedup?

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

                1. Initial program 92.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. *-lowering-*.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. accelerator-lowering-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. *-lowering-*.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. accelerator-lowering-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}{2520} \cdot {\ell}^{2}, \frac{1}{3}\right)}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  8. unpow2N/A

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \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)\right) + J \cdot \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) + U} \]
                8. Simplified66.6%

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

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

                1. Initial program 89.4%

                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. *-commutativeN/A

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{K}{2}\right)} \cdot 2, \sinh \ell \cdot J, U\right) \]
                  9. div-invN/A

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot \frac{1}{2}\right) \cdot 2, \color{blue}{J \cdot \sinh \ell}, U\right) \]
                  14. sinh-lowering-sinh.f64100.0

                    \[\leadsto \mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot 2, J \cdot \color{blue}{\sinh \ell}, U\right) \]
                4. Applied egg-rr100.0%

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

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

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

                Alternative 10: 83.6% accurate, 1.9× speedup?

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

                  1. Initial program 92.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. *-lowering-*.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. accelerator-lowering-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. *-lowering-*.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. accelerator-lowering-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}{2520} \cdot {\ell}^{2}, \frac{1}{3}\right)}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    8. unpow2N/A

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

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

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

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

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

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

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

                      \[\leadsto \color{blue}{\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \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)\right) + J \cdot \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) + U} \]
                  8. Simplified66.6%

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

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

                  1. Initial program 89.4%

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{U + J \cdot \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)} \]
                  7. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \color{blue}{J \cdot \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) + U} \]
                    2. accelerator-lowering-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                  8. Simplified91.4%

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

                Alternative 11: 83.0% accurate, 2.0× speedup?

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

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

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

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

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

                      \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \frac{1}{3}, 2\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    7. *-lowering-*.f6493.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. Simplified93.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 \]
                  6. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

                  1. Initial program 89.4%

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{U + J \cdot \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)} \]
                  7. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \color{blue}{J \cdot \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) + U} \]
                    2. accelerator-lowering-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                  8. Simplified91.4%

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

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

                Alternative 12: 82.9% accurate, 2.1× speedup?

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

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

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

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

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

                      \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \frac{1}{3}, 2\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    7. *-lowering-*.f6493.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. Simplified93.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 \]
                  6. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

                  1. Initial program 89.4%

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{U + J \cdot \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)} \]
                  7. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \color{blue}{J \cdot \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) + U} \]
                    2. accelerator-lowering-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                  8. Simplified91.4%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                  9. Taylor expanded in l around inf

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \ell \cdot \left(\frac{1}{2520} \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot \ell\right)\right), 2\right), U\right) \]
                    10. unpow3N/A

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \ell \cdot \left(\left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right) \cdot \frac{1}{2520}\right), 2\right), U\right) \]
                    18. *-lowering-*.f6491.4

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

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

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

                Alternative 13: 81.2% accurate, 2.1× speedup?

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

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

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

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

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

                      \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \frac{1}{3}, 2\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    7. *-lowering-*.f6493.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. Simplified93.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 \]
                  6. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

                  1. Initial program 89.4%

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{U + J \cdot \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)} \]
                  7. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \color{blue}{J \cdot \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) + U} \]
                    2. accelerator-lowering-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                  8. Simplified91.4%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                  9. Taylor expanded in l around 0

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

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

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

                  Alternative 14: 77.9% accurate, 2.2× speedup?

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

                    1. Initial program 91.2%

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

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

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

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

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

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

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

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

                        \[\leadsto \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)} + U \]
                      8. *-lowering-*.f6475.8

                        \[\leadsto \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \color{blue}{\left(J \cdot \ell\right)}\right) + U \]
                    5. Simplified75.8%

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

                      \[\leadsto \color{blue}{U + \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. +-commutativeN/A

                        \[\leadsto \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) + U} \]
                      2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    1. Initial program 89.8%

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

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

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

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

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

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

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

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

                      \[\leadsto \color{blue}{U + J \cdot \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)} \]
                    7. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{J \cdot \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) + U} \]
                      2. accelerator-lowering-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                    8. Simplified87.9%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                    9. Taylor expanded in l around 0

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

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

                    Alternative 15: 74.5% accurate, 2.4× speedup?

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

                      1. Initial program 91.2%

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

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

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

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

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

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

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

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

                          \[\leadsto \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)} + U \]
                        8. *-lowering-*.f6475.8

                          \[\leadsto \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \color{blue}{\left(J \cdot \ell\right)}\right) + U \]
                      5. Simplified75.8%

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

                        \[\leadsto \color{blue}{U + \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. +-commutativeN/A

                          \[\leadsto \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) + U} \]
                        2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      1. Initial program 89.8%

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

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

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

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

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

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

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

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

                        \[\leadsto \color{blue}{U + J \cdot \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)} \]
                      7. Step-by-step derivation
                        1. +-commutativeN/A

                          \[\leadsto \color{blue}{J \cdot \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) + U} \]
                        2. accelerator-lowering-fma.f64N/A

                          \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                      8. Simplified87.9%

                        \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                      9. Taylor expanded in l around 0

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

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

                      Alternative 16: 46.1% accurate, 14.3× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(J \cdot \ell\right)\\ \mathbf{if}\;\ell \leq -4.4 \cdot 10^{+55}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 1.35 \cdot 10^{+14}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                      (FPCore (J l K U)
                       :precision binary64
                       (let* ((t_0 (* 2.0 (* J l))))
                         (if (<= l -4.4e+55) t_0 (if (<= l 1.35e+14) U t_0))))
                      double code(double J, double l, double K, double U) {
                      	double t_0 = 2.0 * (J * l);
                      	double tmp;
                      	if (l <= -4.4e+55) {
                      		tmp = t_0;
                      	} else if (l <= 1.35e+14) {
                      		tmp = U;
                      	} else {
                      		tmp = t_0;
                      	}
                      	return tmp;
                      }
                      
                      real(8) function code(j, l, k, u)
                          real(8), intent (in) :: j
                          real(8), intent (in) :: l
                          real(8), intent (in) :: k
                          real(8), intent (in) :: u
                          real(8) :: t_0
                          real(8) :: tmp
                          t_0 = 2.0d0 * (j * l)
                          if (l <= (-4.4d+55)) then
                              tmp = t_0
                          else if (l <= 1.35d+14) then
                              tmp = u
                          else
                              tmp = t_0
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double J, double l, double K, double U) {
                      	double t_0 = 2.0 * (J * l);
                      	double tmp;
                      	if (l <= -4.4e+55) {
                      		tmp = t_0;
                      	} else if (l <= 1.35e+14) {
                      		tmp = U;
                      	} else {
                      		tmp = t_0;
                      	}
                      	return tmp;
                      }
                      
                      def code(J, l, K, U):
                      	t_0 = 2.0 * (J * l)
                      	tmp = 0
                      	if l <= -4.4e+55:
                      		tmp = t_0
                      	elif l <= 1.35e+14:
                      		tmp = U
                      	else:
                      		tmp = t_0
                      	return tmp
                      
                      function code(J, l, K, U)
                      	t_0 = Float64(2.0 * Float64(J * l))
                      	tmp = 0.0
                      	if (l <= -4.4e+55)
                      		tmp = t_0;
                      	elseif (l <= 1.35e+14)
                      		tmp = U;
                      	else
                      		tmp = t_0;
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(J, l, K, U)
                      	t_0 = 2.0 * (J * l);
                      	tmp = 0.0;
                      	if (l <= -4.4e+55)
                      		tmp = t_0;
                      	elseif (l <= 1.35e+14)
                      		tmp = U;
                      	else
                      		tmp = t_0;
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[J_, l_, K_, U_] := Block[{t$95$0 = N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.4e+55], t$95$0, If[LessEqual[l, 1.35e+14], U, t$95$0]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_0 := 2 \cdot \left(J \cdot \ell\right)\\
                      \mathbf{if}\;\ell \leq -4.4 \cdot 10^{+55}:\\
                      \;\;\;\;t\_0\\
                      
                      \mathbf{elif}\;\ell \leq 1.35 \cdot 10^{+14}:\\
                      \;\;\;\;U\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;t\_0\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if l < -4.40000000000000021e55 or 1.35e14 < 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}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
                        4. Step-by-step derivation
                          1. associate-*r*N/A

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

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

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

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

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

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

                            \[\leadsto \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)} + U \]
                          8. *-lowering-*.f6438.7

                            \[\leadsto \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \color{blue}{\left(J \cdot \ell\right)}\right) + U \]
                        5. Simplified38.7%

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

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

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

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

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

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

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

                            \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                          2. *-lowering-*.f6430.0

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

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

                        if -4.40000000000000021e55 < l < 1.35e14

                        1. Initial program 82.7%

                          \[\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 J around 0

                          \[\leadsto \color{blue}{U} \]
                        4. Step-by-step derivation
                          1. Simplified73.6%

                            \[\leadsto \color{blue}{U} \]
                        5. Recombined 2 regimes into one program.
                        6. Add Preprocessing

                        Alternative 17: 71.5% accurate, 14.3× speedup?

                        \[\begin{array}{l} \\ \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right), U\right) \end{array} \]
                        (FPCore (J l K U)
                         :precision binary64
                         (fma J (* l (fma (* l l) 0.3333333333333333 2.0)) U))
                        double code(double J, double l, double K, double U) {
                        	return fma(J, (l * fma((l * l), 0.3333333333333333, 2.0)), U);
                        }
                        
                        function code(J, l, K, U)
                        	return fma(J, Float64(l * fma(Float64(l * l), 0.3333333333333333, 2.0)), U)
                        end
                        
                        code[J_, l_, K_, U_] := N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
                        
                        \begin{array}{l}
                        
                        \\
                        \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right), U\right)
                        \end{array}
                        
                        Derivation
                        1. Initial program 90.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 \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. *-lowering-*.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. accelerator-lowering-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. *-lowering-*.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. accelerator-lowering-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}{2520} \cdot {\ell}^{2}, \frac{1}{3}\right)}, 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                          8. unpow2N/A

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

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

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

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

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

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

                          \[\leadsto \color{blue}{U + J \cdot \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)} \]
                        7. Step-by-step derivation
                          1. +-commutativeN/A

                            \[\leadsto \color{blue}{J \cdot \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) + U} \]
                          2. accelerator-lowering-fma.f64N/A

                            \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                        8. Simplified80.6%

                          \[\leadsto \color{blue}{\mathsf{fma}\left(J, \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), U\right)} \]
                        9. Taylor expanded in l around 0

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

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

                          Alternative 18: 53.5% accurate, 27.5× speedup?

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

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

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

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

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

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

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

                              \[\leadsto \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)} + U \]
                            8. *-lowering-*.f6469.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          Alternative 19: 53.5% accurate, 27.5× speedup?

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

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

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

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

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

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

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

                              \[\leadsto \cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)} + U \]
                            8. *-lowering-*.f6469.0

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

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

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

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

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

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

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

                          Alternative 20: 37.1% accurate, 330.0× speedup?

                          \[\begin{array}{l} \\ U \end{array} \]
                          (FPCore (J l K U) :precision binary64 U)
                          double code(double J, double l, double K, double U) {
                          	return 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 = u
                          end function
                          
                          public static double code(double J, double l, double K, double U) {
                          	return U;
                          }
                          
                          def code(J, l, K, U):
                          	return U
                          
                          function code(J, l, K, U)
                          	return U
                          end
                          
                          function tmp = code(J, l, K, U)
                          	tmp = U;
                          end
                          
                          code[J_, l_, K_, U_] := U
                          
                          \begin{array}{l}
                          
                          \\
                          U
                          \end{array}
                          
                          Derivation
                          1. Initial program 90.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 J around 0

                            \[\leadsto \color{blue}{U} \]
                          4. Step-by-step derivation
                            1. Simplified43.2%

                              \[\leadsto \color{blue}{U} \]
                            2. Add Preprocessing

                            Reproduce

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