Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.5% → 100.0%
Time: 14.4s
Alternatives: 23
Speedup: 1.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 23 alternatives:

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

Initial Program: 86.5% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.4% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 86.8%

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

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

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

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

    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 K around 0

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6492.2

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified92.2%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{0 - \ell}, J, U\right)} \]
      3. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
      4. sinh-undefN/A

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

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

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

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

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

Alternative 3: 94.3% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 87.1%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Add Preprocessing
    3. 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-*.f6494.9

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

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

    1. Initial program 91.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 K around 0

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6491.8

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified91.8%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{0 - \ell}, J, U\right)} \]
      3. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
      4. sinh-undefN/A

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

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

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

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

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

Alternative 4: 93.1% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.866:\\
\;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right), U\right)\\

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


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

    1. Initial program 87.1%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Add Preprocessing
    3. 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. Simplified90.7%

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

    1. Initial program 91.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 K around 0

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6491.8

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified91.8%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{0 - \ell}, J, U\right)} \]
      3. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
      4. sinh-undefN/A

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

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

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

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

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

Alternative 5: 88.0% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 89.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. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 89.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 K around 0

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6489.5

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified89.5%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{0 - \ell}, J, U\right)} \]
      3. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
      4. sinh-undefN/A

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

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

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

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

Alternative 6: 87.7% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.125, K \cdot K, 1\right), \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.016666666666666666, 0.3333333333333333\right), 2\right) \cdot \left(\ell \cdot J\right), U\right)\\

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


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

    1. Initial program 89.6%

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

      \[\leadsto \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-*.f6493.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. Simplified93.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 \]
    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} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) + J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

    1. Initial program 89.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 K around 0

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6489.5

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified89.5%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{0 - \ell}, J, U\right)} \]
      3. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
      4. sinh-undefN/A

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

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

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

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

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

Alternative 7: 89.1% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 10^{-71}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\

\mathbf{else}:\\
\;\;\;\;U + \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) \cdot \cos \left(\frac{K}{2}\right)\\


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

    1. Initial program 90.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 K around 0

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6478.1

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified78.1%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{0 - \ell}, J, U\right)} \]
      3. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
      4. sinh-undefN/A

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

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

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

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

    if 9.9999999999999992e-72 < (/.f64 K #s(literal 2 binary64))

    1. Initial program 89.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-*.f6497.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. Simplified97.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 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.8%

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

Alternative 8: 84.1% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.125, K \cdot K, 1\right), \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.016666666666666666, 0.3333333333333333\right), 2\right) \cdot \left(\ell \cdot J\right), U\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \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), U\right)\\


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

    1. Initial program 89.6%

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

      \[\leadsto \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-*.f6493.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. Simplified93.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 \]
    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} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) + J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

    1. Initial program 89.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 K around 0

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6489.5

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified89.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
    6. Taylor expanded in l around 0

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

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

        \[\leadsto \mathsf{fma}\left(J, \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)}, U\right) \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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)}, U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      12. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      14. *-lowering-*.f6489.8

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

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

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

Alternative 9: 83.6% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.125, K \cdot K, 1\right), \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right) \cdot \left(\ell \cdot J\right), U\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \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), U\right)\\


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

    1. Initial program 89.6%

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

      \[\leadsto \color{blue}{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. Simplified87.8%

      \[\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)} \]
    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. Simplified66.3%

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

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

    1. Initial program 89.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 K around 0

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6489.5

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified89.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
    6. Taylor expanded in l around 0

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

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

        \[\leadsto \mathsf{fma}\left(J, \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)}, U\right) \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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)}, U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      12. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      14. *-lowering-*.f6489.8

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

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

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

