Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 85.9% → 99.9%
Time: 17.2s
Alternatives: 25
Speedup: 1.2×

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;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(j, l, k, u)
use fmin_fmax_functions
    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}

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 25 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: 85.9% 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;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(j, l, k, u)
use fmin_fmax_functions
    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.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.9% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := \sinh \ell \cdot \left(\left(J + J\right) \cdot \cos \left(-0.5 \cdot K\right)\right)\\
\mathbf{if}\;\ell \leq -1.15:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq 1.08 \cdot 10^{-7}:\\
\;\;\;\;\left(J \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.1499999999999999 or 1.08000000000000001e-7 < l

    1. Initial program 99.9%

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

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

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

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

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

        \[\leadsto \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \sinh \ell + \color{blue}{\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \sinh \ell} \]
      5. distribute-rgt-outN/A

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

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

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

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

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

        \[\leadsto \sinh \ell \cdot \left(\left(2 \cdot J\right) \cdot \color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}\right) \]
      11. count-2-revN/A

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

        \[\leadsto \sinh \ell \cdot \left(\left(J + J\right) \cdot \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}\right) \]
      13. cos-neg-revN/A

        \[\leadsto \sinh \ell \cdot \left(\left(J + J\right) \cdot \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)\right) \]
      14. lower-cos.f64N/A

        \[\leadsto \sinh \ell \cdot \left(\left(J + J\right) \cdot \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)\right) \]
      15. distribute-lft-neg-inN/A

        \[\leadsto \sinh \ell \cdot \left(\left(J + J\right) \cdot \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)\right) \]
      16. lower-*.f64N/A

        \[\leadsto \sinh \ell \cdot \left(\left(J + J\right) \cdot \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)\right) \]
      17. metadata-eval99.0

        \[\leadsto \sinh \ell \cdot \left(\left(J + J\right) \cdot \cos \left(-0.5 \cdot K\right)\right) \]
    4. Applied rewrites99.0%

      \[\leadsto \color{blue}{\sinh \ell \cdot \left(\left(J + J\right) \cdot \cos \left(-0.5 \cdot K\right)\right)} \]

    if -1.1499999999999999 < l < 1.08000000000000001e-7

    1. Initial program 71.4%

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

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

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

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

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

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

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

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

        \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Applied rewrites99.8%

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

Alternative 3: 99.4% accurate, 1.2× speedup?

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

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

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

    \[\leadsto \color{blue}{U + J \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)} \]
  3. Applied rewrites99.9%

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

Alternative 4: 95.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right), \sinh \ell \cdot \left(J + J\right), U\right)\\ t_1 := \cos \left(0.5 \cdot K\right)\\ t_2 := \left(\left(t\_1 \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right) \cdot J\\ \mathbf{if}\;\ell \leq -4.4 \cdot 10^{+90}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\ell \leq -3.5 \cdot 10^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 52:\\ \;\;\;\;\mathsf{fma}\left(\left(\ell + \ell\right) \cdot t\_1, J, U\right)\\ \mathbf{elif}\;\ell \leq 2.6 \cdot 10^{+89}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (fma (fma (* K K) -0.125 1.0) (* (sinh l) (+ J J)) U))
        (t_1 (cos (* 0.5 K)))
        (t_2 (* (* (* t_1 l) (fma (* l l) 0.3333333333333333 2.0)) J)))
   (if (<= l -4.4e+90)
     t_2
     (if (<= l -3.5e-5)
       t_0
       (if (<= l 52.0)
         (fma (* (+ l l) t_1) J U)
         (if (<= l 2.6e+89) t_0 t_2))))))
double code(double J, double l, double K, double U) {
	double t_0 = fma(fma((K * K), -0.125, 1.0), (sinh(l) * (J + J)), U);
	double t_1 = cos((0.5 * K));
	double t_2 = ((t_1 * l) * fma((l * l), 0.3333333333333333, 2.0)) * J;
	double tmp;
	if (l <= -4.4e+90) {
		tmp = t_2;
	} else if (l <= -3.5e-5) {
		tmp = t_0;
	} else if (l <= 52.0) {
		tmp = fma(((l + l) * t_1), J, U);
	} else if (l <= 2.6e+89) {
		tmp = t_0;
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = fma(fma(Float64(K * K), -0.125, 1.0), Float64(sinh(l) * Float64(J + J)), U)
	t_1 = cos(Float64(0.5 * K))
	t_2 = Float64(Float64(Float64(t_1 * l) * fma(Float64(l * l), 0.3333333333333333, 2.0)) * J)
	tmp = 0.0
	if (l <= -4.4e+90)
		tmp = t_2;
	elseif (l <= -3.5e-5)
		tmp = t_0;
	elseif (l <= 52.0)
		tmp = fma(Float64(Float64(l + l) * t_1), J, U);
	elseif (l <= 2.6e+89)
		tmp = t_0;
	else
		tmp = t_2;
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * N[(J + J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t$95$1 * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[l, -4.4e+90], t$95$2, If[LessEqual[l, -3.5e-5], t$95$0, If[LessEqual[l, 52.0], N[(N[(N[(l + l), $MachinePrecision] * t$95$1), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 2.6e+89], t$95$0, t$95$2]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right), \sinh \ell \cdot \left(J + J\right), U\right)\\
t_1 := \cos \left(0.5 \cdot K\right)\\
t_2 := \left(\left(t\_1 \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right) \cdot J\\
\mathbf{if}\;\ell \leq -4.4 \cdot 10^{+90}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\ell \leq -3.5 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq 52:\\
\;\;\;\;\mathsf{fma}\left(\left(\ell + \ell\right) \cdot t\_1, J, U\right)\\

\mathbf{elif}\;\ell \leq 2.6 \cdot 10^{+89}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.39999999999999981e90 or 2.6000000000000001e89 < 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. 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)} \]
    3. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \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) + \color{blue}{U} \]
      2. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\cos \left(\frac{-1}{2} \cdot K\right) \cdot \ell\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right) \cdot J \]
      7. cos-neg-revN/A

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

        \[\leadsto \left(\left(\cos \left(\mathsf{neg}\left(\frac{-1}{2} \cdot K\right)\right) \cdot \ell\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right) \cdot J \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \left(\left(\cos \left(\left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot K\right) \cdot \ell\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right) \cdot J \]
      10. metadata-evalN/A

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

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

        \[\leadsto \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \ell\right) \cdot \left(2 + {\ell}^{2} \cdot \frac{1}{3}\right)\right) \cdot J \]
      13. pow2N/A

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

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

        \[\leadsto \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, \frac{1}{3}, 2\right)\right) \cdot J \]
      16. lift-*.f6497.4

        \[\leadsto \left(\left(\cos \left(0.5 \cdot K\right) \cdot \ell\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right) \cdot J \]
    7. Applied rewrites97.4%

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

    if -4.39999999999999981e90 < l < -3.4999999999999997e-5 or 52 < l < 2.6000000000000001e89

    1. Initial program 99.7%

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

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

        \[\leadsto \left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right) + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) + \color{blue}{U} \]
    4. Applied rewrites73.7%

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

    if -3.4999999999999997e-5 < l < 52

    1. Initial program 71.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right), J, U\right) \]
      9. lower-*.f6499.6

        \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot \cos \left(0.5 \cdot K\right), J, U\right) \]
    6. Applied rewrites99.6%

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

