Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.7% → 99.9%
Time: 6.0s
Alternatives: 18
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 18 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.7% 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, 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.7%

    \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \sinh \ell, 2, U\right)} \]
  4. 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)} \]
  5. Add Preprocessing

Alternative 2: 93.6% accurate, 1.1× speedup?

\[\begin{array}{l} \mathbf{if}\;\ell \leq -4:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(1 - e^{-\ell}\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 22:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), \ell \cdot \left(J + J\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\ \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -4.0)
   (fma (* (cos (* -0.5 K)) (- 1.0 (exp (- l)))) J U)
   (if (<= l 22.0)
     (fma (cos (* 0.5 K)) (* l (+ J J)) U)
     (fma (* (+ J J) (sinh l)) (fma (* K K) -0.125 1.0) U))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -4.0) {
		tmp = fma((cos((-0.5 * K)) * (1.0 - exp(-l))), J, U);
	} else if (l <= 22.0) {
		tmp = fma(cos((0.5 * K)), (l * (J + J)), U);
	} else {
		tmp = fma(((J + J) * sinh(l)), fma((K * K), -0.125, 1.0), U);
	}
	return tmp;
}
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -4.0)
		tmp = fma(Float64(cos(Float64(-0.5 * K)) * Float64(1.0 - exp(Float64(-l)))), J, U);
	elseif (l <= 22.0)
		tmp = fma(cos(Float64(0.5 * K)), Float64(l * Float64(J + J)), U);
	else
		tmp = fma(Float64(Float64(J + J) * sinh(l)), fma(Float64(K * K), -0.125, 1.0), U);
	end
	return tmp
