Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 87.0% → 98.5%
Time: 4.0s
Alternatives: 12
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
	return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
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 12 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: 87.0% 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: 98.5% accurate, 0.9× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\left(J \cdot \left(e^{\ell} - t\_1\right)\right) \cdot t\_0 + U\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.25

    1. Initial program 87.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 \left(J \cdot \left(\color{blue}{1} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Step-by-step derivation
      1. Applied rewrites62.6%

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

      if -1.25 < l < 4.89999999999999974e-51

      1. Initial program 87.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 \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. Step-by-step derivation
        1. lower-*.f6464.6

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

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

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

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

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

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

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

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

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

      if 4.89999999999999974e-51 < l

      1. Initial program 87.0%

        \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Recombined 3 regimes into one program.
    5. Add Preprocessing

    Alternative 2: 93.0% accurate, 1.1× speedup?

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

      1. Initial program 87.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 \left(J \cdot \left(\color{blue}{1} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. Step-by-step derivation
        1. Applied rewrites62.6%

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

        if -1.25 < l < 1.0499999999999999e-6

        1. Initial program 87.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 \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        3. Step-by-step derivation
          1. lower-*.f6464.6

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

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

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

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

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

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

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

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

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

        if 1.0499999999999999e-6 < l

        1. Initial program 87.0%

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

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

            \[\leadsto \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \left(1 + \frac{-1}{8} \cdot \color{blue}{{K}^{2}}\right) + U \]
          3. lower-pow.f6465.1

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)} \]
        7. Step-by-step derivation
          1. lift-fma.f64N/A

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(J + J, \sinh \ell \cdot \left(\frac{-1}{8} \cdot \left(K \cdot K\right) + 1\right), U\right) \]
          8. lower-fma.f6469.2

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

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

      Alternative 3: 89.1% accurate, 0.7× speedup?

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

        1. Initial program 87.0%

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

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

            \[\leadsto \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \left(1 + \frac{-1}{8} \cdot \color{blue}{{K}^{2}}\right) + U \]
          3. lower-pow.f6465.1

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

          \[\leadsto \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \color{blue}{\left(1 + -0.125 \cdot {K}^{2}\right)} + U \]

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

        1. Initial program 87.0%

          \[\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. lower-+.f64N/A

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

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

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

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

            \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
          6. lower-neg.f6474.6

            \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
        4. Applied rewrites74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 4: 87.9% accurate, 1.0× speedup?

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

        1. Initial program 87.0%

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

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

            \[\leadsto \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \left(1 + \frac{-1}{8} \cdot \color{blue}{{K}^{2}}\right) + U \]
          3. lower-pow.f6465.1

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

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

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

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

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

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

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

        1. Initial program 87.0%

          \[\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. lower-+.f64N/A

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

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

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

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

            \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
          6. lower-neg.f6474.6

            \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
        4. Applied rewrites74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 5: 85.4% accurate, 1.1× speedup?

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

        1. Initial program 87.0%

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

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

            \[\leadsto \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \left(1 + \frac{-1}{8} \cdot \color{blue}{{K}^{2}}\right) + U \]
          3. lower-pow.f6465.1

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

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

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

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

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

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

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

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

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

          1. Initial program 87.0%

            \[\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. lower-+.f64N/A

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

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

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

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

              \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
            6. lower-neg.f6474.6

              \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
          4. Applied rewrites74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 6: 70.8% accurate, 2.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -820:\\ \;\;\;\;U + J \cdot \left(1 - e^{-\ell}\right)\\ \mathbf{elif}\;\ell \leq 1.05 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\ \end{array} \end{array} \]
        (FPCore (J l K U)
         :precision binary64
         (if (<= l -820.0)
           (+ U (* J (- 1.0 (exp (- l)))))
           (if (<= l 1.05e-6)
             (fma (+ J J) l U)
             (fma (* (+ J J) l) (fma (* K K) -0.125 1.0) U))))
        double code(double J, double l, double K, double U) {
        	double tmp;
        	if (l <= -820.0) {
        		tmp = U + (J * (1.0 - exp(-l)));
        	} else if (l <= 1.05e-6) {
        		tmp = fma((J + J), l, U);
        	} else {
        		tmp = fma(((J + J) * l), fma((K * K), -0.125, 1.0), U);
        	}
        	return tmp;
        }
        
        function code(J, l, K, U)
        	tmp = 0.0
        	if (l <= -820.0)
        		tmp = Float64(U + Float64(J * Float64(1.0 - exp(Float64(-l)))));
        	elseif (l <= 1.05e-6)
        		tmp = fma(Float64(J + J), l, U);
        	else
        		tmp = fma(Float64(Float64(J + J) * l), fma(Float64(K * K), -0.125, 1.0), U);
        	end
        	return tmp
        end
        
        code[J_, l_, K_, U_] := If[LessEqual[l, -820.0], N[(U + N[(J * N[(1.0 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.05e-6], N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\ell \leq -820:\\
        \;\;\;\;U + J \cdot \left(1 - e^{-\ell}\right)\\
        
        \mathbf{elif}\;\ell \leq 1.05 \cdot 10^{-6}:\\
        \;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if l < -820

          1. Initial program 87.0%

            \[\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. lower-+.f64N/A

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

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

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

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

              \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
            6. lower-neg.f6474.6

              \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
          4. Applied rewrites74.6%

            \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{-\ell}\right)} \]
          5. Taylor expanded in l around 0

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

              \[\leadsto U + J \cdot \left(1 - e^{\color{blue}{-\ell}}\right) \]

            if -820 < l < 1.0499999999999999e-6

            1. Initial program 87.0%

              \[\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. lower-+.f64N/A

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

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

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

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

                \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
              6. lower-neg.f6474.6

                \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
            4. Applied rewrites74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(J + J, \ell, U\right) \]
            8. Step-by-step derivation
              1. Applied rewrites55.2%

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

              if 1.0499999999999999e-6 < l

              1. Initial program 87.0%

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

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

                  \[\leadsto \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \left(1 + \frac{-1}{8} \cdot \color{blue}{{K}^{2}}\right) + U \]
                3. lower-pow.f6465.1

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(J + J\right) \cdot \color{blue}{\ell}, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right) \]
              9. Recombined 3 regimes into one program.
              10. Add Preprocessing

              Alternative 7: 59.9% accurate, 1.2× speedup?

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

                1. Initial program 87.0%

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

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

                    \[\leadsto \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \left(1 + \frac{-1}{8} \cdot \color{blue}{{K}^{2}}\right) + U \]
                  3. lower-pow.f6465.1

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

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

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

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

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

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

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

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

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

                  1. Initial program 87.0%

                    \[\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. lower-+.f64N/A

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

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

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

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

                      \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
                    6. lower-neg.f6474.6

                      \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
                  4. Applied rewrites74.6%

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

                      \[\leadsto U + \color{blue}{J \cdot \left(e^{\ell} - e^{-\ell}\right)} \]
                    2. sum-to-multN/A

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{-\ell}, \frac{J}{U}, 1\right) \cdot U \]
                    10. lift-exp.f64N/A

                      \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{-\ell}, \frac{J}{U}, 1\right) \cdot U \]
                    11. lift-exp.f64N/A

                      \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{-\ell}, \frac{J}{U}, 1\right) \cdot U \]
                    12. lift-neg.f64N/A

                      \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, \frac{J}{U}, 1\right) \cdot U \]
                    13. sinh-undefN/A

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

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

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

                      \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot 2, \frac{J}{U}, 1\right) \cdot U \]
                    17. lower-/.f6474.1

                      \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot 2, \frac{J}{U}, 1\right) \cdot U \]
                  6. Applied rewrites74.1%

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

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

                      \[\leadsto \mathsf{fma}\left(2 \cdot \ell, \frac{J}{U}, 1\right) \cdot U \]
                  9. Applied rewrites56.3%

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

                Alternative 8: 56.5% accurate, 4.5× speedup?

                \[\begin{array}{l} \\ \mathsf{fma}\left(2 \cdot \ell, \frac{J}{U}, 1\right) \cdot U \end{array} \]
                (FPCore (J l K U) :precision binary64 (* (fma (* 2.0 l) (/ J U) 1.0) U))
                double code(double J, double l, double K, double U) {
                	return fma((2.0 * l), (J / U), 1.0) * U;
                }
                
                function code(J, l, K, U)
                	return Float64(fma(Float64(2.0 * l), Float64(J / U), 1.0) * U)
                end
                
                code[J_, l_, K_, U_] := N[(N[(N[(2.0 * l), $MachinePrecision] * N[(J / U), $MachinePrecision] + 1.0), $MachinePrecision] * U), $MachinePrecision]
                
                \begin{array}{l}
                
                \\
                \mathsf{fma}\left(2 \cdot \ell, \frac{J}{U}, 1\right) \cdot U
                \end{array}
                
                Derivation
                1. Initial program 87.0%

                  \[\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. lower-+.f64N/A

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

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

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

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

                    \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
                  6. lower-neg.f6474.6

                    \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
                4. Applied rewrites74.6%

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

                    \[\leadsto U + \color{blue}{J \cdot \left(e^{\ell} - e^{-\ell}\right)} \]
                  2. sum-to-multN/A

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{-\ell}, \frac{J}{U}, 1\right) \cdot U \]
                  10. lift-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{-\ell}, \frac{J}{U}, 1\right) \cdot U \]
                  11. lift-exp.f64N/A

                    \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{-\ell}, \frac{J}{U}, 1\right) \cdot U \]
                  12. lift-neg.f64N/A

                    \[\leadsto \mathsf{fma}\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}, \frac{J}{U}, 1\right) \cdot U \]
                  13. sinh-undefN/A

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

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

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

                    \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot 2, \frac{J}{U}, 1\right) \cdot U \]
                  17. lower-/.f6474.1

                    \[\leadsto \mathsf{fma}\left(\sinh \ell \cdot 2, \frac{J}{U}, 1\right) \cdot U \]
                6. Applied rewrites74.1%

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

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

                    \[\leadsto \mathsf{fma}\left(2 \cdot \ell, \frac{J}{U}, 1\right) \cdot U \]
                9. Applied rewrites56.3%

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

                Alternative 9: 56.3% accurate, 1.6× speedup?

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

                  1. Initial program 87.0%

                    \[\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. lower-+.f64N/A

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

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

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

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

                      \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
                    6. lower-neg.f6474.6

                      \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
                  4. Applied rewrites74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(J + J, \ell, U\right) \]
                  8. Step-by-step derivation
                    1. Applied rewrites55.2%

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

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

                    1. Initial program 87.0%

                      \[\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. lower-+.f64N/A

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

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

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

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

                        \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
                      6. lower-neg.f6474.6

                        \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
                    4. Applied rewrites74.6%

                      \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{-\ell}\right)} \]
                    5. Taylor expanded in J around inf

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

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

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

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

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

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

                        \[\leadsto J \cdot \left(\left(e^{\ell} + \frac{U}{J}\right) - e^{\mathsf{neg}\left(\ell\right)}\right) \]
                      7. lower-neg.f6456.9

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

                      \[\leadsto J \cdot \color{blue}{\left(\left(e^{\ell} + \frac{U}{J}\right) - e^{-\ell}\right)} \]
                    8. Taylor expanded in l around 0

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

                        \[\leadsto J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \]
                      2. lower-/.f6452.3

                        \[\leadsto J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \]
                    10. Applied rewrites52.3%

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

                  Alternative 10: 55.2% accurate, 7.9× speedup?

                  \[\begin{array}{l} \\ \mathsf{fma}\left(J + J, \ell, U\right) \end{array} \]
                  (FPCore (J l K U) :precision binary64 (fma (+ J J) l U))
                  double code(double J, double l, double K, double U) {
                  	return fma((J + J), l, U);
                  }
                  
                  function code(J, l, K, U)
                  	return fma(Float64(J + J), l, U)
                  end
                  
                  code[J_, l_, K_, U_] := N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  \mathsf{fma}\left(J + J, \ell, U\right)
                  \end{array}
                  
                  Derivation
                  1. Initial program 87.0%

                    \[\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. lower-+.f64N/A

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

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

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

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

                      \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
                    6. lower-neg.f6474.6

                      \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
                  4. Applied rewrites74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(J + J, \ell, U\right) \]
                  8. Step-by-step derivation
                    1. Applied rewrites55.2%

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

                    Alternative 11: 39.2% accurate, 1.8× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;J \cdot \left(e^{\ell} - e^{-\ell}\right) \leq 0:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;J \cdot \frac{U}{J}\\ \end{array} \end{array} \]
                    (FPCore (J l K U)
                     :precision binary64
                     (if (<= (* J (- (exp l) (exp (- l)))) 0.0) U (* J (/ U J))))
                    double code(double J, double l, double K, double U) {
                    	double tmp;
                    	if ((J * (exp(l) - exp(-l))) <= 0.0) {
                    		tmp = U;
                    	} else {
                    		tmp = J * (U / J);
                    	}
                    	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) :: tmp
                        if ((j * (exp(l) - exp(-l))) <= 0.0d0) then
                            tmp = u
                        else
                            tmp = j * (u / j)
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double J, double l, double K, double U) {
                    	double tmp;
                    	if ((J * (Math.exp(l) - Math.exp(-l))) <= 0.0) {
                    		tmp = U;
                    	} else {
                    		tmp = J * (U / J);
                    	}
                    	return tmp;
                    }
                    
                    def code(J, l, K, U):
                    	tmp = 0
                    	if (J * (math.exp(l) - math.exp(-l))) <= 0.0:
                    		tmp = U
                    	else:
                    		tmp = J * (U / J)
                    	return tmp
                    
                    function code(J, l, K, U)
                    	tmp = 0.0
                    	if (Float64(J * Float64(exp(l) - exp(Float64(-l)))) <= 0.0)
                    		tmp = U;
                    	else
                    		tmp = Float64(J * Float64(U / J));
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(J, l, K, U)
                    	tmp = 0.0;
                    	if ((J * (exp(l) - exp(-l))) <= 0.0)
                    		tmp = U;
                    	else
                    		tmp = J * (U / J);
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[J_, l_, K_, U_] := If[LessEqual[N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], U, N[(J * N[(U / J), $MachinePrecision]), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;J \cdot \left(e^{\ell} - e^{-\ell}\right) \leq 0:\\
                    \;\;\;\;U\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;J \cdot \frac{U}{J}\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -0.0

                      1. Initial program 87.0%

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

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

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

                        1. Initial program 87.0%

                          \[\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. lower-+.f64N/A

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

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

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

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

                            \[\leadsto U + J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
                          6. lower-neg.f6474.6

                            \[\leadsto U + J \cdot \left(e^{\ell} - e^{-\ell}\right) \]
                        4. Applied rewrites74.6%

                          \[\leadsto \color{blue}{U + J \cdot \left(e^{\ell} - e^{-\ell}\right)} \]
                        5. Taylor expanded in J around inf

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

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

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

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

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

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

                            \[\leadsto J \cdot \left(\left(e^{\ell} + \frac{U}{J}\right) - e^{\mathsf{neg}\left(\ell\right)}\right) \]
                          7. lower-neg.f6456.9

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

                          \[\leadsto J \cdot \color{blue}{\left(\left(e^{\ell} + \frac{U}{J}\right) - e^{-\ell}\right)} \]
                        8. Taylor expanded in J around 0

                          \[\leadsto J \cdot \frac{U}{J} \]
                        9. Step-by-step derivation
                          1. lower-/.f6435.0

                            \[\leadsto J \cdot \frac{U}{J} \]
                        10. Applied rewrites35.0%

                          \[\leadsto J \cdot \frac{U}{J} \]
                      4. Recombined 2 regimes into one program.
                      5. Add Preprocessing

                      Alternative 12: 37.9% 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 87.0%

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

                          \[\leadsto \color{blue}{U} \]
                        2. Add Preprocessing

                        Reproduce

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