Alternative 5: 87.5% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;K \leq 2060000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right), \sinh \ell \cdot \left(J + J\right), U\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if K < 2.06e6

    1. Initial program 85.9%

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

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

        \[\leadsto \left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right) + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) + \color{blue}{U} \]
    4. Applied rewrites78.3%

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

    if 2.06e6 < K

    1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 86.5% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;K \leq 2060000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right), \sinh \ell \cdot \left(J + J\right), U\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if K < 2.06e6

    1. Initial program 85.9%

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

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

        \[\leadsto \left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right) + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) + \color{blue}{U} \]
    4. Applied rewrites78.3%

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

    if 2.06e6 < K

    1. Initial program 86.1%

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

        \[\leadsto \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) + \color{blue}{U} \]
      2. distribute-rgt-inN/A

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

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

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

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

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

Alternative 7: 86.5% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right), \sinh \ell \cdot \left(J + J\right), U\right)\\

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+150}:\\
\;\;\;\;\mathsf{fma}\left(\left(\ell + \ell\right) \cdot \cos \left(0.5 \cdot K\right), J, U\right)\\

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


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

    1. Initial program 99.9%

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

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

        \[\leadsto \left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right) + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) + \color{blue}{U} \]
    4. Applied rewrites74.0%

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

    if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 1.99999999999999996e150

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot \cos \left(0.5 \cdot K\right), J, U\right) \]
    6. Applied rewrites99.3%

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

    if 1.99999999999999996e150 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))))

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - \frac{1}{e^{\ell}}\right)} \]
    5. Applied rewrites74.3%

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

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

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

        \[\leadsto \left(1 + \frac{J \cdot \left(e^{\ell} - \frac{1}{e^{\ell}}\right)}{U}\right) \cdot U \]
    8. Applied rewrites73.9%

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

Alternative 8: 83.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right), \sinh \ell \cdot \left(J + J\right), U\right)\\

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+150}:\\
\;\;\;\;\mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right)\\

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


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

    1. Initial program 99.9%

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

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

        \[\leadsto \left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right) + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) + \color{blue}{U} \]
    4. Applied rewrites74.0%

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

    if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 1.99999999999999996e150

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
      15. metadata-eval99.3

        \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
    4. Applied rewrites99.3%

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

    if 1.99999999999999996e150 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))))

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - \frac{1}{e^{\ell}}\right)} \]
    5. Applied rewrites74.3%

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

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

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

        \[\leadsto \left(1 + \frac{J \cdot \left(e^{\ell} - \frac{1}{e^{\ell}}\right)}{U}\right) \cdot U \]
    8. Applied rewrites73.9%

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