end
code[J_, l_, K_, U_] := If[LessEqual[l, -4.0], N[(N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 22.0], N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J + J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\ell \leq -4:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(1 - e^{-\ell}\right), J, U\right)\\

\mathbf{elif}\;\ell \leq 22:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), \ell \cdot \left(J + J\right), U\right)\\

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


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

    1. Initial program 86.7%

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(\left(1 - 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(1 - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
      3. Applied rewrites62.3%

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

      if -4 < l < 22

      1. Initial program 86.7%

        \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \color{blue}{\ell}, 2, U\right) \]
      5. Step-by-step derivation
        1. Applied rewrites63.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 22 < l

        1. Initial program 86.7%

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

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

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

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

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

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

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

      Alternative 3: 87.3% accurate, 0.4× speedup?

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

        1. Initial program 86.7%

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

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

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

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

        1. Initial program 86.7%

          \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \color{blue}{\ell}, 2, U\right) \]
        5. Step-by-step derivation
          1. Applied rewrites63.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

        Alternative 4: 87.3% accurate, 0.6× speedup?

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(J \cdot \left(e^{\ell} - \color{blue}{e^{-\ell}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            10. sub-flipN/A

              \[\leadsto \mathsf{fma}\left(J \cdot \color{blue}{\left(e^{\ell} + \left(\mathsf{neg}\left(e^{-\ell}\right)\right)\right)}, \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            11. distribute-rgt-inN/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{e^{\ell} \cdot J + \left(\mathsf{neg}\left(e^{-\ell}\right)\right) \cdot J}, \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            12. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(J \cdot \left(e^{\ell} - \color{blue}{e^{-\ell}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            10. sub-flipN/A

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \left(\mathsf{neg}\left(e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right)\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            16. exp-negN/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{e^{\ell}}}\right)\right)\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            17. distribute-neg-frac2N/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \color{blue}{\frac{1}{\mathsf{neg}\left(e^{\ell}\right)}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            18. mult-flip-revN/A

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, \frac{J}{\color{blue}{-e^{\ell}}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            21. lower-exp.f6464.8%

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, \frac{J}{-\color{blue}{e^{\ell}}}\right), \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right) \]
          8. Applied rewrites64.8%

            \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(J, e^{\ell}, \frac{J}{-e^{\ell}}\right)}, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right) \]
          9. Taylor expanded in K around 0

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

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

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

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

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

              \[\leadsto U + \mathsf{fma}\left(-1, \frac{J}{e^{\ell}}, J \cdot e^{\ell}\right) \]
            6. lower-exp.f6473.2%

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

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

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

        Alternative 5: 86.9% accurate, 0.6× speedup?

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(J \cdot \left(e^{\ell} - \color{blue}{e^{-\ell}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            10. sub-flipN/A

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \left(\mathsf{neg}\left(e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right)\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            16. exp-negN/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{e^{\ell}}}\right)\right)\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            17. distribute-neg-frac2N/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \color{blue}{\frac{1}{\mathsf{neg}\left(e^{\ell}\right)}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            18. mult-flip-revN/A

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, \frac{J}{\color{blue}{-e^{\ell}}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            21. lower-exp.f6464.8%

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, \frac{J}{-\color{blue}{e^{\ell}}}\right), \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right) \]
          8. Applied rewrites64.8%

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

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(J \cdot \left(e^{\ell} - \color{blue}{e^{-\ell}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            10. sub-flipN/A

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \left(\mathsf{neg}\left(e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right)\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            16. exp-negN/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{e^{\ell}}}\right)\right)\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            17. distribute-neg-frac2N/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \color{blue}{\frac{1}{\mathsf{neg}\left(e^{\ell}\right)}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            18. mult-flip-revN/A

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, \frac{J}{\color{blue}{-e^{\ell}}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            21. lower-exp.f6464.8%

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, \frac{J}{-\color{blue}{e^{\ell}}}\right), \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right) \]
          8. Applied rewrites64.8%

            \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(J, e^{\ell}, \frac{J}{-e^{\ell}}\right)}, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right) \]
          9. Taylor expanded in K around 0

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

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

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

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

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

              \[\leadsto U + \mathsf{fma}\left(-1, \frac{J}{e^{\ell}}, J \cdot e^{\ell}\right) \]
            6. lower-exp.f6473.2%

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

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

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

        Alternative 6: 86.2% accurate, 0.6× speedup?

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

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

              \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
            10. sub-to-fractionN/A

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

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

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

            \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
          4. Taylor expanded in K around 0

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

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

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            3. lower-*.f6462.5%

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
          6. Applied rewrites62.5%

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

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

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

              \[\leadsto \frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \color{blue}{\ell}\right)\right)}{e^{\ell}} + U \]
            3. lower-*.f6450.4%

              \[\leadsto \frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \ell\right)\right)}{e^{\ell}} + U \]
          9. Applied rewrites50.4%

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

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(J \cdot \left(e^{\ell} - \color{blue}{e^{-\ell}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            10. sub-flipN/A

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \left(\mathsf{neg}\left(e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right)\right)\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            16. exp-negN/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{e^{\ell}}}\right)\right)\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            17. distribute-neg-frac2N/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, J \cdot \color{blue}{\frac{1}{\mathsf{neg}\left(e^{\ell}\right)}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            18. mult-flip-revN/A

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, \frac{J}{\color{blue}{-e^{\ell}}}\right), \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right), U\right) \]
            21. lower-exp.f6464.8%

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, \frac{J}{-\color{blue}{e^{\ell}}}\right), \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right) \]
          8. Applied rewrites64.8%

            \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(J, e^{\ell}, \frac{J}{-e^{\ell}}\right)}, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right) \]
          9. Taylor expanded in K around 0

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

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

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

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

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

              \[\leadsto U + \mathsf{fma}\left(-1, \frac{J}{e^{\ell}}, J \cdot e^{\ell}\right) \]
            6. lower-exp.f6473.2%

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

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

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

        Alternative 7: 86.2% accurate, 0.6× speedup?

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

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

              \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
            10. sub-to-fractionN/A

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

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

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

            \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
          4. Taylor expanded in K around 0

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

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

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            3. lower-*.f6462.5%

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
          6. Applied rewrites62.5%

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

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

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

              \[\leadsto \frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \color{blue}{\ell}\right)\right)}{e^{\ell}} + U \]
            3. lower-*.f6450.4%

              \[\leadsto \frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \ell\right)\right)}{e^{\ell}} + U \]
          9. Applied rewrites50.4%

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

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

          1. Initial program 86.7%

            \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto U + J \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) \]
            6. lower-exp.f6473.2%

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

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

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

        Alternative 8: 86.2% accurate, 0.6× speedup?

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

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

              \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
            10. sub-to-fractionN/A

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

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

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

            \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
          4. Taylor expanded in K around 0

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

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

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            3. lower-*.f6462.5%

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
          6. Applied rewrites62.5%

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

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

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

              \[\leadsto \frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \color{blue}{\ell}\right)\right)}{e^{\ell}} + U \]
            3. lower-*.f6450.4%

              \[\leadsto \frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \ell\right)\right)}{e^{\ell}} + U \]
          9. Applied rewrites50.4%

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

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

          1. Initial program 86.7%

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

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

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

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

          1. Initial program 86.7%

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

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

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

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

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

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

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

        Alternative 9: 80.6% accurate, 1.0× speedup?

        \[\begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\ \;\;\;\;\frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \ell\right)\right)}{e^{\ell}} + U\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \end{array} \]
        (FPCore (J l K U)
         :precision binary64
         (if (<= (cos (/ K 2.0)) -0.02)
           (+ (/ (* J (* l (+ 2.0 (* 2.0 l)))) (exp l)) U)
           (+ U (* J (- (exp l) (exp (- l)))))))
        double code(double J, double l, double K, double U) {
        	double tmp;
        	if (cos((K / 2.0)) <= -0.02) {
        		tmp = ((J * (l * (2.0 + (2.0 * l)))) / exp(l)) + U;
        	} else {
        		tmp = U + (J * (exp(l) - exp(-l)));
        	}
        	return tmp;
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(8) function code(j, l, k, u)
        use fmin_fmax_functions
            real(8), intent (in) :: j
            real(8), intent (in) :: l
            real(8), intent (in) :: k
            real(8), intent (in) :: u
            real(8) :: tmp
            if (cos((k / 2.0d0)) <= (-0.02d0)) then
                tmp = ((j * (l * (2.0d0 + (2.0d0 * l)))) / exp(l)) + u
            else
                tmp = u + (j * (exp(l) - exp(-l)))
            end if
            code = tmp
        end function
        
        public static double code(double J, double l, double K, double U) {
        	double tmp;
        	if (Math.cos((K / 2.0)) <= -0.02) {
        		tmp = ((J * (l * (2.0 + (2.0 * l)))) / Math.exp(l)) + U;
        	} else {
        		tmp = U + (J * (Math.exp(l) - Math.exp(-l)));
        	}
        	return tmp;
        }
        
        def code(J, l, K, U):
        	tmp = 0
        	if math.cos((K / 2.0)) <= -0.02:
        		tmp = ((J * (l * (2.0 + (2.0 * l)))) / math.exp(l)) + U
        	else:
        		tmp = U + (J * (math.exp(l) - math.exp(-l)))
        	return tmp
        
        function code(J, l, K, U)
        	tmp = 0.0
        	if (cos(Float64(K / 2.0)) <= -0.02)
        		tmp = Float64(Float64(Float64(J * Float64(l * Float64(2.0 + Float64(2.0 * l)))) / exp(l)) + U);
        	else
        		tmp = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l)))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(J, l, K, U)
        	tmp = 0.0;
        	if (cos((K / 2.0)) <= -0.02)
        		tmp = ((J * (l * (2.0 + (2.0 * l)))) / exp(l)) + U;
        	else
        		tmp = U + (J * (exp(l) - exp(-l)));
        	end
        	tmp_2 = tmp;
        end
        
        code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(N[(N[(J * N[(l * N[(2.0 + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
        \;\;\;\;\frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \ell\right)\right)}{e^{\ell}} + U\\
        
        \mathbf{else}:\\
        \;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0200000000000000004

          1. Initial program 86.7%

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

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

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

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

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

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

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

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

              \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
            10. sub-to-fractionN/A

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

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

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

            \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
          4. Taylor expanded in K around 0

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

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

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            3. lower-*.f6462.5%

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
          6. Applied rewrites62.5%

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

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

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

              \[\leadsto \frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \color{blue}{\ell}\right)\right)}{e^{\ell}} + U \]
            3. lower-*.f6450.4%

              \[\leadsto \frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \ell\right)\right)}{e^{\ell}} + U \]
          9. Applied rewrites50.4%

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

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

          1. Initial program 86.7%

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

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

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

        Alternative 10: 80.6% accurate, 2.1× speedup?

        \[\begin{array}{l} \mathbf{if}\;\ell \leq 500:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\ell + \ell\right) \cdot J}{e^{\ell}} + U\\ \mathbf{else}:\\ \;\;\;\;\frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{1 + \ell} + U\\ \end{array} \]
        (FPCore (J l K U)
         :precision binary64
         (if (<= l 500.0)
           (+ (/ (* (expm1 (+ l l)) J) (exp l)) U)
           (+ (/ (* J (expm1 (* 2.0 l))) (+ 1.0 l)) U)))
        double code(double J, double l, double K, double U) {
        	double tmp;
        	if (l <= 500.0) {
        		tmp = ((expm1((l + l)) * J) / exp(l)) + U;
        	} else {
        		tmp = ((J * expm1((2.0 * l))) / (1.0 + l)) + U;
        	}
        	return tmp;
        }
        
        public static double code(double J, double l, double K, double U) {
        	double tmp;
        	if (l <= 500.0) {
        		tmp = ((Math.expm1((l + l)) * J) / Math.exp(l)) + U;
        	} else {
        		tmp = ((J * Math.expm1((2.0 * l))) / (1.0 + l)) + U;
        	}
        	return tmp;
        }
        
        def code(J, l, K, U):
        	tmp = 0
        	if l <= 500.0:
        		tmp = ((math.expm1((l + l)) * J) / math.exp(l)) + U
        	else:
        		tmp = ((J * math.expm1((2.0 * l))) / (1.0 + l)) + U
        	return tmp
        
        function code(J, l, K, U)
        	tmp = 0.0
        	if (l <= 500.0)
        		tmp = Float64(Float64(Float64(expm1(Float64(l + l)) * J) / exp(l)) + U);
        	else
        		tmp = Float64(Float64(Float64(J * expm1(Float64(2.0 * l))) / Float64(1.0 + l)) + U);
        	end
        	return tmp
        end
        
        code[J_, l_, K_, U_] := If[LessEqual[l, 500.0], N[(N[(N[(N[(Exp[N[(l + l), $MachinePrecision]] - 1), $MachinePrecision] * J), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J * N[(Exp[N[(2.0 * l), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(1.0 + l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
        
        \begin{array}{l}
        \mathbf{if}\;\ell \leq 500:\\
        \;\;\;\;\frac{\mathsf{expm1}\left(\ell + \ell\right) \cdot J}{e^{\ell}} + U\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{1 + \ell} + U\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if l < 500

          1. Initial program 86.7%

            \[\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. *-commutativeN/A

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

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

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

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

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

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

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

              \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
            10. sub-to-fractionN/A

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

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

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

            \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
          4. Taylor expanded in K around 0

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

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

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            3. lower-*.f6462.5%

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
          6. Applied rewrites62.5%

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

              \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(\ell + \ell\right) \cdot J}{e^{\ell}} + U} \]

            if 500 < l

            1. Initial program 86.7%

              \[\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. *-commutativeN/A

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

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

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

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

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

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

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

                \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
              10. sub-to-fractionN/A

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

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

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

              \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
            4. Taylor expanded in K around 0

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

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

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
              3. lower-*.f6462.5%

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            6. Applied rewrites62.5%

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

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{\color{blue}{1 + \ell}} + U \]
            8. Step-by-step derivation
              1. lower-+.f6462.4%

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

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{\color{blue}{1 + \ell}} + U \]
          8. Recombined 2 regimes into one program.
          9. Add Preprocessing

          Alternative 11: 80.4% accurate, 2.1× speedup?

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

            1. Initial program 86.7%

              \[\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. *-commutativeN/A

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

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

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

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

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

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

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

                \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
              10. sub-to-fractionN/A

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

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

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

              \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
            4. Taylor expanded in K around 0

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

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

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
              3. lower-*.f6462.5%

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            6. Applied rewrites62.5%

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

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

                \[\leadsto \color{blue}{\frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}}} + U \]
              3. mult-flipN/A

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

                \[\leadsto \left(J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)\right) \cdot \frac{1}{\color{blue}{e^{\ell}}} + U \]
              5. exp-negN/A

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\mathsf{neg}\left(\ell\right)}, J \cdot \mathsf{expm1}\left(2 \cdot \ell\right), U\right)} \]
            8. Applied rewrites62.5%

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

            if 500 < l

            1. Initial program 86.7%

              \[\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. *-commutativeN/A

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

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

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

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

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

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

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

                \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
              10. sub-to-fractionN/A

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

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

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

              \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
            4. Taylor expanded in K around 0

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

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

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
              3. lower-*.f6462.5%

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            6. Applied rewrites62.5%

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

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{\color{blue}{1 + \ell}} + U \]
            8. Step-by-step derivation
              1. lower-+.f6462.4%

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

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

          Alternative 12: 79.7% accurate, 2.6× speedup?

          \[\begin{array}{l} \mathbf{if}\;\ell \leq -0.24:\\ \;\;\;\;\frac{J \cdot \left(2 \cdot \ell\right)}{e^{\ell}} + U\\ \mathbf{else}:\\ \;\;\;\;\frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{1 + \ell} + U\\ \end{array} \]
          (FPCore (J l K U)
           :precision binary64
           (if (<= l -0.24)
             (+ (/ (* J (* 2.0 l)) (exp l)) U)
             (+ (/ (* J (expm1 (* 2.0 l))) (+ 1.0 l)) U)))
          double code(double J, double l, double K, double U) {
          	double tmp;
          	if (l <= -0.24) {
          		tmp = ((J * (2.0 * l)) / exp(l)) + U;
          	} else {
          		tmp = ((J * expm1((2.0 * l))) / (1.0 + l)) + U;
          	}
          	return tmp;
          }
          
          public static double code(double J, double l, double K, double U) {
          	double tmp;
          	if (l <= -0.24) {
          		tmp = ((J * (2.0 * l)) / Math.exp(l)) + U;
          	} else {
          		tmp = ((J * Math.expm1((2.0 * l))) / (1.0 + l)) + U;
          	}
          	return tmp;
          }
          
          def code(J, l, K, U):
          	tmp = 0
          	if l <= -0.24:
          		tmp = ((J * (2.0 * l)) / math.exp(l)) + U
          	else:
          		tmp = ((J * math.expm1((2.0 * l))) / (1.0 + l)) + U
          	return tmp
          
          function code(J, l, K, U)
          	tmp = 0.0
          	if (l <= -0.24)
          		tmp = Float64(Float64(Float64(J * Float64(2.0 * l)) / exp(l)) + U);
          	else
          		tmp = Float64(Float64(Float64(J * expm1(Float64(2.0 * l))) / Float64(1.0 + l)) + U);
          	end
          	return tmp
          end
          
          code[J_, l_, K_, U_] := If[LessEqual[l, -0.24], N[(N[(N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J * N[(Exp[N[(2.0 * l), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(1.0 + l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
          
          \begin{array}{l}
          \mathbf{if}\;\ell \leq -0.24:\\
          \;\;\;\;\frac{J \cdot \left(2 \cdot \ell\right)}{e^{\ell}} + U\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{1 + \ell} + U\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if l < -0.23999999999999999

            1. Initial program 86.7%

              \[\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. *-commutativeN/A

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

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

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

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

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

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

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

                \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
              10. sub-to-fractionN/A

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

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

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

              \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
            4. Taylor expanded in K around 0

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

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

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
              3. lower-*.f6462.5%

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            6. Applied rewrites62.5%

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

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

                \[\leadsto \frac{J \cdot \left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            9. Applied rewrites62.6%

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

            if -0.23999999999999999 < l

            1. Initial program 86.7%

              \[\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. *-commutativeN/A

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

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

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

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

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

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

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

                \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
              10. sub-to-fractionN/A

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

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

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

              \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
            4. Taylor expanded in K around 0

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

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

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
              3. lower-*.f6462.5%

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            6. Applied rewrites62.5%

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

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{\color{blue}{1 + \ell}} + U \]
            8. Step-by-step derivation
              1. lower-+.f6462.4%

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

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

          Alternative 13: 70.5% accurate, 2.6× speedup?

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

            1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

            if -8 < l

            1. Initial program 86.7%

              \[\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. *-commutativeN/A

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

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

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

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

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

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

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

                \[\leadsto \left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(e^{\ell} - \frac{1}{\color{blue}{e^{\ell}}}\right) + U \]
              10. sub-to-fractionN/A

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

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

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

              \[\leadsto \color{blue}{\frac{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{expm1}\left(\ell + \ell\right)}{e^{\ell}}} + U \]
            4. Taylor expanded in K around 0

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

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

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
              3. lower-*.f6462.5%

                \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{e^{\ell}} + U \]
            6. Applied rewrites62.5%

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

              \[\leadsto \frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{\color{blue}{1 + \ell}} + U \]
            8. Step-by-step derivation
              1. lower-+.f6462.4%

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

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

          Alternative 14: 59.7% accurate, 2.9× speedup?

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

            1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

            if -11.5 < l < 1.1e25

            1. Initial program 86.7%

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

              \[\leadsto \color{blue}{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-*.f6463.4%

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

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

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

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

            if 1.1e25 < l

            1. Initial program 86.7%

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

              \[\leadsto \color{blue}{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-*.f6463.4%

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 15: 57.5% accurate, 3.5× speedup?

          \[\begin{array}{l} t_0 := \left(\ell \cdot J\right) \cdot 2\\ \mathbf{if}\;\ell \leq 1.16 \cdot 10^{+25}:\\ \;\;\;\;\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 1.16e+25) (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 <= 1.16e+25) {
          		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 <= 1.16e+25)
          		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, 1.16e+25], 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 1.16 \cdot 10^{+25}:\\
          \;\;\;\;\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 < 1.15999999999999992e25

            1. Initial program 86.7%

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

              \[\leadsto \color{blue}{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-*.f6463.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

            if 1.15999999999999992e25 < l

            1. Initial program 86.7%

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

              \[\leadsto \color{blue}{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-*.f6463.4%

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

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

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

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

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

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

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

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

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

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

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

              \[\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 16: 57.2% accurate, 4.5× 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.7%

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

            \[\leadsto \color{blue}{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-*.f6463.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 17: 53.7% accurate, 7.1× 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.7%

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

            \[\leadsto \color{blue}{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-*.f6463.4%

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

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

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

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

          Alternative 18: 37.2% accurate, 68.7× 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.7%

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

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

            Reproduce

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