Alternative 10: 83.5% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.125, K \cdot K, 1\right), \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right) \cdot \left(\ell \cdot J\right), U\right)\\

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


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

    1. Initial program 89.6%

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

      \[\leadsto \color{blue}{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. Simplified87.8%

      \[\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)} \]
    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. Simplified66.3%

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

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

    1. Initial program 89.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 K around 0

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6489.5

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified89.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
    6. Taylor expanded in l around 0

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

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

        \[\leadsto \mathsf{fma}\left(J, \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)}, U\right) \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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)}, U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      12. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{fma}\left(J, \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), U\right) \]
      14. *-lowering-*.f6489.8

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

      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)}, 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. *-lowering-*.f64N/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) \]
      6. 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) \]
      7. *-lowering-*.f64N/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) \]
      8. *-commutativeN/A

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

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

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

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

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

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

Alternative 11: 82.1% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.125, K \cdot K, 1\right), \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right) \cdot \left(\ell \cdot J\right), U\right)\\

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


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

    1. Initial program 89.6%

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

      \[\leadsto \color{blue}{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. Simplified87.8%

      \[\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)} \]
    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. Simplified66.3%

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

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

    1. Initial program 89.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 K around 0

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6489.5

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified89.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
    6. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 81.1% accurate, 2.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.02:\\