Alternative 9: 82.8% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.66:\\
\;\;\;\;U\\

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

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


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

    1. Initial program 85.2%

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

      \[\leadsto \color{blue}{U} \]
    3. Step-by-step derivation
      1. Applied rewrites35.5%

        \[\leadsto \color{blue}{U} \]

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

      1. Initial program 86.7%

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

          \[\leadsto \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) + \color{blue}{U} \]
        2. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right) \cdot J\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, \frac{1}{3}, 2\right), \ell, U\right) \]
        5. lift-*.f6458.5

          \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot J\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right), \ell, U\right) \]
      7. Applied rewrites58.5%

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

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

      1. Initial program 85.9%

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) + \color{blue}{U} \]
      4. Applied rewrites95.1%

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

    Alternative 10: 81.0% accurate, 0.7× speedup?

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

      1. Initial program 85.2%

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

        \[\leadsto \color{blue}{U} \]
      3. Step-by-step derivation
        1. Applied rewrites35.5%

          \[\leadsto \color{blue}{U} \]

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

        1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
          15. metadata-eval63.8

            \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
        4. Applied rewrites63.8%

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

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

            \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
          2. count-2-revN/A

            \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
          3. distribute-lft-outN/A

            \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
          4. count-2-revN/A

            \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
          5. *-commutativeN/A

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

            \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
          7. count-2-revN/A

            \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
          8. lift-+.f6435.4

            \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
        7. Applied rewrites35.4%

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

          \[\leadsto U + \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
        9. Applied rewrites52.8%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\ell \cdot \left(2 + \frac{-1}{4} \cdot {K}^{2}\right), J, U\right) \]
        11. Applied rewrites56.4%

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

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

        1. Initial program 85.9%

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

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

            \[\leadsto J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) + \color{blue}{U} \]
        4. Applied rewrites95.1%

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

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

        1. Initial program 85.9%

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

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

            \[\leadsto \left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right) + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right) + \color{blue}{U} \]
        4. Applied rewrites64.3%

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

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

        1. Initial program 85.9%

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

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

            \[\leadsto J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) + \color{blue}{U} \]
        4. Applied rewrites95.1%

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

      Alternative 12: 79.9% accurate, 0.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(J + J\right) \cdot \sinh \ell\\ t_1 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+22}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (J l K U)
       :precision binary64
       (let* ((t_0 (* (+ J J) (sinh l)))
              (t_1 (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0)))))
         (if (<= t_1 (- INFINITY))
           t_0
           (if (<= t_1 4e+22)
             (fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U)
             t_0))))
      double code(double J, double l, double K, double U) {
      	double t_0 = (J + J) * sinh(l);
      	double t_1 = (J * (exp(l) - exp(-l))) * cos((K / 2.0));
      	double tmp;
      	if (t_1 <= -((double) INFINITY)) {
      		tmp = t_0;
      	} else if (t_1 <= 4e+22) {
      		tmp = fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(J, l, K, U)
      	t_0 = Float64(Float64(J + J) * sinh(l))
      	t_1 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0)))
      	tmp = 0.0
      	if (t_1 <= Float64(-Inf))
      		tmp = t_0;
      	elseif (t_1 <= 4e+22)
      		tmp = fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$0, If[LessEqual[t$95$1, 4e+22], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision], t$95$0]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \left(J + J\right) \cdot \sinh \ell\\
      t_1 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
      \mathbf{if}\;t\_1 \leq -\infty:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+22}:\\
      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < -inf.0 or 4e22 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64))))

        1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - \frac{1}{e^{\ell}}\right)} \]
        5. Applied rewrites74.7%

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

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

            \[\leadsto \left(e^{\ell} - \frac{1}{e^{\ell}}\right) \cdot J \]
          2. rec-expN/A

            \[\leadsto \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot J \]
          3. *-commutativeN/A

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

            \[\leadsto J \cdot \left(2 \cdot \sinh \ell\right) \]
          5. count-2-revN/A

            \[\leadsto J \cdot \left(\sinh \ell + \sinh \ell\right) \]
          6. distribute-lft-outN/A

            \[\leadsto J \cdot \sinh \ell + J \cdot \color{blue}{\sinh \ell} \]
          7. count-2-revN/A

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

            \[\leadsto \left(2 \cdot J\right) \cdot \sinh \ell \]
          9. lower-*.f64N/A

            \[\leadsto \left(2 \cdot J\right) \cdot \sinh \ell \]
          10. count-2-revN/A

            \[\leadsto \left(J + J\right) \cdot \sinh \ell \]
          11. lift-+.f64N/A

            \[\leadsto \left(J + J\right) \cdot \sinh \ell \]
          12. lift-sinh.f6474.3

            \[\leadsto \left(J + J\right) \cdot \sinh \ell \]
        8. Applied rewrites74.3%

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

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

        1. Initial program 71.8%

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

            \[\leadsto \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) + \color{blue}{U} \]
          2. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, \frac{1}{3}, 2\right) \cdot \ell, J, U\right) \]
          10. lift-*.f6485.7

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right) \]
        7. Applied rewrites85.7%

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

      Alternative 13: 74.2% accurate, 0.7× speedup?

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

        1. Initial program 85.2%

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

          \[\leadsto \color{blue}{U} \]
        3. Step-by-step derivation
          1. Applied rewrites35.5%

            \[\leadsto \color{blue}{U} \]

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
            15. metadata-eval63.8

              \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
          4. Applied rewrites63.8%

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

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

              \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
            2. count-2-revN/A

              \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
            3. distribute-lft-outN/A

              \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
            4. count-2-revN/A

              \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
            5. *-commutativeN/A

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

              \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
            7. count-2-revN/A

              \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
            8. lift-+.f6435.4

              \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
          7. Applied rewrites35.4%

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

            \[\leadsto U + \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
          9. Applied rewrites52.8%

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\ell \cdot \left(2 + \frac{-1}{4} \cdot {K}^{2}\right), J, U\right) \]
          11. Applied rewrites56.4%

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

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

          1. Initial program 85.9%

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

              \[\leadsto \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) + \color{blue}{U} \]
            2. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, \frac{1}{3}, 2\right) \cdot \ell, J, U\right) \]
            10. lift-*.f6483.8

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right) \]
          7. Applied rewrites83.8%

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

        Alternative 14: 73.8% accurate, 0.7× speedup?

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

          1. Initial program 85.2%

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

            \[\leadsto \color{blue}{U} \]
          3. Step-by-step derivation
            1. Applied rewrites35.5%

              \[\leadsto \color{blue}{U} \]

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

            1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
              15. metadata-eval63.8

                \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
            4. Applied rewrites63.8%

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

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

                \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
              2. count-2-revN/A

                \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
              3. distribute-lft-outN/A

                \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
              4. count-2-revN/A

                \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
              5. *-commutativeN/A

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

                \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
              7. count-2-revN/A

                \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
              8. lift-+.f6435.4

                \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
            7. Applied rewrites35.4%

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

              \[\leadsto U + \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
            9. Applied rewrites52.8%

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

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

            1. Initial program 85.9%

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

                \[\leadsto \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) + \color{blue}{U} \]
              2. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, \frac{1}{3}, 2\right) \cdot \ell, J, U\right) \]
              10. lift-*.f6483.8

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right) \]
            7. Applied rewrites83.8%

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

          Alternative 15: 72.5% accurate, 0.7× speedup?

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

            1. Initial program 85.2%

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

              \[\leadsto \color{blue}{U} \]
            3. Step-by-step derivation
              1. Applied rewrites35.5%

                \[\leadsto \color{blue}{U} \]

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

              1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                15. metadata-eval63.8

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
              4. Applied rewrites63.8%

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

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

                  \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                2. count-2-revN/A

                  \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                3. distribute-lft-outN/A

                  \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                4. count-2-revN/A

                  \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                5. *-commutativeN/A

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

                  \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                7. count-2-revN/A

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                8. lift-+.f6435.4

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
              7. Applied rewrites35.4%

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

                \[\leadsto U + \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
              9. Applied rewrites52.8%

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

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

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

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

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

                  \[\leadsto \left(\left(\frac{-1}{4} \cdot {K}^{2}\right) \cdot J\right) \cdot \ell \]
                5. lower-*.f64N/A

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

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

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

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

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

                  \[\leadsto \left(\left({K}^{2} \cdot J\right) \cdot \frac{-1}{4}\right) \cdot \ell \]
                11. lower-*.f64N/A

                  \[\leadsto \left(\left({K}^{2} \cdot J\right) \cdot \frac{-1}{4}\right) \cdot \ell \]
                12. pow2N/A

                  \[\leadsto \left(\left(\left(K \cdot K\right) \cdot J\right) \cdot \frac{-1}{4}\right) \cdot \ell \]
                13. lift-*.f6441.0

                  \[\leadsto \left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25\right) \cdot \ell \]
              12. Applied rewrites41.0%

                \[\leadsto \left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25\right) \cdot \ell \]

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

              1. Initial program 85.9%

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

                  \[\leadsto \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) + \color{blue}{U} \]
                2. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, \frac{1}{3}, 2\right) \cdot \ell, J, U\right) \]
                10. lift-*.f6483.8

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right) \]
              7. Applied rewrites83.8%

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

            Alternative 16: 58.8% accurate, 2.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U}\\ \mathbf{if}\;\ell \leq -4.2 \cdot 10^{+59}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 1280:\\ \;\;\;\;\mathsf{fma}\left(\ell + \ell, J, U\right)\\ \mathbf{elif}\;\ell \leq 4.9 \cdot 10^{+234}:\\ \;\;\;\;\left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25\right) \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
            (FPCore (J l K U)
             :precision binary64
             (let* ((t_0 (/ (* (* (+ J J) l) U) U)))
               (if (<= l -4.2e+59)
                 t_0
                 (if (<= l 1280.0)
                   (fma (+ l l) J U)
                   (if (<= l 4.9e+234) (* (* (* (* K K) J) -0.25) l) t_0)))))
            double code(double J, double l, double K, double U) {
            	double t_0 = (((J + J) * l) * U) / U;
            	double tmp;
            	if (l <= -4.2e+59) {
            		tmp = t_0;
            	} else if (l <= 1280.0) {
            		tmp = fma((l + l), J, U);
            	} else if (l <= 4.9e+234) {
            		tmp = (((K * K) * J) * -0.25) * l;
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            function code(J, l, K, U)
            	t_0 = Float64(Float64(Float64(Float64(J + J) * l) * U) / U)
            	tmp = 0.0
            	if (l <= -4.2e+59)
            		tmp = t_0;
            	elseif (l <= 1280.0)
            		tmp = fma(Float64(l + l), J, U);
            	elseif (l <= 4.9e+234)
            		tmp = Float64(Float64(Float64(Float64(K * K) * J) * -0.25) * l);
            	else
            		tmp = t_0;
            	end
            	return tmp
            end
            
            code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision] * U), $MachinePrecision] / U), $MachinePrecision]}, If[LessEqual[l, -4.2e+59], t$95$0, If[LessEqual[l, 1280.0], N[(N[(l + l), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 4.9e+234], N[(N[(N[(N[(K * K), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] * l), $MachinePrecision], t$95$0]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U}\\
            \mathbf{if}\;\ell \leq -4.2 \cdot 10^{+59}:\\
            \;\;\;\;t\_0\\
            
            \mathbf{elif}\;\ell \leq 1280:\\
            \;\;\;\;\mathsf{fma}\left(\ell + \ell, J, U\right)\\
            
            \mathbf{elif}\;\ell \leq 4.9 \cdot 10^{+234}:\\
            \;\;\;\;\left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25\right) \cdot \ell\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_0\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if l < -4.19999999999999968e59 or 4.89999999999999989e234 < 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. 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)} \]
              3. Step-by-step derivation
                1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                15. metadata-eval35.9

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
              4. Applied rewrites35.9%

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

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

                  \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                2. count-2-revN/A

                  \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                3. distribute-lft-outN/A

                  \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                4. count-2-revN/A

                  \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                5. *-commutativeN/A

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

                  \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                7. count-2-revN/A

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                8. lift-+.f6427.3

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
              7. Applied rewrites27.3%

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

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

                  \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                2. lower-*.f64N/A

                  \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                3. count-2-revN/A

                  \[\leadsto \left(J + J\right) \cdot \ell \]
                4. lift-+.f6427.2

                  \[\leadsto \left(J + J\right) \cdot \ell \]
              10. Applied rewrites27.2%

                \[\leadsto \left(J + J\right) \cdot \ell \]
              11. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \left(J + J\right) \cdot \ell \]
                2. lift-+.f64N/A

                  \[\leadsto \left(J + J\right) \cdot \ell \]
                3. count-2-revN/A

                  \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                4. associate-*r*N/A

                  \[\leadsto 2 \cdot \left(J \cdot \ell\right) \]
                5. *-rgt-identityN/A

                  \[\leadsto \left(2 \cdot \left(J \cdot \ell\right)\right) \cdot 1 \]
                6. *-inversesN/A

                  \[\leadsto \left(2 \cdot \left(J \cdot \ell\right)\right) \cdot \frac{U}{U} \]
                7. associate-/l*N/A

                  \[\leadsto \frac{\left(2 \cdot \left(J \cdot \ell\right)\right) \cdot U}{U} \]
                8. lower-/.f64N/A

                  \[\leadsto \frac{\left(2 \cdot \left(J \cdot \ell\right)\right) \cdot U}{U} \]
                9. lower-*.f64N/A

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

                  \[\leadsto \frac{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot U}{U} \]
                11. count-2-revN/A

                  \[\leadsto \frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U} \]
                12. lift-+.f64N/A

                  \[\leadsto \frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U} \]
                13. lift-*.f6435.9

                  \[\leadsto \frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U} \]
              12. Applied rewrites35.9%

                \[\leadsto \frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U} \]

              if -4.19999999999999968e59 < l < 1280

              1. Initial program 74.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                15. metadata-eval91.9

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
              4. Applied rewrites91.9%

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

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

                  \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                2. count-2-revN/A

                  \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                3. distribute-lft-outN/A

                  \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                4. count-2-revN/A

                  \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                5. *-commutativeN/A

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

                  \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                7. count-2-revN/A

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                8. lift-+.f6479.0

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
              7. Applied rewrites79.0%

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

              if 1280 < l < 4.89999999999999989e234

              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                15. metadata-eval23.7

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
              4. Applied rewrites23.7%

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

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

                  \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                2. count-2-revN/A

                  \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                3. distribute-lft-outN/A

                  \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                4. count-2-revN/A

                  \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                5. *-commutativeN/A

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

                  \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                7. count-2-revN/A

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                8. lift-+.f6417.8

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
              7. Applied rewrites17.8%

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

                \[\leadsto U + \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
              9. Applied rewrites31.1%

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

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

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

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

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

                  \[\leadsto \left(\left(\frac{-1}{4} \cdot {K}^{2}\right) \cdot J\right) \cdot \ell \]
                5. lower-*.f64N/A

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

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

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

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

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

                  \[\leadsto \left(\left({K}^{2} \cdot J\right) \cdot \frac{-1}{4}\right) \cdot \ell \]
                11. lower-*.f64N/A

                  \[\leadsto \left(\left({K}^{2} \cdot J\right) \cdot \frac{-1}{4}\right) \cdot \ell \]
                12. pow2N/A

                  \[\leadsto \left(\left(\left(K \cdot K\right) \cdot J\right) \cdot \frac{-1}{4}\right) \cdot \ell \]
                13. lift-*.f6420.2

                  \[\leadsto \left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25\right) \cdot \ell \]
              12. Applied rewrites20.2%

                \[\leadsto \left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25\right) \cdot \ell \]
            3. Recombined 3 regimes into one program.
            4. Add Preprocessing

            Alternative 17: 58.5% accurate, 1.5× speedup?

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

              1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                15. metadata-eval29.1

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
              4. Applied rewrites29.1%

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

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

                  \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                2. count-2-revN/A

                  \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                3. distribute-lft-outN/A

                  \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                4. count-2-revN/A

                  \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                5. *-commutativeN/A

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

                  \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                7. count-2-revN/A

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                8. lift-+.f6422.1

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
              7. Applied rewrites22.1%

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

                \[\leadsto U + \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
              9. Applied rewrites33.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{4} \cdot K, K, 2\right) \cdot \left(\ell \cdot J\right) \]
                13. lift-*.f6433.3

                  \[\leadsto \mathsf{fma}\left(-0.25 \cdot K, K, 2\right) \cdot \left(\ell \cdot J\right) \]
              12. Applied rewrites33.3%

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

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

              1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - \frac{1}{e^{\ell}}\right)} \]
              5. Applied rewrites81.8%

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

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

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

                  \[\leadsto \left(1 + \frac{J \cdot \left(e^{\ell} - \frac{1}{e^{\ell}}\right)}{U}\right) \cdot U \]
              8. Applied rewrites80.2%

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

                \[\leadsto \mathsf{fma}\left(J + J, \frac{\ell}{U}, 1\right) \cdot U \]
              10. Step-by-step derivation
                1. Applied rewrites67.1%

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

              Alternative 18: 57.3% accurate, 3.1× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4.2 \cdot 10^{+59}:\\ \;\;\;\;\frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U}\\ \mathbf{elif}\;\ell \leq 1280:\\ \;\;\;\;\mathsf{fma}\left(\ell + \ell, J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.25 \cdot K, K, 2\right) \cdot \left(\ell \cdot J\right)\\ \end{array} \end{array} \]
              (FPCore (J l K U)
               :precision binary64
               (if (<= l -4.2e+59)
                 (/ (* (* (+ J J) l) U) U)
                 (if (<= l 1280.0) (fma (+ l l) J U) (* (fma (* -0.25 K) K 2.0) (* l J)))))
              double code(double J, double l, double K, double U) {
              	double tmp;
              	if (l <= -4.2e+59) {
              		tmp = (((J + J) * l) * U) / U;
              	} else if (l <= 1280.0) {
              		tmp = fma((l + l), J, U);
              	} else {
              		tmp = fma((-0.25 * K), K, 2.0) * (l * J);
              	}
              	return tmp;
              }
              
              function code(J, l, K, U)
              	tmp = 0.0
              	if (l <= -4.2e+59)
              		tmp = Float64(Float64(Float64(Float64(J + J) * l) * U) / U);
              	elseif (l <= 1280.0)
              		tmp = fma(Float64(l + l), J, U);
              	else
              		tmp = Float64(fma(Float64(-0.25 * K), K, 2.0) * Float64(l * J));
              	end
              	return tmp
              end
              
              code[J_, l_, K_, U_] := If[LessEqual[l, -4.2e+59], N[(N[(N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision] * U), $MachinePrecision] / U), $MachinePrecision], If[LessEqual[l, 1280.0], N[(N[(l + l), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(N[(-0.25 * K), $MachinePrecision] * K + 2.0), $MachinePrecision] * N[(l * J), $MachinePrecision]), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;\ell \leq -4.2 \cdot 10^{+59}:\\
              \;\;\;\;\frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U}\\
              
              \mathbf{elif}\;\ell \leq 1280:\\
              \;\;\;\;\mathsf{fma}\left(\ell + \ell, J, U\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\mathsf{fma}\left(-0.25 \cdot K, K, 2\right) \cdot \left(\ell \cdot J\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if l < -4.19999999999999968e59

                1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval32.7

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites32.7%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6424.9

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites24.9%

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

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

                    \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                  2. lower-*.f64N/A

                    \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                  3. count-2-revN/A

                    \[\leadsto \left(J + J\right) \cdot \ell \]
                  4. lift-+.f6424.8

                    \[\leadsto \left(J + J\right) \cdot \ell \]
                10. Applied rewrites24.8%

                  \[\leadsto \left(J + J\right) \cdot \ell \]
                11. Step-by-step derivation
                  1. lift-*.f64N/A

                    \[\leadsto \left(J + J\right) \cdot \ell \]
                  2. lift-+.f64N/A

                    \[\leadsto \left(J + J\right) \cdot \ell \]
                  3. count-2-revN/A

                    \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                  4. associate-*r*N/A

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) \]
                  5. *-rgt-identityN/A

                    \[\leadsto \left(2 \cdot \left(J \cdot \ell\right)\right) \cdot 1 \]
                  6. *-inversesN/A

                    \[\leadsto \left(2 \cdot \left(J \cdot \ell\right)\right) \cdot \frac{U}{U} \]
                  7. associate-/l*N/A

                    \[\leadsto \frac{\left(2 \cdot \left(J \cdot \ell\right)\right) \cdot U}{U} \]
                  8. lower-/.f64N/A

                    \[\leadsto \frac{\left(2 \cdot \left(J \cdot \ell\right)\right) \cdot U}{U} \]
                  9. lower-*.f64N/A

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

                    \[\leadsto \frac{\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot U}{U} \]
                  11. count-2-revN/A

                    \[\leadsto \frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U} \]
                  12. lift-+.f64N/A

                    \[\leadsto \frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U} \]
                  13. lift-*.f6434.2

                    \[\leadsto \frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U} \]
                12. Applied rewrites34.2%

                  \[\leadsto \frac{\left(\left(J + J\right) \cdot \ell\right) \cdot U}{U} \]

                if -4.19999999999999968e59 < l < 1280

                1. Initial program 74.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval91.9

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites91.9%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6479.0

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites79.0%

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

                if 1280 < 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. 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)} \]
                3. Step-by-step derivation
                  1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval29.0

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites29.0%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6421.9

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites21.9%

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

                  \[\leadsto U + \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                9. Applied rewrites34.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{4} \cdot K, K, 2\right) \cdot \left(\ell \cdot J\right) \]
                  13. lift-*.f6434.2

                    \[\leadsto \mathsf{fma}\left(-0.25 \cdot K, K, 2\right) \cdot \left(\ell \cdot J\right) \]
                12. Applied rewrites34.2%

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

              Alternative 19: 56.9% accurate, 1.5× speedup?

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

                1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval29.1

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites29.1%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6422.1

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites22.1%

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

                  \[\leadsto U + \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                9. Applied rewrites33.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{4} \cdot K, K, 2\right) \cdot \left(\ell \cdot J\right) \]
                  13. lift-*.f6433.3

                    \[\leadsto \mathsf{fma}\left(-0.25 \cdot K, K, 2\right) \cdot \left(\ell \cdot J\right) \]
                12. Applied rewrites33.3%

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

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

                1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval75.3

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites75.3%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6463.8

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites63.8%

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \frac{J \cdot \ell}{U}, U, U\right) \]
                  5. associate-*r/N/A

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

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

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

                    \[\leadsto \mathsf{fma}\left(\frac{\left(2 \cdot J\right) \cdot \ell}{U}, U, U\right) \]
                  9. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\frac{\left(J + J\right) \cdot \ell}{U}, U, U\right) \]
                  10. lift-+.f6465.1

                    \[\leadsto \mathsf{fma}\left(\frac{\left(J + J\right) \cdot \ell}{U}, U, U\right) \]
                10. Applied rewrites65.1%

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

              Alternative 20: 56.2% accurate, 0.4× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J\\ \mathbf{elif}\;t\_0 \leq 10^{+304}:\\ \;\;\;\;\mathsf{fma}\left(\ell + \ell, J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(J + J\right) \cdot \ell}{U} \cdot U\\ \end{array} \end{array} \]
              (FPCore (J l K U)
               :precision binary64
               (let* ((t_0 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U)))
                 (if (<= t_0 (- INFINITY))
                   (* (fma 2.0 l (/ U J)) J)
                   (if (<= t_0 1e+304) (fma (+ l l) J U) (* (/ (* (+ J J) l) U) U)))))
              double code(double J, double l, double K, double U) {
              	double t_0 = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
              	double tmp;
              	if (t_0 <= -((double) INFINITY)) {
              		tmp = fma(2.0, l, (U / J)) * J;
              	} else if (t_0 <= 1e+304) {
              		tmp = fma((l + l), J, U);
              	} else {
              		tmp = (((J + J) * l) / U) * U;
              	}
              	return tmp;
              }
              
              function code(J, l, K, U)
              	t_0 = Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U)
              	tmp = 0.0
              	if (t_0 <= Float64(-Inf))
              		tmp = Float64(fma(2.0, l, Float64(U / J)) * J);
              	elseif (t_0 <= 1e+304)
              		tmp = fma(Float64(l + l), J, U);
              	else
              		tmp = Float64(Float64(Float64(Float64(J + J) * l) / U) * U);
              	end
              	return tmp
              end
              
              code[J_, l_, K_, U_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(2.0 * l + N[(U / J), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision], If[LessEqual[t$95$0, 1e+304], N[(N[(l + l), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision] / U), $MachinePrecision] * U), $MachinePrecision]]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
              \mathbf{if}\;t\_0 \leq -\infty:\\
              \;\;\;\;\mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J\\
              
              \mathbf{elif}\;t\_0 \leq 10^{+304}:\\
              \;\;\;\;\mathsf{fma}\left(\ell + \ell, J, U\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{\left(J + J\right) \cdot \ell}{U} \cdot U\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < -inf.0

                1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval28.5

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites28.5%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6421.7

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites21.7%

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J \]
                10. Applied rewrites27.1%

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

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

                1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval99.0

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites99.0%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6485.1

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites85.1%

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

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

                1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval29.1

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites29.1%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6422.1

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites22.1%

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

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

                    \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                  2. lower-*.f64N/A

                    \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                  3. count-2-revN/A

                    \[\leadsto \left(J + J\right) \cdot \ell \]
                  4. lift-+.f6421.6

                    \[\leadsto \left(J + J\right) \cdot \ell \]
                10. Applied rewrites21.6%

                  \[\leadsto \left(J + J\right) \cdot \ell \]
                11. Step-by-step derivation
                  1. lift-*.f64N/A

                    \[\leadsto \left(J + J\right) \cdot \ell \]
                  2. lift-+.f64N/A

                    \[\leadsto \left(J + J\right) \cdot \ell \]
                  3. count-2-revN/A

                    \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                  4. associate-*r*N/A

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) \]
                  5. *-rgt-identityN/A

                    \[\leadsto \left(2 \cdot \left(J \cdot \ell\right)\right) \cdot 1 \]
                  6. *-inversesN/A

                    \[\leadsto \left(2 \cdot \left(J \cdot \ell\right)\right) \cdot \frac{U}{U} \]
                  7. associate-/l*N/A

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

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

                    \[\leadsto \left(2 \cdot \frac{J \cdot \ell}{U}\right) \cdot U \]
                  10. lower-*.f64N/A

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

                    \[\leadsto \frac{2 \cdot \left(J \cdot \ell\right)}{U} \cdot U \]
                  12. lower-/.f64N/A

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

                    \[\leadsto \frac{\left(2 \cdot J\right) \cdot \ell}{U} \cdot U \]
                  14. count-2-revN/A

                    \[\leadsto \frac{\left(J + J\right) \cdot \ell}{U} \cdot U \]
                  15. lift-+.f64N/A

                    \[\leadsto \frac{\left(J + J\right) \cdot \ell}{U} \cdot U \]
                  16. lift-*.f6430.3

                    \[\leadsto \frac{\left(J + J\right) \cdot \ell}{U} \cdot U \]
                12. Applied rewrites30.3%

                  \[\leadsto \frac{\left(J + J\right) \cdot \ell}{U} \cdot U \]
              3. Recombined 3 regimes into one program.
              4. Add Preprocessing

              Alternative 21: 54.8% accurate, 3.4× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1280:\\ \;\;\;\;\mathsf{fma}\left(\ell + \ell, J, U\right)\\ \mathbf{elif}\;\ell \leq 1.5 \cdot 10^{+233}:\\ \;\;\;\;\left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25\right) \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J\\ \end{array} \end{array} \]
              (FPCore (J l K U)
               :precision binary64
               (if (<= l 1280.0)
                 (fma (+ l l) J U)
                 (if (<= l 1.5e+233)
                   (* (* (* (* K K) J) -0.25) l)
                   (* (fma 2.0 l (/ U J)) J))))
              double code(double J, double l, double K, double U) {
              	double tmp;
              	if (l <= 1280.0) {
              		tmp = fma((l + l), J, U);
              	} else if (l <= 1.5e+233) {
              		tmp = (((K * K) * J) * -0.25) * l;
              	} else {
              		tmp = fma(2.0, l, (U / J)) * J;
              	}
              	return tmp;
              }
              
              function code(J, l, K, U)
              	tmp = 0.0
              	if (l <= 1280.0)
              		tmp = fma(Float64(l + l), J, U);
              	elseif (l <= 1.5e+233)
              		tmp = Float64(Float64(Float64(Float64(K * K) * J) * -0.25) * l);
              	else
              		tmp = Float64(fma(2.0, l, Float64(U / J)) * J);
              	end
              	return tmp
              end
              
              code[J_, l_, K_, U_] := If[LessEqual[l, 1280.0], N[(N[(l + l), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 1.5e+233], N[(N[(N[(N[(K * K), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] * l), $MachinePrecision], N[(N[(2.0 * l + N[(U / J), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;\ell \leq 1280:\\
              \;\;\;\;\mathsf{fma}\left(\ell + \ell, J, U\right)\\
              
              \mathbf{elif}\;\ell \leq 1.5 \cdot 10^{+233}:\\
              \;\;\;\;\left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25\right) \cdot \ell\\
              
              \mathbf{else}:\\
              \;\;\;\;\mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if l < 1280

                1. Initial program 81.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval76.1

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites76.1%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6464.5

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites64.5%

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

                if 1280 < l < 1.50000000000000007e233

                1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval23.6

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites23.6%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6417.7

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites17.7%

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

                  \[\leadsto U + \color{blue}{\left(\frac{-1}{4} \cdot \left(J \cdot \left({K}^{2} \cdot \ell\right)\right) + 2 \cdot \left(J \cdot \ell\right)\right)} \]
                9. Applied rewrites31.0%

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

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

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

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

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

                    \[\leadsto \left(\left(\frac{-1}{4} \cdot {K}^{2}\right) \cdot J\right) \cdot \ell \]
                  5. lower-*.f64N/A

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

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

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

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

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

                    \[\leadsto \left(\left({K}^{2} \cdot J\right) \cdot \frac{-1}{4}\right) \cdot \ell \]
                  11. lower-*.f64N/A

                    \[\leadsto \left(\left({K}^{2} \cdot J\right) \cdot \frac{-1}{4}\right) \cdot \ell \]
                  12. pow2N/A

                    \[\leadsto \left(\left(\left(K \cdot K\right) \cdot J\right) \cdot \frac{-1}{4}\right) \cdot \ell \]
                  13. lift-*.f6420.2

                    \[\leadsto \left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25\right) \cdot \ell \]
                12. Applied rewrites20.2%

                  \[\leadsto \left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25\right) \cdot \ell \]

                if 1.50000000000000007e233 < 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. 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)} \]
                3. Step-by-step derivation
                  1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval46.1

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites46.1%

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

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

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6435.1

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites35.1%

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J \]
                10. Applied rewrites40.1%

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

              Alternative 22: 54.3% accurate, 0.8× speedup?

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

                1. Initial program 99.9%

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

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

                    \[\leadsto \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 \left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right) + U \]
                  4. lower-fma.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  5. associate-*r*N/A

                    \[\leadsto \mathsf{fma}\left(2 \cdot \left(J \cdot \ell\right), \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  6. *-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(2 \cdot \left(\ell \cdot J\right), \cos \left(\frac{1}{2} \cdot \color{blue}{K}\right), U\right) \]
                  7. associate-*r*N/A

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  8. lower-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  9. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\color{blue}{\frac{1}{2}} \cdot K\right), U\right) \]
                  10. lower-+.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\color{blue}{\frac{1}{2}} \cdot K\right), U\right) \]
                  11. cos-neg-revN/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
                  12. lower-cos.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
                  13. distribute-lft-neg-inN/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  14. lower-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval28.5

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites28.5%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right)} \]
                5. Taylor expanded in K around 0

                  \[\leadsto U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                6. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

                    \[\leadsto \left(2 \cdot \ell\right) \cdot J + U \]
                  6. lower-fma.f64N/A

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6421.7

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites21.7%

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, \color{blue}{J}, U\right) \]
                8. Taylor expanded in J around inf

                  \[\leadsto J \cdot \left(2 \cdot \ell + \color{blue}{\frac{U}{J}}\right) \]
                9. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto \left(2 \cdot \ell + \frac{U}{J}\right) \cdot J \]
                  2. lower-*.f64N/A

                    \[\leadsto \left(2 \cdot \ell + \frac{U}{J}\right) \cdot J \]
                  3. lower-fma.f64N/A

                    \[\leadsto \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J \]
                  4. lower-/.f6427.1

                    \[\leadsto \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J \]
                10. Applied rewrites27.1%

                  \[\leadsto \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J \]

                if -inf.0 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U)

                1. Initial program 81.2%

                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                2. 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)} \]
                3. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + \color{blue}{U} \]
                  2. associate-*r*N/A

                    \[\leadsto \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 \left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right) + U \]
                  4. lower-fma.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  5. associate-*r*N/A

                    \[\leadsto \mathsf{fma}\left(2 \cdot \left(J \cdot \ell\right), \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  6. *-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(2 \cdot \left(\ell \cdot J\right), \cos \left(\frac{1}{2} \cdot \color{blue}{K}\right), U\right) \]
                  7. associate-*r*N/A

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  8. lower-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  9. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\color{blue}{\frac{1}{2}} \cdot K\right), U\right) \]
                  10. lower-+.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\color{blue}{\frac{1}{2}} \cdot K\right), U\right) \]
                  11. cos-neg-revN/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
                  12. lower-cos.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
                  13. distribute-lft-neg-inN/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  14. lower-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval75.7

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites75.7%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right)} \]
                5. Taylor expanded in K around 0

                  \[\leadsto U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                6. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

                    \[\leadsto \left(2 \cdot \ell\right) \cdot J + U \]
                  6. lower-fma.f64N/A

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6464.1

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites64.1%

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, \color{blue}{J}, U\right) \]
              3. Recombined 2 regimes into one program.
              4. Add Preprocessing

              Alternative 23: 53.5% accurate, 7.9× speedup?

              \[\begin{array}{l} \\ \mathsf{fma}\left(\ell + \ell, J, U\right) \end{array} \]
              (FPCore (J l K U) :precision binary64 (fma (+ l l) J U))
              double code(double J, double l, double K, double U) {
              	return fma((l + l), J, U);
              }
              
              function code(J, l, K, U)
              	return fma(Float64(l + l), J, U)
              end
              
              code[J_, l_, K_, U_] := N[(N[(l + l), $MachinePrecision] * J + U), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \mathsf{fma}\left(\ell + \ell, J, U\right)
              \end{array}
              
              Derivation
              1. Initial program 85.9%

                \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              2. 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)} \]
              3. Step-by-step derivation
                1. +-commutativeN/A

                  \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + \color{blue}{U} \]
                2. associate-*r*N/A

                  \[\leadsto \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 \left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right) + U \]
                4. lower-fma.f64N/A

                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, U\right) \]
                5. associate-*r*N/A

                  \[\leadsto \mathsf{fma}\left(2 \cdot \left(J \cdot \ell\right), \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                6. *-commutativeN/A

                  \[\leadsto \mathsf{fma}\left(2 \cdot \left(\ell \cdot J\right), \cos \left(\frac{1}{2} \cdot \color{blue}{K}\right), U\right) \]
                7. associate-*r*N/A

                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                8. lower-*.f64N/A

                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                9. count-2-revN/A

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\color{blue}{\frac{1}{2}} \cdot K\right), U\right) \]
                10. lower-+.f64N/A

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\color{blue}{\frac{1}{2}} \cdot K\right), U\right) \]
                11. cos-neg-revN/A

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
                12. lower-cos.f64N/A

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
                13. distribute-lft-neg-inN/A

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                14. lower-*.f64N/A

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                15. metadata-eval63.9

                  \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
              4. Applied rewrites63.9%

                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right)} \]
              5. Taylor expanded in K around 0

                \[\leadsto U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
              6. Step-by-step derivation
                1. +-commutativeN/A

                  \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                2. count-2-revN/A

                  \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                3. distribute-lft-outN/A

                  \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                4. count-2-revN/A

                  \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                5. *-commutativeN/A

                  \[\leadsto \left(2 \cdot \ell\right) \cdot J + U \]
                6. lower-fma.f64N/A

                  \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                7. count-2-revN/A

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                8. lift-+.f6453.5

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
              7. Applied rewrites53.5%

                \[\leadsto \mathsf{fma}\left(\ell + \ell, \color{blue}{J}, U\right) \]
              8. Add Preprocessing

              Alternative 24: 44.9% accurate, 4.8× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(J + J\right) \cdot \ell\\ \mathbf{if}\;\ell \leq -1600:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 7 \cdot 10^{-38}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
              (FPCore (J l K U)
               :precision binary64
               (let* ((t_0 (* (+ J J) l))) (if (<= l -1600.0) t_0 (if (<= l 7e-38) U t_0))))
              double code(double J, double l, double K, double U) {
              	double t_0 = (J + J) * l;
              	double tmp;
              	if (l <= -1600.0) {
              		tmp = t_0;
              	} else if (l <= 7e-38) {
              		tmp = U;
              	} else {
              		tmp = t_0;
              	}
              	return tmp;
              }
              
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(j, l, k, u)
              use fmin_fmax_functions
                  real(8), intent (in) :: j
                  real(8), intent (in) :: l
                  real(8), intent (in) :: k
                  real(8), intent (in) :: u
                  real(8) :: t_0
                  real(8) :: tmp
                  t_0 = (j + j) * l
                  if (l <= (-1600.0d0)) then
                      tmp = t_0
                  else if (l <= 7d-38) then
                      tmp = u
                  else
                      tmp = t_0
                  end if
                  code = tmp
              end function
              
              public static double code(double J, double l, double K, double U) {
              	double t_0 = (J + J) * l;
              	double tmp;
              	if (l <= -1600.0) {
              		tmp = t_0;
              	} else if (l <= 7e-38) {
              		tmp = U;
              	} else {
              		tmp = t_0;
              	}
              	return tmp;
              }
              
              def code(J, l, K, U):
              	t_0 = (J + J) * l
              	tmp = 0
              	if l <= -1600.0:
              		tmp = t_0
              	elif l <= 7e-38:
              		tmp = U
              	else:
              		tmp = t_0
              	return tmp
              
              function code(J, l, K, U)
              	t_0 = Float64(Float64(J + J) * l)
              	tmp = 0.0
              	if (l <= -1600.0)
              		tmp = t_0;
              	elseif (l <= 7e-38)
              		tmp = U;
              	else
              		tmp = t_0;
              	end
              	return tmp
              end
              
              function tmp_2 = code(J, l, K, U)
              	t_0 = (J + J) * l;
              	tmp = 0.0;
              	if (l <= -1600.0)
              		tmp = t_0;
              	elseif (l <= 7e-38)
              		tmp = U;
              	else
              		tmp = t_0;
              	end
              	tmp_2 = tmp;
              end
              
              code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[l, -1600.0], t$95$0, If[LessEqual[l, 7e-38], U, t$95$0]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \left(J + J\right) \cdot \ell\\
              \mathbf{if}\;\ell \leq -1600:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;\ell \leq 7 \cdot 10^{-38}:\\
              \;\;\;\;U\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_0\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if l < -1600 or 7.0000000000000003e-38 < l

                1. Initial program 98.2%

                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                2. 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)} \]
                3. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + \color{blue}{U} \]
                  2. associate-*r*N/A

                    \[\leadsto \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 \left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right) + U \]
                  4. lower-fma.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  5. associate-*r*N/A

                    \[\leadsto \mathsf{fma}\left(2 \cdot \left(J \cdot \ell\right), \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  6. *-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(2 \cdot \left(\ell \cdot J\right), \cos \left(\frac{1}{2} \cdot \color{blue}{K}\right), U\right) \]
                  7. associate-*r*N/A

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  8. lower-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \color{blue}{\left(\frac{1}{2} \cdot K\right)}, U\right) \]
                  9. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\color{blue}{\frac{1}{2}} \cdot K\right), U\right) \]
                  10. lower-+.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\color{blue}{\frac{1}{2}} \cdot K\right), U\right) \]
                  11. cos-neg-revN/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
                  12. lower-cos.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
                  13. distribute-lft-neg-inN/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  14. lower-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
                  15. metadata-eval32.5

                    \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
                4. Applied rewrites32.5%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right)} \]
                5. Taylor expanded in K around 0

                  \[\leadsto U + \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
                6. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
                  2. count-2-revN/A

                    \[\leadsto \left(J \cdot \ell + J \cdot \ell\right) + U \]
                  3. distribute-lft-outN/A

                    \[\leadsto J \cdot \left(\ell + \ell\right) + U \]
                  4. count-2-revN/A

                    \[\leadsto J \cdot \left(2 \cdot \ell\right) + U \]
                  5. *-commutativeN/A

                    \[\leadsto \left(2 \cdot \ell\right) \cdot J + U \]
                  6. lower-fma.f64N/A

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, J, U\right) \]
                  7. count-2-revN/A

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                  8. lift-+.f6424.9

                    \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                7. Applied rewrites24.9%

                  \[\leadsto \mathsf{fma}\left(\ell + \ell, \color{blue}{J}, U\right) \]
                8. Taylor expanded in J around inf

                  \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) \]
                9. Step-by-step derivation
                  1. associate-*r*N/A

                    \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                  2. lower-*.f64N/A

                    \[\leadsto \left(2 \cdot J\right) \cdot \ell \]
                  3. count-2-revN/A

                    \[\leadsto \left(J + J\right) \cdot \ell \]
                  4. lift-+.f6421.8

                    \[\leadsto \left(J + J\right) \cdot \ell \]
                10. Applied rewrites21.8%

                  \[\leadsto \left(J + J\right) \cdot \ell \]

                if -1600 < l < 7.0000000000000003e-38

                1. Initial program 72.1%

                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                2. Taylor expanded in J around 0

                  \[\leadsto \color{blue}{U} \]
                3. Step-by-step derivation
                  1. Applied rewrites70.9%

                    \[\leadsto \color{blue}{U} \]
                4. Recombined 2 regimes into one program.
                5. Add Preprocessing

                Alternative 25: 36.1% accurate, 68.7× speedup?

                \[\begin{array}{l} \\ U \end{array} \]
                (FPCore (J l K U) :precision binary64 U)
                double code(double J, double l, double K, double U) {
                	return U;
                }
                
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(j, l, k, u)
                use fmin_fmax_functions
                    real(8), intent (in) :: j
                    real(8), intent (in) :: l
                    real(8), intent (in) :: k
                    real(8), intent (in) :: u
                    code = u
                end function
                
                public static double code(double J, double l, double K, double U) {
                	return U;
                }
                
                def code(J, l, K, U):
                	return U
                
                function code(J, l, K, U)
                	return U
                end
                
                function tmp = code(J, l, K, U)
                	tmp = U;
                end
                
                code[J_, l_, K_, U_] := U
                
                \begin{array}{l}
                
                \\
                U
                \end{array}
                
                Derivation
                1. Initial program 85.9%

                  \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                2. Taylor expanded in J around 0

                  \[\leadsto \color{blue}{U} \]
                3. Step-by-step derivation
                  1. Applied rewrites36.1%

                    \[\leadsto \color{blue}{U} \]
                  2. Add Preprocessing

                  Reproduce

                  ?
                  herbie shell --seed 2025130 
                  (FPCore (J l K U)
                    :name "Maksimov and Kolovsky, Equation (4)"
                    :precision binary64
                    (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))