Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.3% → 99.9%
Time: 15.1s
Alternatives: 23
Speedup: 2.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 23 alternatives:

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

Initial Program: 86.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.5× speedup?

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

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

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. Applied egg-rr99.9%

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

    Alternative 2: 86.2% accurate, 0.9× speedup?

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

      1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 3: 86.2% accurate, 0.9× speedup?

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

      1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 82.0%

        \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. Applied egg-rr99.8%

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
        3. Step-by-step derivation
          1. lower-*.f6473.3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 4: 86.2% accurate, 0.9× speedup?

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

        1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        1. Initial program 82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 5: 94.1% accurate, 1.3× speedup?

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

        1. Initial program 82.3%

          \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. Applied egg-rr99.9%

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 87.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 6: 94.1% accurate, 1.3× speedup?

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

          1. Initial program 82.3%

            \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. Applied egg-rr99.9%

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

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

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

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

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

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

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

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

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

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

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

            1. Initial program 87.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 7: 92.7% accurate, 1.3× speedup?

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

            1. Initial program 82.3%

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

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

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

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

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

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

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

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

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

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

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

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

            1. Initial program 87.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 8: 87.2% accurate, 1.4× speedup?

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

            1. Initial program 85.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 9: 88.9% accurate, 1.8× speedup?

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

            1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if 5.00000000000000004e-36 < (/.f64 K #s(literal 2 binary64))

            1. Initial program 81.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 10: 88.5% accurate, 2.0× speedup?

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

            1. Initial program 86.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if 1.2e-9 < (/.f64 K #s(literal 2 binary64))

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 11: 83.5% accurate, 2.0× speedup?

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

            1. Initial program 85.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 12: 83.2% accurate, 2.0× speedup?

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

            1. Initial program 85.9%

              \[\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. Applied egg-rr99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), 0.16666666666666666, \ell\right) \cdot \mathsf{fma}\left(-0.25, \color{blue}{K \cdot K}, 2\right), J, U\right) \]
              7. Simplified53.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 13: 92.4% accurate, 2.1× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(K \cdot 0.5\right)\\ t_1 := \ell \cdot \left(t\_0 \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right)\right)\\ \mathbf{if}\;\ell \leq -2.25 \cdot 10^{+144}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq -0.00162:\\ \;\;\;\;\mathsf{fma}\left(\sinh \ell \cdot J, 2, U\right)\\ \mathbf{elif}\;\ell \leq 1.12 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(t\_0 \cdot \left(2 \cdot \ell\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 9.5 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(J, e^{\ell} + \left(\ell + -1\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
            (FPCore (J l K U)
             :precision binary64
             (let* ((t_0 (cos (* K 0.5)))
                    (t_1 (* l (* t_0 (* J (fma l (* l 0.3333333333333333) 2.0))))))
               (if (<= l -2.25e+144)
                 t_1
                 (if (<= l -0.00162)
                   (fma (* (sinh l) J) 2.0 U)
                   (if (<= l 1.12e-13)
                     (fma (* t_0 (* 2.0 l)) J U)
                     (if (<= l 9.5e+100) (fma J (+ (exp l) (+ l -1.0)) U) t_1))))))
            double code(double J, double l, double K, double U) {
            	double t_0 = cos((K * 0.5));
            	double t_1 = l * (t_0 * (J * fma(l, (l * 0.3333333333333333), 2.0)));
            	double tmp;
            	if (l <= -2.25e+144) {
            		tmp = t_1;
            	} else if (l <= -0.00162) {
            		tmp = fma((sinh(l) * J), 2.0, U);
            	} else if (l <= 1.12e-13) {
            		tmp = fma((t_0 * (2.0 * l)), J, U);
            	} else if (l <= 9.5e+100) {
            		tmp = fma(J, (exp(l) + (l + -1.0)), U);
            	} else {
            		tmp = t_1;
            	}
            	return tmp;
            }
            
            function code(J, l, K, U)
            	t_0 = cos(Float64(K * 0.5))
            	t_1 = Float64(l * Float64(t_0 * Float64(J * fma(l, Float64(l * 0.3333333333333333), 2.0))))
            	tmp = 0.0
            	if (l <= -2.25e+144)
            		tmp = t_1;
            	elseif (l <= -0.00162)
            		tmp = fma(Float64(sinh(l) * J), 2.0, U);
            	elseif (l <= 1.12e-13)
            		tmp = fma(Float64(t_0 * Float64(2.0 * l)), J, U);
            	elseif (l <= 9.5e+100)
            		tmp = fma(J, Float64(exp(l) + Float64(l + -1.0)), U);
            	else
            		tmp = t_1;
            	end
            	return tmp
            end
            
            code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(l * N[(t$95$0 * N[(J * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.25e+144], t$95$1, If[LessEqual[l, -0.00162], N[(N[(N[Sinh[l], $MachinePrecision] * J), $MachinePrecision] * 2.0 + U), $MachinePrecision], If[LessEqual[l, 1.12e-13], N[(N[(t$95$0 * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 9.5e+100], N[(J * N[(N[Exp[l], $MachinePrecision] + N[(l + -1.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], t$95$1]]]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \cos \left(K \cdot 0.5\right)\\
            t_1 := \ell \cdot \left(t\_0 \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right)\right)\\
            \mathbf{if}\;\ell \leq -2.25 \cdot 10^{+144}:\\
            \;\;\;\;t\_1\\
            
            \mathbf{elif}\;\ell \leq -0.00162:\\
            \;\;\;\;\mathsf{fma}\left(\sinh \ell \cdot J, 2, U\right)\\
            
            \mathbf{elif}\;\ell \leq 1.12 \cdot 10^{-13}:\\
            \;\;\;\;\mathsf{fma}\left(t\_0 \cdot \left(2 \cdot \ell\right), J, U\right)\\
            
            \mathbf{elif}\;\ell \leq 9.5 \cdot 10^{+100}:\\
            \;\;\;\;\mathsf{fma}\left(J, e^{\ell} + \left(\ell + -1\right), U\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_1\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 4 regimes
            2. if l < -2.24999999999999984e144 or 9.4999999999999995e100 < l

              1. Initial program 100.0%

                \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              2. Add Preprocessing
              3. Step-by-step derivation
                1. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                if -2.24999999999999984e144 < l < -0.0016199999999999999

                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. lower-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if -0.0016199999999999999 < l < 1.12e-13

                1. Initial program 70.0%

                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. Applied egg-rr99.9%

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

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(K \cdot \frac{1}{2}\right), J, U\right) \]
                  3. Step-by-step derivation
                    1. lower-*.f6499.4

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

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

                  if 1.12e-13 < l < 9.4999999999999995e100

                  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. lower-fma.f64N/A

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \left(1 + \color{blue}{\left(\mathsf{neg}\left(\ell\right)\right)}\right), U\right) \]
                    2. unsub-negN/A

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

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

                    \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{\left(1 - \ell\right)}, U\right) \]
                4. Recombined 4 regimes into one program.
                5. Final simplification95.5%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.25 \cdot 10^{+144}:\\ \;\;\;\;\ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right)\right)\\ \mathbf{elif}\;\ell \leq -0.00162:\\ \;\;\;\;\mathsf{fma}\left(\sinh \ell \cdot J, 2, U\right)\\ \mathbf{elif}\;\ell \leq 1.12 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot \ell\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 9.5 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(J, e^{\ell} + \left(\ell + -1\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right)\right)\\ \end{array} \]
                6. Add Preprocessing

                Alternative 14: 81.8% accurate, 2.1× speedup?

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

                  1. Initial program 85.9%

                    \[\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. Applied egg-rr99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \left(\ell \cdot \ell\right), 0.16666666666666666, \ell\right) \cdot \mathsf{fma}\left(-0.25, \color{blue}{K \cdot K}, 2\right), J, U\right) \]
                    7. Simplified53.5%

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

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

                    1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 15: 76.4% accurate, 2.2× speedup?

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

                    1. Initial program 85.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    1. Initial program 85.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 16: 72.7% accurate, 2.2× speedup?

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

                    1. Initial program 85.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    1. Initial program 85.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 17: 73.5% accurate, 2.2× speedup?

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

                    1. Initial program 85.0%

                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    2. Add Preprocessing
                    3. Taylor expanded in l around 0

                      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                    4. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                      2. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                      3. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                      4. *-commutativeN/A

                        \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                      5. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                      6. lower-cos.f64N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                      7. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                      8. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                      9. associate-*l*N/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                      10. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                      11. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                      12. lower-*.f6461.8

                        \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                    5. Simplified61.8%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                    6. Taylor expanded in K around 0

                      \[\leadsto \color{blue}{U + \left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                    7. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right) + U} \]
                      2. associate-+l+N/A

                        \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + \left(2 \cdot \left(J \cdot \ell\right) + U\right)} \]
                      3. +-commutativeN/A

                        \[\leadsto \frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + \color{blue}{\left(U + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                      4. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, J \cdot \left({K}^{2} \cdot \ell\right), U + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                      5. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, \color{blue}{J \cdot \left({K}^{2} \cdot \ell\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      6. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \color{blue}{\left(\ell \cdot {K}^{2}\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      7. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \color{blue}{\left(\ell \cdot {K}^{2}\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      8. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \color{blue}{\left(K \cdot K\right)}\right), U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      9. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \color{blue}{\left(K \cdot K\right)}\right), U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \color{blue}{2 \cdot \left(J \cdot \ell\right) + U}\right) \]
                      11. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)}\right) \]
                      12. lower-*.f6442.9

                        \[\leadsto \mathsf{fma}\left(-0.25, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right)\right) \]
                    8. Simplified42.9%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.25, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \mathsf{fma}\left(2, J \cdot \ell, U\right)\right)} \]
                    9. Step-by-step derivation
                      1. associate-*r*N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \color{blue}{\left(\left(\ell \cdot K\right) \cdot K\right)}, \mathsf{fma}\left(2, J \cdot \ell, U\right)\right) \]
                      2. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \color{blue}{\left(\left(\ell \cdot K\right) \cdot K\right)}, \mathsf{fma}\left(2, J \cdot \ell, U\right)\right) \]
                      3. lower-*.f6451.3

                        \[\leadsto \mathsf{fma}\left(-0.25, J \cdot \left(\color{blue}{\left(\ell \cdot K\right)} \cdot K\right), \mathsf{fma}\left(2, J \cdot \ell, U\right)\right) \]
                    10. Applied egg-rr51.3%

                      \[\leadsto \mathsf{fma}\left(-0.25, J \cdot \color{blue}{\left(\left(\ell \cdot K\right) \cdot K\right)}, \mathsf{fma}\left(2, J \cdot \ell, U\right)\right) \]

                    if -0.309999999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                    1. Initial program 85.4%

                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    2. Add Preprocessing
                    3. Taylor expanded in K around 0

                      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
                    4. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) + U} \]
                      2. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                      3. lower--.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      4. lower-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}, U\right) \]
                      5. lower-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      6. lower-neg.f6483.3

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{-\ell}}, U\right) \]
                    5. Simplified83.3%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{-\ell}, U\right)} \]
                    6. Taylor expanded in l around 0

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}, U\right) \]
                    7. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}, U\right) \]
                      2. +-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)}, U\right) \]
                      3. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \frac{1}{3}} + 2\right), U\right) \]
                      4. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{3} + 2\right), U\right) \]
                      5. associate-*l*N/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{3}\right)} + 2\right), U\right) \]
                      6. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \frac{1}{3}, 2\right)}, U\right) \]
                      7. lower-*.f6480.2

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot 0.3333333333333333}, 2\right), U\right) \]
                    8. Simplified80.2%

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)}, U\right) \]
                  3. Recombined 2 regimes into one program.
                  4. Final simplification75.0%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.31:\\ \;\;\;\;\mathsf{fma}\left(-0.25, J \cdot \left(K \cdot \left(\ell \cdot K\right)\right), \mathsf{fma}\left(2, \ell \cdot J, U\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\ \end{array} \]
                  5. Add Preprocessing

                  Alternative 18: 76.0% accurate, 2.4× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot J, \mathsf{fma}\left(-0.25, K \cdot K, 2\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\ \end{array} \end{array} \]
                  (FPCore (J l K U)
                   :precision binary64
                   (if (<= (cos (/ K 2.0)) -0.02)
                     (fma (* l J) (fma -0.25 (* K K) 2.0) U)
                     (fma J (* l (fma l (* l 0.3333333333333333) 2.0)) U)))
                  double code(double J, double l, double K, double U) {
                  	double tmp;
                  	if (cos((K / 2.0)) <= -0.02) {
                  		tmp = fma((l * J), fma(-0.25, (K * K), 2.0), U);
                  	} else {
                  		tmp = fma(J, (l * fma(l, (l * 0.3333333333333333), 2.0)), U);
                  	}
                  	return tmp;
                  }
                  
                  function code(J, l, K, U)
                  	tmp = 0.0
                  	if (cos(Float64(K / 2.0)) <= -0.02)
                  		tmp = fma(Float64(l * J), fma(-0.25, Float64(K * K), 2.0), U);
                  	else
                  		tmp = fma(J, Float64(l * fma(l, Float64(l * 0.3333333333333333), 2.0)), U);
                  	end
                  	return tmp
                  end
                  
                  code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(N[(l * J), $MachinePrecision] * N[(-0.25 * N[(K * K), $MachinePrecision] + 2.0), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(l * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
                  \;\;\;\;\mathsf{fma}\left(\ell \cdot J, \mathsf{fma}\left(-0.25, K \cdot K, 2\right), U\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0200000000000000004

                    1. Initial program 85.9%

                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    2. Add Preprocessing
                    3. Taylor expanded in l around 0

                      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                    4. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                      2. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                      3. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                      4. *-commutativeN/A

                        \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                      5. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                      6. lower-cos.f64N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                      7. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                      8. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                      9. associate-*l*N/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                      10. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                      11. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                      12. lower-*.f6466.8

                        \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                    5. Simplified66.8%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                    6. Taylor expanded in K around 0

                      \[\leadsto \mathsf{fma}\left(\color{blue}{1 + {K}^{2} \cdot \left(\frac{1}{384} \cdot {K}^{2} - \frac{1}{8}\right)}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                    7. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{{K}^{2} \cdot \left(\frac{1}{384} \cdot {K}^{2} - \frac{1}{8}\right) + 1}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                      2. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(K \cdot K\right)} \cdot \left(\frac{1}{384} \cdot {K}^{2} - \frac{1}{8}\right) + 1, J \cdot \left(\ell \cdot 2\right), U\right) \]
                      3. associate-*l*N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{K \cdot \left(K \cdot \left(\frac{1}{384} \cdot {K}^{2} - \frac{1}{8}\right)\right)} + 1, J \cdot \left(\ell \cdot 2\right), U\right) \]
                      4. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(K, K \cdot \left(\frac{1}{384} \cdot {K}^{2} - \frac{1}{8}\right), 1\right)}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                      5. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, \color{blue}{K \cdot \left(\frac{1}{384} \cdot {K}^{2} - \frac{1}{8}\right)}, 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                      6. sub-negN/A

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot \color{blue}{\left(\frac{1}{384} \cdot {K}^{2} + \left(\mathsf{neg}\left(\frac{1}{8}\right)\right)\right)}, 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                      7. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot \left(\color{blue}{{K}^{2} \cdot \frac{1}{384}} + \left(\mathsf{neg}\left(\frac{1}{8}\right)\right)\right), 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                      8. metadata-evalN/A

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot \left({K}^{2} \cdot \frac{1}{384} + \color{blue}{\frac{-1}{8}}\right), 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                      9. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot \color{blue}{\mathsf{fma}\left({K}^{2}, \frac{1}{384}, \frac{-1}{8}\right)}, 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                      10. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, \frac{1}{384}, \frac{-1}{8}\right), 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                      11. lower-*.f642.7

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K, K \cdot \mathsf{fma}\left(\color{blue}{K \cdot K}, 0.0026041666666666665, -0.125\right), 1\right), J \cdot \left(\ell \cdot 2\right), U\right) \]
                    8. Simplified2.7%

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(K, K \cdot \mathsf{fma}\left(K \cdot K, 0.0026041666666666665, -0.125\right), 1\right)}, J \cdot \left(\ell \cdot 2\right), U\right) \]
                    9. Taylor expanded in K around 0

                      \[\leadsto \color{blue}{U + \left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                    10. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right) + U} \]
                      2. *-commutativeN/A

                        \[\leadsto \left(\frac{-1}{4} \cdot \left(J \cdot \color{blue}{\left(\ell \cdot {K}^{2}\right)}\right) + 2 \cdot \left(J \cdot \ell\right)\right) + U \]
                      3. associate-*r*N/A

                        \[\leadsto \left(\frac{-1}{4} \cdot \color{blue}{\left(\left(J \cdot \ell\right) \cdot {K}^{2}\right)} + 2 \cdot \left(J \cdot \ell\right)\right) + U \]
                      4. associate-*l*N/A

                        \[\leadsto \left(\color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \ell\right)\right) \cdot {K}^{2}} + 2 \cdot \left(J \cdot \ell\right)\right) + U \]
                      5. *-commutativeN/A

                        \[\leadsto \left(\color{blue}{\left(\left(J \cdot \ell\right) \cdot \frac{-1}{4}\right)} \cdot {K}^{2} + 2 \cdot \left(J \cdot \ell\right)\right) + U \]
                      6. associate-*l*N/A

                        \[\leadsto \left(\color{blue}{\left(J \cdot \ell\right) \cdot \left(\frac{-1}{4} \cdot {K}^{2}\right)} + 2 \cdot \left(J \cdot \ell\right)\right) + U \]
                      7. *-commutativeN/A

                        \[\leadsto \left(\left(J \cdot \ell\right) \cdot \left(\frac{-1}{4} \cdot {K}^{2}\right) + \color{blue}{\left(J \cdot \ell\right) \cdot 2}\right) + U \]
                      8. distribute-lft-outN/A

                        \[\leadsto \color{blue}{\left(J \cdot \ell\right) \cdot \left(\frac{-1}{4} \cdot {K}^{2} + 2\right)} + U \]
                      9. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(J \cdot \ell, \frac{-1}{4} \cdot {K}^{2} + 2, U\right)} \]
                      10. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{J \cdot \ell}, \frac{-1}{4} \cdot {K}^{2} + 2, U\right) \]
                      11. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(J \cdot \ell, \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {K}^{2}, 2\right)}, U\right) \]
                      12. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(J \cdot \ell, \mathsf{fma}\left(\frac{-1}{4}, \color{blue}{K \cdot K}, 2\right), U\right) \]
                      13. lower-*.f6450.1

                        \[\leadsto \mathsf{fma}\left(J \cdot \ell, \mathsf{fma}\left(-0.25, \color{blue}{K \cdot K}, 2\right), U\right) \]
                    11. Simplified50.1%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J \cdot \ell, \mathsf{fma}\left(-0.25, K \cdot K, 2\right), U\right)} \]

                    if -0.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                    1. Initial program 85.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. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                      3. lower--.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      4. lower-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}, U\right) \]
                      5. lower-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      6. lower-neg.f6485.0

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{-\ell}}, U\right) \]
                    5. Simplified85.0%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{-\ell}, U\right)} \]
                    6. Taylor expanded in l around 0

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}, U\right) \]
                    7. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}, U\right) \]
                      2. +-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)}, U\right) \]
                      3. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \frac{1}{3}} + 2\right), U\right) \]
                      4. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{3} + 2\right), U\right) \]
                      5. associate-*l*N/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{3}\right)} + 2\right), U\right) \]
                      6. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \frac{1}{3}, 2\right)}, U\right) \]
                      7. lower-*.f6481.7

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot 0.3333333333333333}, 2\right), U\right) \]
                    8. Simplified81.7%

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)}, U\right) \]
                  3. Recombined 2 regimes into one program.
                  4. Final simplification74.8%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot J, \mathsf{fma}\left(-0.25, K \cdot K, 2\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\ \end{array} \]
                  5. Add Preprocessing

                  Alternative 19: 70.7% accurate, 8.2× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{K}{2} \leq 5 \cdot 10^{+294}:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;-0.25 \cdot \left(\ell \cdot \left(J \cdot \left(K \cdot K\right)\right)\right)\\ \end{array} \end{array} \]
                  (FPCore (J l K U)
                   :precision binary64
                   (if (<= (/ K 2.0) 5e+294)
                     (fma J (* l (fma l (* l 0.3333333333333333) 2.0)) U)
                     (* -0.25 (* l (* J (* K K))))))
                  double code(double J, double l, double K, double U) {
                  	double tmp;
                  	if ((K / 2.0) <= 5e+294) {
                  		tmp = fma(J, (l * fma(l, (l * 0.3333333333333333), 2.0)), U);
                  	} else {
                  		tmp = -0.25 * (l * (J * (K * K)));
                  	}
                  	return tmp;
                  }
                  
                  function code(J, l, K, U)
                  	tmp = 0.0
                  	if (Float64(K / 2.0) <= 5e+294)
                  		tmp = fma(J, Float64(l * fma(l, Float64(l * 0.3333333333333333), 2.0)), U);
                  	else
                  		tmp = Float64(-0.25 * Float64(l * Float64(J * Float64(K * K))));
                  	end
                  	return tmp
                  end
                  
                  code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 5e+294], N[(J * N[(l * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(-0.25 * N[(l * N[(J * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;\frac{K}{2} \leq 5 \cdot 10^{+294}:\\
                  \;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;-0.25 \cdot \left(\ell \cdot \left(J \cdot \left(K \cdot K\right)\right)\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (/.f64 K #s(literal 2 binary64)) < 4.9999999999999999e294

                    1. Initial program 85.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. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                      3. lower--.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      4. lower-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}, U\right) \]
                      5. lower-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      6. lower-neg.f6474.9

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{-\ell}}, U\right) \]
                    5. Simplified74.9%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{-\ell}, U\right)} \]
                    6. Taylor expanded in l around 0

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}, U\right) \]
                    7. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}, U\right) \]
                      2. +-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)}, U\right) \]
                      3. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \frac{1}{3}} + 2\right), U\right) \]
                      4. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{3} + 2\right), U\right) \]
                      5. associate-*l*N/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \left(\color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{3}\right)} + 2\right), U\right) \]
                      6. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \frac{1}{3}, 2\right)}, U\right) \]
                      7. lower-*.f6472.3

                        \[\leadsto \mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot 0.3333333333333333}, 2\right), U\right) \]
                    8. Simplified72.3%

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)}, U\right) \]

                    if 4.9999999999999999e294 < (/.f64 K #s(literal 2 binary64))

                    1. Initial program 100.0%

                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    2. Add Preprocessing
                    3. Taylor expanded in l around 0

                      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                    4. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                      2. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                      3. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                      4. *-commutativeN/A

                        \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                      5. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                      6. lower-cos.f64N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                      7. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                      8. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                      9. associate-*l*N/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                      10. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                      11. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                      12. lower-*.f6452.3

                        \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                    5. Simplified52.3%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                    6. Taylor expanded in K around 0

                      \[\leadsto \color{blue}{U + \left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                    7. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right) + U} \]
                      2. associate-+l+N/A

                        \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + \left(2 \cdot \left(J \cdot \ell\right) + U\right)} \]
                      3. +-commutativeN/A

                        \[\leadsto \frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + \color{blue}{\left(U + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                      4. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, J \cdot \left({K}^{2} \cdot \ell\right), U + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                      5. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, \color{blue}{J \cdot \left({K}^{2} \cdot \ell\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      6. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \color{blue}{\left(\ell \cdot {K}^{2}\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      7. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \color{blue}{\left(\ell \cdot {K}^{2}\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      8. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \color{blue}{\left(K \cdot K\right)}\right), U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      9. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \color{blue}{\left(K \cdot K\right)}\right), U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \color{blue}{2 \cdot \left(J \cdot \ell\right) + U}\right) \]
                      11. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)}\right) \]
                      12. lower-*.f6450.0

                        \[\leadsto \mathsf{fma}\left(-0.25, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right)\right) \]
                    8. Simplified50.0%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.25, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \mathsf{fma}\left(2, J \cdot \ell, U\right)\right)} \]
                    9. Taylor expanded in K around inf

                      \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right)} \]
                    10. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right)} \]
                      2. associate-*r*N/A

                        \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\left(J \cdot {K}^{2}\right) \cdot \ell\right)} \]
                      3. *-commutativeN/A

                        \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\ell \cdot \left(J \cdot {K}^{2}\right)\right)} \]
                      4. lower-*.f64N/A

                        \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\ell \cdot \left(J \cdot {K}^{2}\right)\right)} \]
                      5. lower-*.f64N/A

                        \[\leadsto \frac{-1}{4} \cdot \left(\ell \cdot \color{blue}{\left(J \cdot {K}^{2}\right)}\right) \]
                      6. unpow2N/A

                        \[\leadsto \frac{-1}{4} \cdot \left(\ell \cdot \left(J \cdot \color{blue}{\left(K \cdot K\right)}\right)\right) \]
                      7. lower-*.f64100.0

                        \[\leadsto -0.25 \cdot \left(\ell \cdot \left(J \cdot \color{blue}{\left(K \cdot K\right)}\right)\right) \]
                    11. Simplified100.0%

                      \[\leadsto \color{blue}{-0.25 \cdot \left(\ell \cdot \left(J \cdot \left(K \cdot K\right)\right)\right)} \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 20: 52.9% accurate, 8.7× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{K}{2} \leq 5 \cdot 10^{+294}:\\ \;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;-0.25 \cdot \left(\ell \cdot \left(J \cdot \left(K \cdot K\right)\right)\right)\\ \end{array} \end{array} \]
                  (FPCore (J l K U)
                   :precision binary64
                   (if (<= (/ K 2.0) 5e+294) (fma J (* 2.0 l) U) (* -0.25 (* l (* J (* K K))))))
                  double code(double J, double l, double K, double U) {
                  	double tmp;
                  	if ((K / 2.0) <= 5e+294) {
                  		tmp = fma(J, (2.0 * l), U);
                  	} else {
                  		tmp = -0.25 * (l * (J * (K * K)));
                  	}
                  	return tmp;
                  }
                  
                  function code(J, l, K, U)
                  	tmp = 0.0
                  	if (Float64(K / 2.0) <= 5e+294)
                  		tmp = fma(J, Float64(2.0 * l), U);
                  	else
                  		tmp = Float64(-0.25 * Float64(l * Float64(J * Float64(K * K))));
                  	end
                  	return tmp
                  end
                  
                  code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 5e+294], N[(J * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision], N[(-0.25 * N[(l * N[(J * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;\frac{K}{2} \leq 5 \cdot 10^{+294}:\\
                  \;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;-0.25 \cdot \left(\ell \cdot \left(J \cdot \left(K \cdot K\right)\right)\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (/.f64 K #s(literal 2 binary64)) < 4.9999999999999999e294

                    1. Initial program 85.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. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                      3. lower--.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      4. lower-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}, U\right) \]
                      5. lower-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      6. lower-neg.f6474.9

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{-\ell}}, U\right) \]
                    5. Simplified74.9%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{-\ell}, U\right)} \]
                    6. Taylor expanded in l around 0

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                    7. Step-by-step derivation
                      1. lower-*.f6452.7

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                    8. Simplified52.7%

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]

                    if 4.9999999999999999e294 < (/.f64 K #s(literal 2 binary64))

                    1. Initial program 100.0%

                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    2. Add Preprocessing
                    3. Taylor expanded in l around 0

                      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                    4. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                      2. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                      3. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                      4. *-commutativeN/A

                        \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                      5. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                      6. lower-cos.f64N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                      7. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                      8. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                      9. associate-*l*N/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                      10. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                      11. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                      12. lower-*.f6452.3

                        \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                    5. Simplified52.3%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                    6. Taylor expanded in K around 0

                      \[\leadsto \color{blue}{U + \left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                    7. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right) + U} \]
                      2. associate-+l+N/A

                        \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + \left(2 \cdot \left(J \cdot \ell\right) + U\right)} \]
                      3. +-commutativeN/A

                        \[\leadsto \frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + \color{blue}{\left(U + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                      4. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, J \cdot \left({K}^{2} \cdot \ell\right), U + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                      5. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, \color{blue}{J \cdot \left({K}^{2} \cdot \ell\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      6. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \color{blue}{\left(\ell \cdot {K}^{2}\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      7. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \color{blue}{\left(\ell \cdot {K}^{2}\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      8. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \color{blue}{\left(K \cdot K\right)}\right), U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      9. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \color{blue}{\left(K \cdot K\right)}\right), U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \color{blue}{2 \cdot \left(J \cdot \ell\right) + U}\right) \]
                      11. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)}\right) \]
                      12. lower-*.f6450.0

                        \[\leadsto \mathsf{fma}\left(-0.25, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right)\right) \]
                    8. Simplified50.0%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.25, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \mathsf{fma}\left(2, J \cdot \ell, U\right)\right)} \]
                    9. Taylor expanded in K around inf

                      \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right)} \]
                    10. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right)} \]
                      2. associate-*r*N/A

                        \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\left(J \cdot {K}^{2}\right) \cdot \ell\right)} \]
                      3. *-commutativeN/A

                        \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\ell \cdot \left(J \cdot {K}^{2}\right)\right)} \]
                      4. lower-*.f64N/A

                        \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\ell \cdot \left(J \cdot {K}^{2}\right)\right)} \]
                      5. lower-*.f64N/A

                        \[\leadsto \frac{-1}{4} \cdot \left(\ell \cdot \color{blue}{\left(J \cdot {K}^{2}\right)}\right) \]
                      6. unpow2N/A

                        \[\leadsto \frac{-1}{4} \cdot \left(\ell \cdot \left(J \cdot \color{blue}{\left(K \cdot K\right)}\right)\right) \]
                      7. lower-*.f64100.0

                        \[\leadsto -0.25 \cdot \left(\ell \cdot \left(J \cdot \color{blue}{\left(K \cdot K\right)}\right)\right) \]
                    11. Simplified100.0%

                      \[\leadsto \color{blue}{-0.25 \cdot \left(\ell \cdot \left(J \cdot \left(K \cdot K\right)\right)\right)} \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 21: 58.6% accurate, 9.7× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \ell \cdot \left(J \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right)\\ \mathbf{if}\;\ell \leq -7.6 \cdot 10^{+72}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 3 \cdot 10^{+27}:\\ \;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                  (FPCore (J l K U)
                   :precision binary64
                   (let* ((t_0 (* l (* J (fma -0.25 (* K K) 2.0)))))
                     (if (<= l -7.6e+72) t_0 (if (<= l 3e+27) (fma J (* 2.0 l) U) t_0))))
                  double code(double J, double l, double K, double U) {
                  	double t_0 = l * (J * fma(-0.25, (K * K), 2.0));
                  	double tmp;
                  	if (l <= -7.6e+72) {
                  		tmp = t_0;
                  	} else if (l <= 3e+27) {
                  		tmp = fma(J, (2.0 * l), U);
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  function code(J, l, K, U)
                  	t_0 = Float64(l * Float64(J * fma(-0.25, Float64(K * K), 2.0)))
                  	tmp = 0.0
                  	if (l <= -7.6e+72)
                  		tmp = t_0;
                  	elseif (l <= 3e+27)
                  		tmp = fma(J, Float64(2.0 * l), U);
                  	else
                  		tmp = t_0;
                  	end
                  	return tmp
                  end
                  
                  code[J_, l_, K_, U_] := Block[{t$95$0 = N[(l * N[(J * N[(-0.25 * N[(K * K), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -7.6e+72], t$95$0, If[LessEqual[l, 3e+27], N[(J * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision], t$95$0]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \ell \cdot \left(J \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right)\\
                  \mathbf{if}\;\ell \leq -7.6 \cdot 10^{+72}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;\ell \leq 3 \cdot 10^{+27}:\\
                  \;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if l < -7.60000000000000012e72 or 2.99999999999999976e27 < l

                    1. Initial program 100.0%

                      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                    2. Add Preprocessing
                    3. Taylor expanded in l around 0

                      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
                    4. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U} \]
                      2. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + U \]
                      3. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                      4. *-commutativeN/A

                        \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\left(2 \cdot J\right) \cdot \ell\right)} + U \]
                      5. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(2 \cdot J\right) \cdot \ell, U\right)} \]
                      6. lower-cos.f64N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                      7. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, \left(2 \cdot J\right) \cdot \ell, U\right) \]
                      8. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{\left(J \cdot 2\right)} \cdot \ell, U\right) \]
                      9. associate-*l*N/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                      10. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), \color{blue}{J \cdot \left(2 \cdot \ell\right)}, U\right) \]
                      11. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                      12. lower-*.f6429.1

                        \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \color{blue}{\left(\ell \cdot 2\right)}, U\right) \]
                    5. Simplified29.1%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), J \cdot \left(\ell \cdot 2\right), U\right)} \]
                    6. Taylor expanded in K around 0

                      \[\leadsto \color{blue}{U + \left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                    7. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right) + U} \]
                      2. associate-+l+N/A

                        \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + \left(2 \cdot \left(J \cdot \ell\right) + U\right)} \]
                      3. +-commutativeN/A

                        \[\leadsto \frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + \color{blue}{\left(U + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                      4. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, J \cdot \left({K}^{2} \cdot \ell\right), U + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                      5. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, \color{blue}{J \cdot \left({K}^{2} \cdot \ell\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      6. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \color{blue}{\left(\ell \cdot {K}^{2}\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      7. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \color{blue}{\left(\ell \cdot {K}^{2}\right)}, U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      8. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \color{blue}{\left(K \cdot K\right)}\right), U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      9. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \color{blue}{\left(K \cdot K\right)}\right), U + 2 \cdot \left(J \cdot \ell\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \color{blue}{2 \cdot \left(J \cdot \ell\right) + U}\right) \]
                      11. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \color{blue}{\mathsf{fma}\left(2, J \cdot \ell, U\right)}\right) \]
                      12. lower-*.f6428.6

                        \[\leadsto \mathsf{fma}\left(-0.25, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \mathsf{fma}\left(2, \color{blue}{J \cdot \ell}, U\right)\right) \]
                    8. Simplified28.6%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.25, J \cdot \left(\ell \cdot \left(K \cdot K\right)\right), \mathsf{fma}\left(2, J \cdot \ell, U\right)\right)} \]
                    9. Taylor expanded in J around inf

                      \[\leadsto \color{blue}{J \cdot \left(\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell\right)} \]
                    10. Step-by-step derivation
                      1. distribute-rgt-inN/A

                        \[\leadsto \color{blue}{\left(\frac{-1}{4} \cdot \left({K}^{2} \cdot \ell\right)\right) \cdot J + \left(2 \cdot \ell\right) \cdot J} \]
                      2. associate-*r*N/A

                        \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(\left({K}^{2} \cdot \ell\right) \cdot J\right)} + \left(2 \cdot \ell\right) \cdot J \]
                      3. *-commutativeN/A

                        \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(J \cdot \left({K}^{2} \cdot \ell\right)\right)} + \left(2 \cdot \ell\right) \cdot J \]
                      4. associate-*r*N/A

                        \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(\left(J \cdot {K}^{2}\right) \cdot \ell\right)} + \left(2 \cdot \ell\right) \cdot J \]
                      5. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right)\right) \cdot \ell} + \left(2 \cdot \ell\right) \cdot J \]
                      6. *-commutativeN/A

                        \[\leadsto \color{blue}{\ell \cdot \left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right)\right)} + \left(2 \cdot \ell\right) \cdot J \]
                      7. *-commutativeN/A

                        \[\leadsto \ell \cdot \left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right)\right) + \color{blue}{\left(\ell \cdot 2\right)} \cdot J \]
                      8. associate-*r*N/A

                        \[\leadsto \ell \cdot \left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right)\right) + \color{blue}{\ell \cdot \left(2 \cdot J\right)} \]
                      9. distribute-lft-inN/A

                        \[\leadsto \color{blue}{\ell \cdot \left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right) + 2 \cdot J\right)} \]
                      10. lower-*.f64N/A

                        \[\leadsto \color{blue}{\ell \cdot \left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right) + 2 \cdot J\right)} \]
                      11. *-commutativeN/A

                        \[\leadsto \ell \cdot \left(\frac{-1}{4} \cdot \color{blue}{\left({K}^{2} \cdot J\right)} + 2 \cdot J\right) \]
                      12. associate-*r*N/A

                        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{-1}{4} \cdot {K}^{2}\right) \cdot J} + 2 \cdot J\right) \]
                      13. distribute-rgt-outN/A

                        \[\leadsto \ell \cdot \color{blue}{\left(J \cdot \left(\frac{-1}{4} \cdot {K}^{2} + 2\right)\right)} \]
                      14. lower-*.f64N/A

                        \[\leadsto \ell \cdot \color{blue}{\left(J \cdot \left(\frac{-1}{4} \cdot {K}^{2} + 2\right)\right)} \]
                      15. lower-fma.f64N/A

                        \[\leadsto \ell \cdot \left(J \cdot \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {K}^{2}, 2\right)}\right) \]
                      16. unpow2N/A

                        \[\leadsto \ell \cdot \left(J \cdot \mathsf{fma}\left(\frac{-1}{4}, \color{blue}{K \cdot K}, 2\right)\right) \]
                      17. lower-*.f6436.1

                        \[\leadsto \ell \cdot \left(J \cdot \mathsf{fma}\left(-0.25, \color{blue}{K \cdot K}, 2\right)\right) \]
                    11. Simplified36.1%

                      \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right)} \]

                    if -7.60000000000000012e72 < l < 2.99999999999999976e27

                    1. Initial program 73.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 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. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                      3. lower--.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      4. lower-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}, U\right) \]
                      5. lower-exp.f64N/A

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                      6. lower-neg.f6471.0

                        \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{-\ell}}, U\right) \]
                    5. Simplified71.0%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{-\ell}, U\right)} \]
                    6. Taylor expanded in l around 0

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                    7. Step-by-step derivation
                      1. lower-*.f6476.4

                        \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                    8. Simplified76.4%

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 22: 53.1% accurate, 27.5× speedup?

                  \[\begin{array}{l} \\ \mathsf{fma}\left(J, 2 \cdot \ell, U\right) \end{array} \]
                  (FPCore (J l K U) :precision binary64 (fma J (* 2.0 l) U))
                  double code(double J, double l, double K, double U) {
                  	return fma(J, (2.0 * l), U);
                  }
                  
                  function code(J, l, K, U)
                  	return fma(J, Float64(2.0 * l), U)
                  end
                  
                  code[J_, l_, K_, U_] := N[(J * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  \mathsf{fma}\left(J, 2 \cdot \ell, U\right)
                  \end{array}
                  
                  Derivation
                  1. Initial program 85.3%

                    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  2. Add Preprocessing
                  3. Taylor expanded in K around 0

                    \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) + U} \]
                    2. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                    3. lower--.f64N/A

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                    4. lower-exp.f64N/A

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}, U\right) \]
                    5. lower-exp.f64N/A

                      \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                    6. lower-neg.f6474.3

                      \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{-\ell}}, U\right) \]
                  5. Simplified74.3%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{-\ell}, U\right)} \]
                  6. Taylor expanded in l around 0

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                  7. Step-by-step derivation
                    1. lower-*.f6452.3

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                  8. Simplified52.3%

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                  9. Add Preprocessing

                  Alternative 23: 19.1% accurate, 30.0× speedup?

                  \[\begin{array}{l} \\ J \cdot \left(2 \cdot \ell\right) \end{array} \]
                  (FPCore (J l K U) :precision binary64 (* J (* 2.0 l)))
                  double code(double J, double l, double K, double U) {
                  	return J * (2.0 * l);
                  }
                  
                  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 * (2.0d0 * l)
                  end function
                  
                  public static double code(double J, double l, double K, double U) {
                  	return J * (2.0 * l);
                  }
                  
                  def code(J, l, K, U):
                  	return J * (2.0 * l)
                  
                  function code(J, l, K, U)
                  	return Float64(J * Float64(2.0 * l))
                  end
                  
                  function tmp = code(J, l, K, U)
                  	tmp = J * (2.0 * l);
                  end
                  
                  code[J_, l_, K_, U_] := N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  J \cdot \left(2 \cdot \ell\right)
                  \end{array}
                  
                  Derivation
                  1. Initial program 85.3%

                    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                  2. Add Preprocessing
                  3. Taylor expanded in K around 0

                    \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)} \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) + U} \]
                    2. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, U\right)} \]
                    3. lower--.f64N/A

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                    4. lower-exp.f64N/A

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{e^{\ell}} - e^{\mathsf{neg}\left(\ell\right)}, U\right) \]
                    5. lower-exp.f64N/A

                      \[\leadsto \mathsf{fma}\left(J, e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}, U\right) \]
                    6. lower-neg.f6474.3

                      \[\leadsto \mathsf{fma}\left(J, e^{\ell} - e^{\color{blue}{-\ell}}, U\right) \]
                  5. Simplified74.3%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(J, e^{\ell} - e^{-\ell}, U\right)} \]
                  6. Taylor expanded in l around 0

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                  7. Step-by-step derivation
                    1. lower-*.f6452.3

                      \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                  8. Simplified52.3%

                    \[\leadsto \mathsf{fma}\left(J, \color{blue}{2 \cdot \ell}, U\right) \]
                  9. Taylor expanded in J around inf

                    \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                  10. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \color{blue}{\left(J \cdot \ell\right) \cdot 2} \]
                    2. associate-*r*N/A

                      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot 2\right)} \]
                    3. *-commutativeN/A

                      \[\leadsto J \cdot \color{blue}{\left(2 \cdot \ell\right)} \]
                    4. lower-*.f64N/A

                      \[\leadsto \color{blue}{J \cdot \left(2 \cdot \ell\right)} \]
                    5. *-commutativeN/A

                      \[\leadsto J \cdot \color{blue}{\left(\ell \cdot 2\right)} \]
                    6. lower-*.f6419.5

                      \[\leadsto J \cdot \color{blue}{\left(\ell \cdot 2\right)} \]
                  11. Simplified19.5%

                    \[\leadsto \color{blue}{J \cdot \left(\ell \cdot 2\right)} \]
                  12. Final simplification19.5%

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) \]
                  13. Add Preprocessing

                  Reproduce

                  ?
                  herbie shell --seed 2024207 
                  (FPCore (J l K U)
                    :name "Maksimov and Kolovsky, Equation (4)"
                    :precision binary64
                    (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))