Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.5% → 100.0%
Time: 9.7s
Alternatives: 17
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 86.5% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 2: 71.4% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        1. Initial program 78.2%

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

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

            \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) + U} \]
          2. *-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.f6478.0

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

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

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

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

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

          1. Initial program 99.7%

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

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

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

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

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

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

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

            Alternative 3: 97.2% accurate, 1.2× speedup?

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

              1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              1. Initial program 90.1%

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

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

                  \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) + U} \]
                2. *-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.f6490.1

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

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

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

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

              Alternative 4: 95.6% accurate, 1.2× speedup?

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

                1. Initial program 90.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                1. Initial program 90.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.f6490.2

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

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

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

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

                Alternative 5: 94.2% accurate, 1.3× speedup?

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

                  1. Initial program 90.9%

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

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

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

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

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

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

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

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

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

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

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

                  1. Initial program 90.1%

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

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

                      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) + U} \]
                    2. *-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.f6489.9

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

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

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

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

                  Alternative 6: 87.3% accurate, 1.3× speedup?

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

                    1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    1. Initial program 89.8%

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

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

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

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

                    Alternative 7: 84.9% accurate, 1.4× speedup?

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

                      1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        1. Initial program 89.8%

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

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

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

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

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

                        Alternative 8: 81.0% accurate, 2.0× speedup?

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

                          1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            1. Initial program 89.8%

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

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

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

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

                                \[\leadsto \mathsf{fma}\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), J, U\right) \]
                              3. Step-by-step derivation
                                1. Applied rewrites90.0%

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

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

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

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

                                Alternative 9: 82.0% accurate, 2.0× speedup?

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

                                  1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    1. Initial program 89.8%

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

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

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

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

                                        \[\leadsto \mathsf{fma}\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), J, U\right) \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites90.0%

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

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

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

                                        Alternative 10: 80.5% accurate, 2.2× speedup?

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

                                          1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            1. Initial program 89.8%

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

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

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

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

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

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

                                              Alternative 11: 76.9% accurate, 2.4× speedup?

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

                                                1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  1. Initial program 89.8%

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

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

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

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

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

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

                                                    Alternative 12: 76.0% accurate, 2.4× speedup?

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

                                                      1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                        1. Initial program 89.8%

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

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

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

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

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

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

                                                          Alternative 13: 73.7% accurate, 2.4× speedup?

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

                                                            1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                              1. Initial program 89.8%

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

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

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

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

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

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

                                                                Alternative 14: 68.7% accurate, 2.4× speedup?

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

                                                                  1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                    1. Initial program 89.8%

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

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

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

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

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

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

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

                                                                      Alternative 15: 71.5% accurate, 9.7× speedup?

                                                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.25 \cdot 10^{-5} \lor \neg \left(\ell \leq 1.68 \cdot 10^{+50}\right):\\ \;\;\;\;\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\ \end{array} \end{array} \]
                                                                      (FPCore (J l K U)
                                                                       :precision binary64
                                                                       (if (or (<= l -1.25e-5) (not (<= l 1.68e+50)))
                                                                         (* (* (fma (* l l) 0.3333333333333333 2.0) l) J)
                                                                         (fma (* 2.0 J) l U)))
                                                                      double code(double J, double l, double K, double U) {
                                                                      	double tmp;
                                                                      	if ((l <= -1.25e-5) || !(l <= 1.68e+50)) {
                                                                      		tmp = (fma((l * l), 0.3333333333333333, 2.0) * l) * J;
                                                                      	} else {
                                                                      		tmp = fma((2.0 * J), l, U);
                                                                      	}
                                                                      	return tmp;
                                                                      }
                                                                      
                                                                      function code(J, l, K, U)
                                                                      	tmp = 0.0
                                                                      	if ((l <= -1.25e-5) || !(l <= 1.68e+50))
                                                                      		tmp = Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J);
                                                                      	else
                                                                      		tmp = fma(Float64(2.0 * J), l, U);
                                                                      	end
                                                                      	return tmp
                                                                      end
                                                                      
                                                                      code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.25e-5], N[Not[LessEqual[l, 1.68e+50]], $MachinePrecision]], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision], N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision]]
                                                                      
                                                                      \begin{array}{l}
                                                                      
                                                                      \\
                                                                      \begin{array}{l}
                                                                      \mathbf{if}\;\ell \leq -1.25 \cdot 10^{-5} \lor \neg \left(\ell \leq 1.68 \cdot 10^{+50}\right):\\
                                                                      \;\;\;\;\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\\
                                                                      
                                                                      \mathbf{else}:\\
                                                                      \;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\
                                                                      
                                                                      
                                                                      \end{array}
                                                                      \end{array}
                                                                      
                                                                      Derivation
                                                                      1. Split input into 2 regimes
                                                                      2. if l < -1.25000000000000006e-5 or 1.68000000000000009e50 < l

                                                                        1. Initial program 99.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.f6469.1

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

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

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

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

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

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

                                                                            if -1.25000000000000006e-5 < l < 1.68000000000000009e50

                                                                            1. Initial program 80.6%

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

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

                                                                                \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) + U} \]
                                                                              2. *-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.f6476.4

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

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

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

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

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

                                                                            Alternative 16: 53.9% accurate, 27.5× speedup?

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

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

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

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

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

                                                                              Alternative 17: 19.2% accurate, 30.0× speedup?

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

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

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

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

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

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

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

                                                                                  Reproduce

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