\;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, 0.041666666666666664, 0.16666666666666666\right), 0.5\right), 1\right), U\right)\\

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


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

    1. Initial program 88.6%

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

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
      3. neg-mul-1N/A

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

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      9. --lowering--.f6427.5

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
    5. Simplified27.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
    6. Taylor expanded in l around 0

      \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{1}, U\right) \]
    7. Step-by-step derivation
      1. Simplified27.8%

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \frac{1}{24}} + \frac{1}{6}, \frac{1}{2}\right), 1\right), U\right) \]
        8. accelerator-lowering-fma.f6456.7

          \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, 0.041666666666666664, 0.16666666666666666\right)}, 0.5\right), 1\right), U\right) \]
      4. Simplified56.7%

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

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

      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 K around 0

        \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
        3. neg-mul-1N/A

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

          \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
        5. exp-lowering-exp.f64N/A

          \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
        6. exp-lowering-exp.f64N/A

          \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
        7. neg-mul-1N/A

          \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
        8. neg-sub0N/A

          \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
        9. --lowering--.f6489.9

          \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      5. Simplified89.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
      6. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 13: 80.0% accurate, 2.2× speedup?

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

      1. Initial program 88.6%

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

        \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
        3. neg-mul-1N/A

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

          \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
        5. exp-lowering-exp.f64N/A

          \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
        6. exp-lowering-exp.f64N/A

          \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
        7. neg-mul-1N/A

          \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
        8. neg-sub0N/A

          \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
        9. --lowering--.f6427.5

          \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
      5. Simplified27.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
      6. Taylor expanded in l around 0

        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{1}, U\right) \]
      7. Step-by-step derivation
        1. Simplified27.8%

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \frac{1}{24}} + \frac{1}{6}, \frac{1}{2}\right), 1\right), U\right) \]
          8. accelerator-lowering-fma.f6456.7

            \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, 0.041666666666666664, 0.16666666666666666\right)}, 0.5\right), 1\right), U\right) \]
        4. Simplified56.7%

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

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

        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} + \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-*.f6493.4

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

          \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.016666666666666666, 0.3333333333333333\right), 2\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        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} + \frac{1}{60} \cdot {\ell}^{2}\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} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + U} \]
          2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 14: 77.3% accurate, 2.2× speedup?

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

        1. Initial program 88.6%

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

          \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
          3. neg-mul-1N/A

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

            \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
          5. exp-lowering-exp.f64N/A

            \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
          6. exp-lowering-exp.f64N/A

            \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
          7. neg-mul-1N/A

            \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
          8. neg-sub0N/A

            \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
          9. --lowering--.f6427.5

            \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
        5. Simplified27.5%

          \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
        6. Taylor expanded in l around 0

          \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{1}, U\right) \]
        7. Step-by-step derivation
          1. Simplified27.8%

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \frac{1}{24}} + \frac{1}{6}, \frac{1}{2}\right), 1\right), U\right) \]
            8. accelerator-lowering-fma.f6456.7

              \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, 0.041666666666666664, 0.16666666666666666\right)}, 0.5\right), 1\right), U\right) \]
          4. Simplified56.7%

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

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

          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 K around 0

            \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
            3. neg-mul-1N/A

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

              \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
            5. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
            6. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
            7. neg-mul-1N/A

              \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
            8. neg-sub0N/A

              \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
            9. --lowering--.f6489.9

              \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
          5. Simplified89.9%

            \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
          6. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

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

        Alternative 15: 76.0% accurate, 2.4× speedup?

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

          1. Initial program 88.6%

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

            \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
            3. neg-mul-1N/A

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

              \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
            5. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
            6. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
            7. neg-mul-1N/A

              \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
            8. neg-sub0N/A

              \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
            9. --lowering--.f6427.5

              \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
          5. Simplified27.5%

            \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
          6. Taylor expanded in l around 0

            \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{1}, U\right) \]
          7. Step-by-step derivation
            1. Simplified27.8%

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

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

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

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

                \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{\ell \cdot \frac{1}{2}} + 1\right), U\right) \]
              4. accelerator-lowering-fma.f6453.7

                \[\leadsto \mathsf{fma}\left(J, \ell \cdot \color{blue}{\mathsf{fma}\left(\ell, 0.5, 1\right)}, U\right) \]
            4. Simplified53.7%

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

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

            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 K around 0

              \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
            4. Step-by-step derivation
              1. +-commutativeN/A

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
              3. neg-mul-1N/A

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

                \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
              5. exp-lowering-exp.f64N/A

                \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
              6. exp-lowering-exp.f64N/A

                \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
              7. neg-mul-1N/A

                \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
              8. neg-sub0N/A

                \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
              9. --lowering--.f6489.9

                \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
            5. Simplified89.9%

              \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
            6. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

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

          Alternative 16: 68.6% accurate, 2.4× speedup?

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

            1. Initial program 88.6%

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

              \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
            4. Step-by-step derivation
              1. +-commutativeN/A

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
              3. neg-mul-1N/A

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

                \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
              5. exp-lowering-exp.f64N/A

                \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
              6. exp-lowering-exp.f64N/A

                \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
              7. neg-mul-1N/A

                \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
              8. neg-sub0N/A

                \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
              9. --lowering--.f6427.5

                \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
            5. Simplified27.5%

              \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
            6. Taylor expanded in l around 0

              \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{1}, U\right) \]
            7. Step-by-step derivation
              1. Simplified27.8%

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{\ell \cdot \frac{1}{2}} + 1\right), U\right) \]
                4. accelerator-lowering-fma.f6453.7

                  \[\leadsto \mathsf{fma}\left(J, \ell \cdot \color{blue}{\mathsf{fma}\left(\ell, 0.5, 1\right)}, U\right) \]
              4. Simplified53.7%

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

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

              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 K around 0

                \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                3. neg-mul-1N/A

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

                  \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
                5. exp-lowering-exp.f64N/A

                  \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
                6. exp-lowering-exp.f64N/A

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
                7. neg-mul-1N/A

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                8. neg-sub0N/A

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                9. --lowering--.f6489.9

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
              5. Simplified89.9%

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

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{0 - \ell}, J, U\right)} \]
                3. sub0-negN/A

                  \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                4. sinh-undefN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 17: 55.2% accurate, 9.4× speedup?

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

              1. Initial program 90.5%

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

                \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                3. neg-mul-1N/A

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

                  \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
                5. exp-lowering-exp.f64N/A

                  \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
                6. exp-lowering-exp.f64N/A

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
                7. neg-mul-1N/A

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                8. neg-sub0N/A

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                9. --lowering--.f6477.3

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
              5. Simplified77.3%

                \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
              6. Taylor expanded in l around 0

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

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

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

              if 2.3999999999999999e-168 < (/.f64 K #s(literal 2 binary64))

              1. Initial program 88.3%

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

                \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                3. neg-mul-1N/A

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

                  \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
                5. exp-lowering-exp.f64N/A

                  \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
                6. exp-lowering-exp.f64N/A

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
                7. neg-mul-1N/A

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                8. neg-sub0N/A

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                9. --lowering--.f6468.0

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
              5. Simplified68.0%

                \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
              6. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

              Alternative 18: 71.7% accurate, 9.7× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := J \cdot \left(\ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right)\right)\\ \mathbf{if}\;\ell \leq -32000000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+20}:\\ \;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
              (FPCore (J l K U)
               :precision binary64
               (let* ((t_0 (* J (* l (fma 0.3333333333333333 (* l l) 2.0)))))
                 (if (<= l -32000000000.0) t_0 (if (<= l 1.8e+20) (fma J (* 2.0 l) U) t_0))))
              double code(double J, double l, double K, double U) {
              	double t_0 = J * (l * fma(0.3333333333333333, (l * l), 2.0));
              	double tmp;
              	if (l <= -32000000000.0) {
              		tmp = t_0;
              	} else if (l <= 1.8e+20) {
              		tmp = fma(J, (2.0 * l), U);
              	} else {
              		tmp = t_0;
              	}
              	return tmp;
              }
              
              function code(J, l, K, U)
              	t_0 = Float64(J * Float64(l * fma(0.3333333333333333, Float64(l * l), 2.0)))
              	tmp = 0.0
              	if (l <= -32000000000.0)
              		tmp = t_0;
              	elseif (l <= 1.8e+20)
              		tmp = fma(J, Float64(2.0 * l), U);
              	else
              		tmp = t_0;
              	end
              	return tmp
              end
              
              code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(l * N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -32000000000.0], t$95$0, If[LessEqual[l, 1.8e+20], N[(J * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision], t$95$0]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := J \cdot \left(\ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right)\right)\\
              \mathbf{if}\;\ell \leq -32000000000:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+20}:\\
              \;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_0\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if l < -3.2e10 or 1.8e20 < 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 K around 0

                  \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
                4. Step-by-step derivation
                  1. +-commutativeN/A

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                  3. neg-mul-1N/A

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

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
                  5. exp-lowering-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
                  6. exp-lowering-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
                  7. neg-mul-1N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                  8. neg-sub0N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                  9. --lowering--.f6470.9

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                5. Simplified70.9%

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

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{0 - \ell}, J, U\right)} \]
                  3. sub0-negN/A

                    \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                  4. sinh-undefN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(\ell \cdot \mathsf{fma}\left(0.3333333333333333, \color{blue}{\ell \cdot \ell}, 2\right)\right) \cdot J \]
                13. Simplified61.2%

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

                if -3.2e10 < l < 1.8e20

                1. Initial program 79.6%

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

                  \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
                4. Step-by-step derivation
                  1. +-commutativeN/A

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                  3. neg-mul-1N/A

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

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
                  5. exp-lowering-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
                  6. exp-lowering-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
                  7. neg-mul-1N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                  8. neg-sub0N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                  9. --lowering--.f6476.7

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                5. Simplified76.7%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
                6. Taylor expanded in l around 0

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

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

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -32000000000:\\ \;\;\;\;J \cdot \left(\ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right)\right)\\ \mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+20}:\\ \;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \left(\ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right)\right)\\ \end{array} \]
              5. Add Preprocessing

              Alternative 19: 69.5% accurate, 10.0× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(\ell \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \mathbf{if}\;\ell \leq -5500000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 2.85 \cdot 10^{+20}:\\ \;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
              (FPCore (J l K U)
               :precision binary64
               (let* ((t_0 (* 0.3333333333333333 (* l (* J (* l l))))))
                 (if (<= l -5500000000.0) t_0 (if (<= l 2.85e+20) (fma J (* 2.0 l) U) t_0))))
              double code(double J, double l, double K, double U) {
              	double t_0 = 0.3333333333333333 * (l * (J * (l * l)));
              	double tmp;
              	if (l <= -5500000000.0) {
              		tmp = t_0;
              	} else if (l <= 2.85e+20) {
              		tmp = fma(J, (2.0 * l), U);
              	} else {
              		tmp = t_0;
              	}
              	return tmp;
              }
              
              function code(J, l, K, U)
              	t_0 = Float64(0.3333333333333333 * Float64(l * Float64(J * Float64(l * l))))
              	tmp = 0.0
              	if (l <= -5500000000.0)
              		tmp = t_0;
              	elseif (l <= 2.85e+20)
              		tmp = fma(J, Float64(2.0 * l), U);
              	else
              		tmp = t_0;
              	end
              	return tmp
              end
              
              code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(l * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5500000000.0], t$95$0, If[LessEqual[l, 2.85e+20], N[(J * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision], t$95$0]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := 0.3333333333333333 \cdot \left(\ell \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\
              \mathbf{if}\;\ell \leq -5500000000:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;\ell \leq 2.85 \cdot 10^{+20}:\\
              \;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_0\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if l < -5.5e9 or 2.85e20 < 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 K around 0

                  \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
                4. Step-by-step derivation
                  1. +-commutativeN/A

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                  3. neg-mul-1N/A

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

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
                  5. exp-lowering-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
                  6. exp-lowering-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
                  7. neg-mul-1N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                  8. neg-sub0N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                  9. --lowering--.f6470.9

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                5. Simplified70.9%

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

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{0 - \ell}, J, U\right)} \]
                  3. sub0-negN/A

                    \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                  4. sinh-undefN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{1}{3} \cdot \color{blue}{\left({\ell}^{3} \cdot J\right)} \]
                  3. cube-multN/A

                    \[\leadsto \frac{1}{3} \cdot \left(\color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)} \cdot J\right) \]
                  4. unpow2N/A

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

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

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

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

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

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

                    \[\leadsto \frac{1}{3} \cdot \left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot J\right)\right) \]
                  11. *-lowering-*.f6456.7

                    \[\leadsto 0.3333333333333333 \cdot \left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot J\right)\right) \]
                13. Simplified56.7%

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

                if -5.5e9 < l < 2.85e20

                1. Initial program 79.6%

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

                  \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
                4. Step-by-step derivation
                  1. +-commutativeN/A

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                  3. neg-mul-1N/A

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

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
                  5. exp-lowering-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
                  6. exp-lowering-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
                  7. neg-mul-1N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                  8. neg-sub0N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                  9. --lowering--.f6476.7

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                5. Simplified76.7%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
                6. Taylor expanded in l around 0

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

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

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5500000000:\\ \;\;\;\;0.3333333333333333 \cdot \left(\ell \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 2.85 \cdot 10^{+20}:\\ \;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left(\ell \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \end{array} \]
              5. Add Preprocessing

              Alternative 20: 46.3% accurate, 18.3× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5500000000:\\ \;\;\;\;\ell \cdot J\\ \mathbf{elif}\;\ell \leq 9 \cdot 10^{+19}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot J\\ \end{array} \end{array} \]
              (FPCore (J l K U)
               :precision binary64
               (if (<= l -5500000000.0) (* l J) (if (<= l 9e+19) U (* l J))))
              double code(double J, double l, double K, double U) {
              	double tmp;
              	if (l <= -5500000000.0) {
              		tmp = l * J;
              	} else if (l <= 9e+19) {
              		tmp = U;
              	} else {
              		tmp = l * J;
              	}
              	return tmp;
              }
              
              real(8) function code(j, l, k, u)
                  real(8), intent (in) :: j
                  real(8), intent (in) :: l
                  real(8), intent (in) :: k
                  real(8), intent (in) :: u
                  real(8) :: tmp
                  if (l <= (-5500000000.0d0)) then
                      tmp = l * j
                  else if (l <= 9d+19) then
                      tmp = u
                  else
                      tmp = l * j
                  end if
                  code = tmp
              end function
              
              public static double code(double J, double l, double K, double U) {
              	double tmp;
              	if (l <= -5500000000.0) {
              		tmp = l * J;
              	} else if (l <= 9e+19) {
              		tmp = U;
              	} else {
              		tmp = l * J;
              	}
              	return tmp;
              }
              
              def code(J, l, K, U):
              	tmp = 0
              	if l <= -5500000000.0:
              		tmp = l * J
              	elif l <= 9e+19:
              		tmp = U
              	else:
              		tmp = l * J
              	return tmp
              
              function code(J, l, K, U)
              	tmp = 0.0
              	if (l <= -5500000000.0)
              		tmp = Float64(l * J);
              	elseif (l <= 9e+19)
              		tmp = U;
              	else
              		tmp = Float64(l * J);
              	end
              	return tmp
              end
              
              function tmp_2 = code(J, l, K, U)
              	tmp = 0.0;
              	if (l <= -5500000000.0)
              		tmp = l * J;
              	elseif (l <= 9e+19)
              		tmp = U;
              	else
              		tmp = l * J;
              	end
              	tmp_2 = tmp;
              end
              
              code[J_, l_, K_, U_] := If[LessEqual[l, -5500000000.0], N[(l * J), $MachinePrecision], If[LessEqual[l, 9e+19], U, N[(l * J), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;\ell \leq -5500000000:\\
              \;\;\;\;\ell \cdot J\\
              
              \mathbf{elif}\;\ell \leq 9 \cdot 10^{+19}:\\
              \;\;\;\;U\\
              
              \mathbf{else}:\\
              \;\;\;\;\ell \cdot J\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if l < -5.5e9 or 9e19 < 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 K around 0

                  \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
                4. Step-by-step derivation
                  1. +-commutativeN/A

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                  3. neg-mul-1N/A

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

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
                  5. exp-lowering-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
                  6. exp-lowering-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
                  7. neg-mul-1N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                  8. neg-sub0N/A

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                  9. --lowering--.f6470.9

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                5. Simplified70.9%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
                6. Taylor expanded in l around 0

                  \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{1}, U\right) \]
                7. Step-by-step derivation
                  1. Simplified38.6%

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

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

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

                      \[\leadsto \color{blue}{J \cdot \ell} \]
                    3. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \color{blue}{\ell \cdot J} \]
                      2. *-lowering-*.f6422.1

                        \[\leadsto \color{blue}{\ell \cdot J} \]
                    4. Simplified22.1%

                      \[\leadsto \color{blue}{\ell \cdot J} \]

                    if -5.5e9 < l < 9e19

                    1. Initial program 79.6%

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

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

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

                    Alternative 21: 53.9% accurate, 27.5× speedup?

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

                      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
                    4. Step-by-step derivation
                      1. +-commutativeN/A

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

                        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                      3. neg-mul-1N/A

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

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
                      5. exp-lowering-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
                      6. exp-lowering-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
                      7. neg-mul-1N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      8. neg-sub0N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                      9. --lowering--.f6473.8

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                    5. Simplified73.8%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
                    6. Taylor expanded in l around 0

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

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

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

                    Alternative 22: 47.9% accurate, 47.1× speedup?

                    \[\begin{array}{l} \\ \mathsf{fma}\left(J, \ell, U\right) \end{array} \]
                    (FPCore (J l K U) :precision binary64 (fma J l U))
                    double code(double J, double l, double K, double U) {
                    	return fma(J, l, U);
                    }
                    
                    function code(J, l, K, U)
                    	return fma(J, l, U)
                    end
                    
                    code[J_, l_, K_, U_] := N[(J * l + U), $MachinePrecision]
                    
                    \begin{array}{l}
                    
                    \\
                    \mathsf{fma}\left(J, \ell, U\right)
                    \end{array}
                    
                    Derivation
                    1. Initial program 89.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 K around 0

                      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
                    4. Step-by-step derivation
                      1. +-commutativeN/A

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

                        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                      3. neg-mul-1N/A

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

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{-1 \cdot \ell}}, U\right) \]
                      5. exp-lowering-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{-1 \cdot \ell}, U\right) \]
                      6. exp-lowering-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{-1 \cdot \ell}}, U\right) \]
                      7. neg-mul-1N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      8. neg-sub0N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                      9. --lowering--.f6473.8

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{0 - \ell}}, U\right) \]
                    5. Simplified73.8%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{0 - \ell}, U\right)} \]
                    6. Taylor expanded in l around 0

                      \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{1}, U\right) \]
                    7. Step-by-step derivation
                      1. Simplified57.0%

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

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

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

                        Alternative 23: 36.9% 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 89.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. Simplified37.4%

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

                          Reproduce

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