Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.4% → 97.3%
Time: 14.7s
Alternatives: 19
Speedup: 2.4×

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 19 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.4% 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: 97.3% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0

    1. Initial program 100.0%

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 78.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. lower-*.f64N/A

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

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \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 \]
      4. associate-*l*N/A

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \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 \]
      6. lower-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \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 \]
      7. +-commutativeN/A

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      9. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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. lower-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      11. +-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      12. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      13. lower-fma.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      14. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      15. lower-*.f6497.8

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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.8%

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 simplification98.5%

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

Alternative 2: 83.0% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -0.405:\\ \;\;\;\;J \cdot \mathsf{fma}\left(\cos \left(K \cdot 0.5\right), \ell \cdot 2, \frac{U}{J}\right)\\ \mathbf{elif}\;t\_0 \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right) \cdot \mathsf{fma}\left(K \cdot K, J \cdot -0.125, J\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \left(0.0003968253968253968 \cdot \left(\left(\ell \cdot \ell\right) \cdot \left(\ell \cdot \ell\right)\right)\right), 2\right), J, U\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 -0.405)
     (* J (fma (cos (* K 0.5)) (* l 2.0) (/ U J)))
     (if (<= t_0 -0.01)
       (fma
        l
        (*
         (fma
          (* l l)
          (fma l (* l 0.016666666666666666) 0.3333333333333333)
          2.0)
         (fma (* K K) (* J -0.125) J))
        U)
       (fma
        (* l (fma l (* l (* 0.0003968253968253968 (* (* l l) (* l l)))) 2.0))
        J
        U)))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double tmp;
	if (t_0 <= -0.405) {
		tmp = J * fma(cos((K * 0.5)), (l * 2.0), (U / J));
	} else if (t_0 <= -0.01) {
		tmp = fma(l, (fma((l * l), fma(l, (l * 0.016666666666666666), 0.3333333333333333), 2.0) * fma((K * K), (J * -0.125), J)), U);
	} else {
		tmp = fma((l * fma(l, (l * (0.0003968253968253968 * ((l * l) * (l * l)))), 2.0)), J, U);
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= -0.405)
		tmp = Float64(J * fma(cos(Float64(K * 0.5)), Float64(l * 2.0), Float64(U / J)));
	elseif (t_0 <= -0.01)
		tmp = fma(l, Float64(fma(Float64(l * l), fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0) * fma(Float64(K * K), Float64(J * -0.125), J)), U);
	else
		tmp = fma(Float64(l * fma(l, Float64(l * Float64(0.0003968253968253968 * Float64(Float64(l * l) * Float64(l * l)))), 2.0)), J, U);
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.405], N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(l * 2.0), $MachinePrecision] + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.01], N[(l * N[(N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * N[(J * -0.125), $MachinePrecision] + J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(l * N[(l * N[(l * N[(0.0003968253968253968 * N[(N[(l * l), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $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.405:\\
\;\;\;\;J \cdot \mathsf{fma}\left(\cos \left(K \cdot 0.5\right), \ell \cdot 2, \frac{U}{J}\right)\\

\mathbf{elif}\;t\_0 \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right) \cdot \mathsf{fma}\left(K \cdot K, J \cdot -0.125, J\right), U\right)\\

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


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

    1. Initial program 82.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 85.4%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
      7. lower-neg.f6485.4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 83.4% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 84.3%

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

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

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

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \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 \]
      4. associate-*l*N/A

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \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 \]
      6. lower-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \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 \]
      7. +-commutativeN/A

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      9. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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. lower-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      11. +-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      12. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      13. lower-fma.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      14. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      15. lower-*.f6494.5

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 85.4%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
      7. lower-neg.f6485.4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 83.0% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 85.4%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
      7. lower-neg.f6485.4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 95.0% accurate, 2.0× speedup?

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

\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right)\right)
\end{array}
Derivation
  1. Initial program 85.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. lower-*.f64N/A

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

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

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \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 \]
    4. associate-*l*N/A

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

      \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \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 \]
    6. lower-*.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \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 \]
    7. +-commutativeN/A

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

      \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
    9. unpow2N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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. lower-*.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
    11. +-commutativeN/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
    12. *-commutativeN/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
    13. lower-fma.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
    14. unpow2N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
    15. lower-*.f6495.9

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

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

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

Alternative 6: 79.1% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 2 \cdot 10^{+14}:\\
\;\;\;\;U + \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right) \cdot \left(J \cdot \mathsf{fma}\left(-0.125, \ell \cdot \left(K \cdot K\right), \ell\right)\right)\\

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


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

    1. Initial program 86.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 l around 0

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

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

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \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 \]
      4. associate-*l*N/A

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \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 \]
      6. lower-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \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 \]
      7. +-commutativeN/A

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      9. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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. lower-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      11. +-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      12. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      13. lower-fma.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      14. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
      15. lower-*.f6495.7

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 81.5%

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

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

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

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

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

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

