Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.3% → 99.9%
Time: 6.1s
Alternatives: 17
Speedup: 1.2×

Specification

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 86.3% accurate, 1.0× speedup?

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

Alternative 1: 99.9% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \cos \left(0.5 \cdot K\right) \cdot 1\\ t_1 := \sin \left(K \cdot -0.5\right) \cdot 0\\ \mathsf{fma}\left(\frac{t\_1 \cdot t\_1 - t\_0 \cdot t\_0}{t\_1 - t\_0} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \end{array} \]
(FPCore (J l K U)
  :precision binary64
  (let* ((t_0 (* (cos (* 0.5 K)) 1.0)) (t_1 (* (sin (* K -0.5)) 0.0)))
  (fma
   (* (/ (- (* t_1 t_1) (* t_0 t_0)) (- t_1 t_0)) (* (sinh l) 2.0))
   J
   U)))
double code(double J, double l, double K, double U) {
	double t_0 = cos((0.5 * K)) * 1.0;
	double t_1 = sin((K * -0.5)) * 0.0;
	return fma(((((t_1 * t_1) - (t_0 * t_0)) / (t_1 - t_0)) * (sinh(l) * 2.0)), J, U);
}
function code(J, l, K, U)
	t_0 = Float64(cos(Float64(0.5 * K)) * 1.0)
	t_1 = Float64(sin(Float64(K * -0.5)) * 0.0)
	return fma(Float64(Float64(Float64(Float64(t_1 * t_1) - Float64(t_0 * t_0)) / Float64(t_1 - t_0)) * Float64(sinh(l) * 2.0)), J, U)
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(K * -0.5), $MachinePrecision]], $MachinePrecision] * 0.0), $MachinePrecision]}, N[(N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - t$95$0), $MachinePrecision]), $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]]
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot K\right) \cdot 1\\
t_1 := \sin \left(K \cdot -0.5\right) \cdot 0\\
\mathsf{fma}\left(\frac{t\_1 \cdot t\_1 - t\_0 \cdot t\_0}{t\_1 - t\_0} \cdot \left(\sinh \ell \cdot 2\right), J, U\right)
\end{array}
Derivation
  1. Initial program 86.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\left(\sin \left(\frac{-1}{2} \cdot K\right) \cdot \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right) + \cos \left(K \cdot \color{blue}{\frac{1}{2}}\right) \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
    9. metadata-evalN/A

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

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

      \[\leadsto \mathsf{fma}\left(\left(\sin \left(\frac{-1}{2} \cdot K\right) \cdot \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right) + \cos \color{blue}{\left(\frac{K}{2}\right)} \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
    12. flip-+N/A

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\left(\sin \left(\frac{-1}{2} \cdot K\right) \cdot \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left(\sin \left(\frac{-1}{2} \cdot K\right) \cdot \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) - \left(\cos \left(\frac{K}{2}\right) \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right)}{\sin \left(\frac{-1}{2} \cdot K\right) \cdot \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right) - \cos \left(\frac{K}{2}\right) \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)}} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
  5. Applied rewrites99.9%

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

Alternative 2: 99.9% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

Alternative 3: 99.9% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 88.0% accurate, 0.6× speedup?

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