Alternative 7: 80.4% accurate, 2.1× speedup?

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

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

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


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

    1. Initial program 83.4%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
      7. lower-neg.f6430.6

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 85.8%

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
        7. lower-neg.f6485.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 78.2% accurate, 2.1× speedup?

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

      1. Initial program 86.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 l around 0

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

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

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

          \[\leadsto \left(J \cdot \left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \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 \]
        4. associate-*l*N/A

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

          \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \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 \]
        6. lower-*.f64N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \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 \]
        7. +-commutativeN/A

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

          \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
        9. unpow2N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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. lower-*.f64N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
        11. +-commutativeN/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
        12. *-commutativeN/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
        13. lower-fma.f64N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
        14. unpow2N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
        15. lower-*.f6495.7

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 81.5%

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

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

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

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

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

        \[\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 \]
    3. Recombined 2 regimes into one program.
    4. Final simplification82.2%

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

    Alternative 9: 92.8% accurate, 2.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 10: 78.9% accurate, 2.2× speedup?

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

      1. Initial program 83.4%

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
        7. lower-neg.f6430.6

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

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

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

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

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

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

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

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

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

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

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

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

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

        1. Initial program 85.8%

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
          7. lower-neg.f6485.7

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

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

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

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

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

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

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

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

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

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

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

        Alternative 11: 77.1% accurate, 2.2× speedup?

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

          1. Initial program 86.4%

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

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

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

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

              \[\leadsto \left(J \cdot \left(\ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \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 \]
            4. associate-*l*N/A

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

              \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \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 \]
            6. lower-*.f64N/A

              \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \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 \]
            7. +-commutativeN/A

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

              \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
            9. unpow2N/A

              \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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. lower-*.f64N/A

              \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
            11. +-commutativeN/A

              \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
            12. *-commutativeN/A

              \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
            13. lower-fma.f64N/A

              \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
            14. unpow2N/A

              \[\leadsto \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \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 \]
            15. lower-*.f6495.7

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

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

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

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

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

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

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

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

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

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

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

          if 9.99999999999999958e27 < (/.f64 K #s(literal 2 binary64))

          1. Initial program 82.0%

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

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

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

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

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

        Alternative 12: 87.1% accurate, 2.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{+209}:\\ \;\;\;\;\mathsf{fma}\left(J \cdot \mathsf{fma}\left(-0.125, \ell \cdot \left(K \cdot K\right), \ell\right), \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\ \mathbf{elif}\;\ell \leq -1.9:\\ \;\;\;\;\mathsf{fma}\left(1 - e^{-\ell}, J, U\right)\\ \mathbf{elif}\;\ell \leq 85:\\ \;\;\;\;\mathsf{fma}\left(\ell, \cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \mathsf{expm1}\left(\ell\right)\\ \end{array} \end{array} \]
        (FPCore (J l K U)
         :precision binary64
         (if (<= l -2e+209)
           (fma
            (* J (fma -0.125 (* l (* K K)) l))
            (fma l (* l 0.3333333333333333) 2.0)
            U)
           (if (<= l -1.9)
             (fma (- 1.0 (exp (- l))) J U)
             (if (<= l 85.0)
               (fma l (* (cos (* K 0.5)) (* J 2.0)) U)
               (* J (expm1 l))))))
        double code(double J, double l, double K, double U) {
        	double tmp;
        	if (l <= -2e+209) {
        		tmp = fma((J * fma(-0.125, (l * (K * K)), l)), fma(l, (l * 0.3333333333333333), 2.0), U);
        	} else if (l <= -1.9) {
        		tmp = fma((1.0 - exp(-l)), J, U);
        	} else if (l <= 85.0) {
        		tmp = fma(l, (cos((K * 0.5)) * (J * 2.0)), U);
        	} else {
        		tmp = J * expm1(l);
        	}
        	return tmp;
        }
        
        function code(J, l, K, U)
        	tmp = 0.0
        	if (l <= -2e+209)
        		tmp = fma(Float64(J * fma(-0.125, Float64(l * Float64(K * K)), l)), fma(l, Float64(l * 0.3333333333333333), 2.0), U);
        	elseif (l <= -1.9)
        		tmp = fma(Float64(1.0 - exp(Float64(-l))), J, U);
        	elseif (l <= 85.0)
        		tmp = fma(l, Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)), U);
        	else
        		tmp = Float64(J * expm1(l));
        	end
        	return tmp
        end
        
        code[J_, l_, K_, U_] := If[LessEqual[l, -2e+209], N[(N[(J * N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision] * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, -1.9], N[(N[(1.0 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 85.0], N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(Exp[l] - 1), $MachinePrecision]), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\ell \leq -2 \cdot 10^{+209}:\\
        \;\;\;\;\mathsf{fma}\left(J \cdot \mathsf{fma}\left(-0.125, \ell \cdot \left(K \cdot K\right), \ell\right), \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\
        
        \mathbf{elif}\;\ell \leq -1.9:\\
        \;\;\;\;\mathsf{fma}\left(1 - e^{-\ell}, J, U\right)\\
        
        \mathbf{elif}\;\ell \leq 85:\\
        \;\;\;\;\mathsf{fma}\left(\ell, \cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right), U\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;J \cdot \mathsf{expm1}\left(\ell\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 4 regimes
        2. if l < -2.0000000000000001e209

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -2.0000000000000001e209 < l < -1.8999999999999999

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

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

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

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

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

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

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

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

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

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

            if -1.8999999999999999 < l < 85

            1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
              7. lower-neg.f6473.6

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

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

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

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

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

                  \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - 1\right)} \]
                2. lower-expm1.f6473.6

                  \[\leadsto J \cdot \color{blue}{\mathsf{expm1}\left(\ell\right)} \]
              4. Simplified73.6%

                \[\leadsto \color{blue}{J \cdot \mathsf{expm1}\left(\ell\right)} \]
            8. Recombined 4 regimes into one program.
            9. Final simplification87.1%

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

            Alternative 13: 75.3% accurate, 2.4× speedup?

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

              1. Initial program 83.4%

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                7. lower-neg.f6430.6

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

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

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

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

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

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

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

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

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

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

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

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

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

                1. Initial program 85.8%

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                  7. lower-neg.f6485.7

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 14: 73.4% accurate, 2.4× speedup?

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

                1. Initial program 83.4%

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                  7. lower-neg.f6430.6

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

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

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

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

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

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

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

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

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

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

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

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

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

                  1. Initial program 85.8%

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

                    \[\leadsto \color{blue}{U + \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} \]
                  5. Simplified85.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                Alternative 15: 58.1% accurate, 2.4× speedup?

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                    7. lower-neg.f6441.3

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

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

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

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

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

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

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

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

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

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

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

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

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

                    1. Initial program 85.7%

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

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                      7. lower-neg.f6485.7

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

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

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

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

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

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

                  Alternative 16: 57.3% accurate, 2.4× speedup?

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

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

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                      7. lower-neg.f6441.3

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

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

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

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

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

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

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

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

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

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

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

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

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

                      1. Initial program 85.7%

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

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

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

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

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

                          \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                        7. lower-neg.f6485.7

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

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

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

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

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

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

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

                    Alternative 17: 54.5% accurate, 27.5× speedup?

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

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                      7. lower-neg.f6470.2

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

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

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

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

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

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

                    Alternative 18: 54.5% accurate, 27.5× speedup?

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

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                      7. lower-neg.f6470.2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 19: 48.5% 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 85.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. *-commutativeN/A

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, J, U\right) \]
                      7. lower-neg.f6470.2

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

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

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

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

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

                          \[\leadsto \color{blue}{J \cdot \ell + U} \]
                        2. lower-fma.f6446.0

                          \[\leadsto \color{blue}{\mathsf{fma}\left(J, \ell, U\right)} \]
                      4. Simplified46.0%

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

                      Reproduce

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