\mathbf{elif}\;t\_0 \leq -0.01:\\
\;\;\;\;\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, U\right)\\


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

    1. Initial program 86.3%

      \[\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.f6464.4%

        \[\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 rewrites64.4%

      \[\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.85199999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.01

    1. Initial program 86.3%

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

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

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

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

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

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

    1. Initial program 86.3%

      \[\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.f6473.3%

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

      \[\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. lift-sinh.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(J + J, \sinh \color{blue}{\ell}, U\right) \]
    6. Applied rewrites80.4%

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

Alternative 5: 87.6% accurate, 0.6× speedup?

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

\mathbf{elif}\;t\_0 \leq -0.01:\\
\;\;\;\;\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, U\right)\\


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

    1. Initial program 86.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 86.3%

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

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

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

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

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

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

    1. Initial program 86.3%

      \[\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.f6473.3%

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

      \[\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. lift-sinh.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(J + J, \sinh \color{blue}{\ell}, U\right) \]
    6. Applied rewrites80.4%

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

Alternative 6: 87.6% accurate, 0.8× speedup?

\[\begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\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, U\right)\\ \end{array} \]
(FPCore (J l K U)
  :precision binary64
  (if (<= (cos (/ K 2.0)) -0.01)
  (fma (* (cos (* 0.5 K)) (+ l l)) J 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.01) {
		tmp = fma((cos((0.5 * K)) * (l + l)), J, 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.01)
		tmp = fma(Float64(cos(Float64(0.5 * K)) * Float64(l + l)), J, 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.01], N[(N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(l + l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\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, U\right)\\


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

    1. Initial program 86.3%

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

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

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

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

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

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

    1. Initial program 86.3%

      \[\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.f6473.3%

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

      \[\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. lift-sinh.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(J + J, \sinh \color{blue}{\ell}, U\right) \]
    6. Applied rewrites80.4%

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

Alternative 7: 87.5% accurate, 0.8× speedup?

\[\begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(0.5 \cdot K\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\ \end{array} \]
(FPCore (J l K U)
  :precision binary64
  (if (<= (cos (/ K 2.0)) -0.01)
  (fma (* (+ l l) J) (cos (* 0.5 K)) 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.01) {
		tmp = fma(((l + l) * J), cos((0.5 * K)), 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.01)
		tmp = fma(Float64(Float64(l + l) * J), cos(Float64(0.5 * K)), 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.01], N[(N[(N[(l + l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(0.5 \cdot K\right), U\right)\\

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


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

    1. Initial program 86.3%

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

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

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

      \[\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. lower-fma.f6464.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\ell + \color{blue}{\ell}\right) \cdot J, \cos \mathsf{Rewrite<=}\left(lift-*.f64, \left(\frac{1}{2} \cdot K\right)\right), U\right) \]
    6. Applied rewrites64.7%

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

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

    1. Initial program 86.3%

      \[\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.f6473.3%

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

      \[\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. lift-sinh.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(J + J, \sinh \color{blue}{\ell}, U\right) \]
    6. Applied rewrites80.4%

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

Alternative 8: 84.9% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 86.3%

      \[\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.f6473.3%

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

      \[\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 rewrites55.2%

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

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

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

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

          \[\leadsto U + J \cdot \left(1 - \left(1 + \ell \cdot \left(\frac{1}{2} \cdot \ell - 1\right)\right)\right) \]
        4. lower-*.f6452.1%

          \[\leadsto U + J \cdot \left(1 - \left(1 + \ell \cdot \left(0.5 \cdot \ell - 1\right)\right)\right) \]
      4. Applied rewrites52.1%

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

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

      1. Initial program 86.3%

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

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

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

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

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

          \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
        5. lower-*.f6464.6%

          \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U \]
      4. Applied rewrites64.6%

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

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

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

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

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

          \[\leadsto 2 \cdot \mathsf{fma}\left(\frac{-1}{8}, J \cdot \left({K}^{2} \cdot \ell\right), J \cdot \ell\right) + U \]
        5. lower-*.f6445.0%

          \[\leadsto 2 \cdot \mathsf{fma}\left(-0.125, J \cdot \left({K}^{2} \cdot \ell\right), J \cdot \ell\right) + U \]
      7. Applied rewrites45.0%

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

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

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

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

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

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

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

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

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

          \[\leadsto 2 \cdot \mathsf{fma}\left(\ell, J, \left(\left({K}^{2} \cdot \ell\right) \cdot J\right) \cdot \frac{-1}{8}\right) + U \]
        10. lower-*.f6448.0%

          \[\leadsto 2 \cdot \mathsf{fma}\left(\ell, J, \left(\left({K}^{2} \cdot \ell\right) \cdot J\right) \cdot -0.125\right) + U \]
        11. lift-pow.f64N/A

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

          \[\leadsto 2 \cdot \mathsf{fma}\left(\ell, J, \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot \frac{-1}{8}\right) + U \]
        13. lower-*.f6448.0%

          \[\leadsto 2 \cdot \mathsf{fma}\left(\ell, J, \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.125\right) + U \]
      9. Applied rewrites48.0%

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

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

      1. Initial program 86.3%

        \[\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.f6473.3%

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

        \[\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. lift-sinh.f64N/A

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(J + J, \sinh \color{blue}{\ell}, U\right) \]
      6. Applied rewrites80.4%

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

    Alternative 9: 84.4% accurate, 1.1× speedup?

    \[\begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;U + J \cdot \left(1 - \left(1 + \ell \cdot \left(0.5 \cdot \ell - 1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\ \end{array} \]
    (FPCore (J l K U)
      :precision binary64
      (if (<= (cos (/ K 2.0)) -0.01)
      (+ U (* J (- 1.0 (+ 1.0 (* l (- (* 0.5 l) 1.0))))))
      (fma (+ J J) (sinh l) U)))
    double code(double J, double l, double K, double U) {
    	double tmp;
    	if (cos((K / 2.0)) <= -0.01) {
    		tmp = U + (J * (1.0 - (1.0 + (l * ((0.5 * l) - 1.0)))));
    	} 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.01)
    		tmp = Float64(U + Float64(J * Float64(1.0 - Float64(1.0 + Float64(l * Float64(Float64(0.5 * l) - 1.0))))));
    	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.01], N[(U + N[(J * N[(1.0 - N[(1.0 + N[(l * N[(N[(0.5 * l), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]
    
    \begin{array}{l}
    \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
    \;\;\;\;U + J \cdot \left(1 - \left(1 + \ell \cdot \left(0.5 \cdot \ell - 1\right)\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.01

      1. Initial program 86.3%

        \[\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.f6473.3%

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

        \[\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 rewrites55.2%

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

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

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

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

            \[\leadsto U + J \cdot \left(1 - \left(1 + \ell \cdot \left(\frac{1}{2} \cdot \ell - 1\right)\right)\right) \]
          4. lower-*.f6452.1%

            \[\leadsto U + J \cdot \left(1 - \left(1 + \ell \cdot \left(0.5 \cdot \ell - 1\right)\right)\right) \]
        4. Applied rewrites52.1%

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

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

        1. Initial program 86.3%

          \[\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.f6473.3%

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

          \[\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. lift-sinh.f64N/A

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(J + J, \sinh \color{blue}{\ell}, U\right) \]
        6. Applied rewrites80.4%

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

      Alternative 10: 75.0% accurate, 3.0× speedup?

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

        1. Initial program 86.3%

          \[\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.f6473.3%

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

          \[\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 rewrites55.2%

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

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

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

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

              \[\leadsto \left(1 - e^{-\ell}\right) \cdot J + U \]
            5. lower-fma.f6455.2%

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

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

          if -1.2500000000000001e-6 < l

          1. Initial program 86.3%

            \[\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.f6473.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(J \cdot {\ell}^{2}\right) \cdot \frac{1}{3}}{2 \cdot J}\right) \cdot \left(2 \cdot J\right)\right) \]
            8. lower-*.f6470.3%

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left({\ell}^{2} \cdot J\right) \cdot \frac{1}{3}}{2 \cdot J}\right) \cdot \left(2 \cdot J\right)\right) \]
            11. lower-*.f6470.3%

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot \frac{1}{3}}{2 \cdot J}\right) \cdot \left(2 \cdot J\right)\right) \]
            14. lower-*.f6470.3%

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot \frac{1}{3}}{J + J}\right) \cdot \left(2 \cdot J\right)\right) \]
            17. lower-+.f6470.3%

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot \frac{1}{3}}{J + J}\right) \cdot \left(J + J\right)\right) \]
            20. lower-+.f6470.3%

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333}{J + J}\right) \cdot \left(J + J\right)\right) \]
          9. Applied rewrites70.3%

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

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot \frac{1}{3}}{J + J}\right) \cdot \left(J + J\right)\right) \]
            4. sum-to-mult-revN/A

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

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

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

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

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

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

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

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

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

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

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(\frac{1}{3} \cdot \ell, J \cdot \color{blue}{\ell}, J + J\right) \]
            15. lower-*.f6469.6%

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(0.3333333333333333 \cdot \ell, J \cdot \ell, J + J\right) \]
            16. lift-*.f64N/A

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

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(\frac{1}{3} \cdot \ell, \ell \cdot J, J + J\right) \]
            18. lower-*.f6469.6%

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(0.3333333333333333 \cdot \ell, \ell \cdot J, J + J\right) \]
          11. Applied rewrites69.6%

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

        Alternative 11: 74.1% accurate, 1.2× speedup?

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

          1. Initial program 86.3%

            \[\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.f6473.3%

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

            \[\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 rewrites55.2%

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

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

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

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

                \[\leadsto U + J \cdot \left(1 - \left(1 + \ell \cdot \left(\frac{1}{2} \cdot \ell - 1\right)\right)\right) \]
              4. lower-*.f6452.1%

                \[\leadsto U + J \cdot \left(1 - \left(1 + \ell \cdot \left(0.5 \cdot \ell - 1\right)\right)\right) \]
            4. Applied rewrites52.1%

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

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

            1. Initial program 86.3%

              \[\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.f6473.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto U + \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333 \cdot J, 2 \cdot J\right) \]
              10. lift-*.f64N/A

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

                \[\leadsto U + \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \frac{1}{3} \cdot J, J + J\right) \]
              12. lower-+.f6470.3%

                \[\leadsto U + \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333 \cdot J, J + J\right) \]
            9. Applied rewrites70.3%

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

          Alternative 12: 70.3% accurate, 3.6× speedup?

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

            \[\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.f6473.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333 \cdot J, 2 \cdot J\right) \]
            10. lift-*.f64N/A

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

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \frac{1}{3} \cdot J, J + J\right) \]
            12. lower-+.f6470.3%

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333 \cdot J, J + J\right) \]
          9. Applied rewrites70.3%

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

          Alternative 13: 69.6% accurate, 3.6× speedup?

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

            \[\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.f6473.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(J \cdot {\ell}^{2}\right) \cdot \frac{1}{3}}{2 \cdot J}\right) \cdot \left(2 \cdot J\right)\right) \]
            8. lower-*.f6470.3%

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left({\ell}^{2} \cdot J\right) \cdot \frac{1}{3}}{2 \cdot J}\right) \cdot \left(2 \cdot J\right)\right) \]
            11. lower-*.f6470.3%

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot \frac{1}{3}}{2 \cdot J}\right) \cdot \left(2 \cdot J\right)\right) \]
            14. lower-*.f6470.3%

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot \frac{1}{3}}{J + J}\right) \cdot \left(2 \cdot J\right)\right) \]
            17. lower-+.f6470.3%

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot \frac{1}{3}}{J + J}\right) \cdot \left(J + J\right)\right) \]
            20. lower-+.f6470.3%

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333}{J + J}\right) \cdot \left(J + J\right)\right) \]
          9. Applied rewrites70.3%

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

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

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

              \[\leadsto U + \ell \cdot \left(\left(1 + \frac{\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot \frac{1}{3}}{J + J}\right) \cdot \left(J + J\right)\right) \]
            4. sum-to-mult-revN/A

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

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

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

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

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

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

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

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

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

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

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(\frac{1}{3} \cdot \ell, J \cdot \color{blue}{\ell}, J + J\right) \]
            15. lower-*.f6469.6%

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(0.3333333333333333 \cdot \ell, J \cdot \ell, J + J\right) \]
            16. lift-*.f64N/A

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

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(\frac{1}{3} \cdot \ell, \ell \cdot J, J + J\right) \]
            18. lower-*.f6469.6%

              \[\leadsto U + \ell \cdot \mathsf{fma}\left(0.3333333333333333 \cdot \ell, \ell \cdot J, J + J\right) \]
          11. Applied rewrites69.6%

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

          Alternative 14: 58.3% accurate, 3.6× speedup?

          \[\begin{array}{l} t_0 := \left(\ell \cdot J\right) \cdot 2\\ \mathbf{if}\;\ell \leq 4 \cdot 10^{+49}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t\_0}{U}, U, U\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(t\_0 + U\right) \cdot U}{U}\\ \end{array} \]
          (FPCore (J l K U)
            :precision binary64
            (let* ((t_0 (* (* l J) 2.0)))
            (if (<= l 4e+49) (fma (/ t_0 U) U U) (/ (* (+ t_0 U) U) U))))
          double code(double J, double l, double K, double U) {
          	double t_0 = (l * J) * 2.0;
          	double tmp;
          	if (l <= 4e+49) {
          		tmp = fma((t_0 / U), U, U);
          	} else {
          		tmp = ((t_0 + U) * U) / U;
          	}
          	return tmp;
          }
          
          function code(J, l, K, U)
          	t_0 = Float64(Float64(l * J) * 2.0)
          	tmp = 0.0
          	if (l <= 4e+49)
          		tmp = fma(Float64(t_0 / U), U, U);
          	else
          		tmp = Float64(Float64(Float64(t_0 + U) * U) / U);
          	end
          	return tmp
          end
          
          code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(l * J), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[l, 4e+49], N[(N[(t$95$0 / U), $MachinePrecision] * U + U), $MachinePrecision], N[(N[(N[(t$95$0 + U), $MachinePrecision] * U), $MachinePrecision] / U), $MachinePrecision]]]
          
          \begin{array}{l}
          t_0 := \left(\ell \cdot J\right) \cdot 2\\
          \mathbf{if}\;\ell \leq 4 \cdot 10^{+49}:\\
          \;\;\;\;\mathsf{fma}\left(\frac{t\_0}{U}, U, U\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\left(t\_0 + U\right) \cdot U}{U}\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if l < 3.9999999999999998e49

            1. Initial program 86.3%

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

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

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

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

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

                \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
              5. lower-*.f6464.6%

                \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U \]
            4. Applied rewrites64.6%

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

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

                \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
            7. Applied rewrites54.6%

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

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

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

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

                \[\leadsto \color{blue}{\left(1 + \frac{2 \cdot \left(J \cdot \ell\right)}{U}\right) \cdot U} \]
            9. Applied rewrites58.0%

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

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

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

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

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

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

                \[\leadsto \frac{\left(J \cdot \ell\right) \cdot 2}{U} \cdot U + \color{blue}{U} \]
              7. lower-fma.f6458.0%

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

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

            if 3.9999999999999998e49 < l

            1. Initial program 86.3%

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

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

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

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

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

                \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
              5. lower-*.f6464.6%

                \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U \]
            4. Applied rewrites64.6%

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

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

                \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
            7. Applied rewrites54.6%

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

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

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

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

                \[\leadsto \color{blue}{\left(1 + \frac{2 \cdot \left(J \cdot \ell\right)}{U}\right) \cdot U} \]
            9. Applied rewrites58.0%

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

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

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

                \[\leadsto \left(1 + \color{blue}{\frac{\left(J \cdot \ell\right) \cdot 2}{U}}\right) \cdot U \]
              4. add-to-fractionN/A

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

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

                \[\leadsto \color{blue}{\frac{\left(1 \cdot U + \left(J \cdot \ell\right) \cdot 2\right) \cdot U}{U}} \]
            11. Applied rewrites42.8%

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

          Alternative 15: 58.0% accurate, 4.6× speedup?

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

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

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

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

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

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

              \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
            5. lower-*.f6464.6%

              \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U \]
          4. Applied rewrites64.6%

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

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

              \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
          7. Applied rewrites54.6%

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

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

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

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

              \[\leadsto \color{blue}{\left(1 + \frac{2 \cdot \left(J \cdot \ell\right)}{U}\right) \cdot U} \]
          9. Applied rewrites58.0%

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

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

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

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

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

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

              \[\leadsto \frac{\left(J \cdot \ell\right) \cdot 2}{U} \cdot U + \color{blue}{U} \]
            7. lower-fma.f6458.0%

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

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

          Alternative 16: 54.6% accurate, 7.6× speedup?

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

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

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

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

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

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

              \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
            5. lower-*.f6464.6%

              \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U \]
          4. Applied rewrites64.6%

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

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

              \[\leadsto 2 \cdot \left(J \cdot \ell\right) + U \]
          7. Applied rewrites54.6%

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

          Alternative 17: 37.1% accurate, 72.6× speedup?

          \[U \]
          (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
          
          U
          
          Derivation
          1. Initial program 86.3%

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

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

            Reproduce

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