Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.5% → 99.9%
Time: 4.3s
Alternatives: 13
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 13 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.5% 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(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot 2, \sinh \ell, U\right) \]
(FPCore (J l K U)
 :precision binary64
 (fma (* (* (cos (* -0.5 K)) J) 2.0) (sinh l) U))
double code(double J, double l, double K, double U) {
	return fma(((cos((-0.5 * K)) * J) * 2.0), sinh(l), U);
}
function code(J, l, K, U)
	return fma(Float64(Float64(cos(Float64(-0.5 * K)) * J) * 2.0), sinh(l), U)
end
code[J_, l_, K_, U_] := N[(N[(N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * 2.0), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]
\mathsf{fma}\left(\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot 2, \sinh \ell, U\right)
Derivation
  1. Initial program 86.5%

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

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

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

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

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

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

Alternative 2: 93.6% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;U + e^{\log \left(\frac{0.5}{\sinh \ell \cdot J}\right) \cdot -1}\\


\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)))) < -inf.0

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto U + J \cdot \frac{1}{\frac{2}{2 \cdot \left(\sinh \ell \cdot \color{blue}{2}\right)}} \]
      23. lower-*.f6481.2%

        \[\leadsto U + J \cdot \frac{1}{\frac{2}{2 \cdot \left(\sinh \ell \cdot \color{blue}{2}\right)}} \]
    6. Applied rewrites81.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto U + \frac{1}{\frac{\frac{\frac{2}{2}}{\sinh \ell \cdot 2}}{J}} \]
      10. metadata-evalN/A

        \[\leadsto U + \frac{1}{\frac{\frac{1}{\sinh \ell \cdot 2}}{J}} \]
      11. lift-*.f64N/A

        \[\leadsto U + \frac{1}{\frac{\frac{1}{\sinh \ell \cdot 2}}{J}} \]
      12. *-commutativeN/A

        \[\leadsto U + \frac{1}{\frac{\frac{1}{2 \cdot \sinh \ell}}{J}} \]
      13. associate-/r*N/A

        \[\leadsto U + \frac{1}{\frac{\frac{\frac{1}{2}}{\sinh \ell}}{J}} \]
      14. metadata-evalN/A

        \[\leadsto U + \frac{1}{\frac{\frac{\frac{1}{2}}{\sinh \ell}}{J}} \]
      15. lower-/.f6481.2%

        \[\leadsto U + \frac{1}{\frac{\frac{0.5}{\sinh \ell}}{J}} \]
    8. Applied rewrites81.2%

      \[\leadsto U + \frac{1}{\color{blue}{\frac{\frac{0.5}{\sinh \ell}}{J}}} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto U + \frac{1}{\color{blue}{\frac{\frac{\frac{1}{2}}{\sinh \ell}}{J}}} \]
      2. inv-powN/A

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

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

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

        \[\leadsto U + e^{\log \left(\frac{\frac{\frac{1}{2}}{\sinh \ell}}{J}\right) \cdot -1} \]
      6. lower-unsound-log.f6446.4%

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

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

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

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

        \[\leadsto U + e^{\log \left(\frac{\frac{1}{2}}{\sinh \ell \cdot J}\right) \cdot -1} \]
      11. lower-*.f6446.4%

        \[\leadsto U + e^{\log \left(\frac{0.5}{\sinh \ell \cdot J}\right) \cdot -1} \]
    10. Applied rewrites46.4%

      \[\leadsto U + e^{\log \left(\frac{0.5}{\sinh \ell \cdot J}\right) \cdot -1} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 87.0% accurate, 0.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;U + e^{\log \left(\frac{0.5}{\sinh \ell \cdot J}\right) \cdot -1}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < 4.99999999999999991e295

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999991e295 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U)

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto U + J \cdot \frac{1}{\frac{2}{2 \cdot \left(\sinh \ell \cdot \color{blue}{2}\right)}} \]
      23. lower-*.f6481.2%

        \[\leadsto U + J \cdot \frac{1}{\frac{2}{2 \cdot \left(\sinh \ell \cdot \color{blue}{2}\right)}} \]
    6. Applied rewrites81.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto U + \frac{1}{\frac{\frac{\frac{2}{2}}{\sinh \ell \cdot 2}}{J}} \]
      10. metadata-evalN/A

        \[\leadsto U + \frac{1}{\frac{\frac{1}{\sinh \ell \cdot 2}}{J}} \]
      11. lift-*.f64N/A

        \[\leadsto U + \frac{1}{\frac{\frac{1}{\sinh \ell \cdot 2}}{J}} \]
      12. *-commutativeN/A

        \[\leadsto U + \frac{1}{\frac{\frac{1}{2 \cdot \sinh \ell}}{J}} \]
      13. associate-/r*N/A

        \[\leadsto U + \frac{1}{\frac{\frac{\frac{1}{2}}{\sinh \ell}}{J}} \]
      14. metadata-evalN/A

        \[\leadsto U + \frac{1}{\frac{\frac{\frac{1}{2}}{\sinh \ell}}{J}} \]
      15. lower-/.f6481.2%

        \[\leadsto U + \frac{1}{\frac{\frac{0.5}{\sinh \ell}}{J}} \]
    8. Applied rewrites81.2%

      \[\leadsto U + \frac{1}{\color{blue}{\frac{\frac{0.5}{\sinh \ell}}{J}}} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto U + \frac{1}{\color{blue}{\frac{\frac{\frac{1}{2}}{\sinh \ell}}{J}}} \]
      2. inv-powN/A

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

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

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

        \[\leadsto U + e^{\log \left(\frac{\frac{\frac{1}{2}}{\sinh \ell}}{J}\right) \cdot -1} \]
      6. lower-unsound-log.f6446.4%

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

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

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

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

        \[\leadsto U + e^{\log \left(\frac{\frac{1}{2}}{\sinh \ell \cdot J}\right) \cdot -1} \]
      11. lower-*.f6446.4%

        \[\leadsto U + e^{\log \left(\frac{0.5}{\sinh \ell \cdot J}\right) \cdot -1} \]
    10. Applied rewrites46.4%

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

Alternative 4: 86.9% accurate, 1.0× speedup?

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

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


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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-0.25, J \cdot {K}^{2}, 2 \cdot J\right), \sinh \ell, U\right) \]
    6. Applied rewrites68.1%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sinh \ell, \mathsf{fma}\left({K}^{2} \cdot J, \frac{-1}{4}, 2 \cdot J\right), U\right) \]
      9. lower-*.f6468.1%

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

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

        \[\leadsto \mathsf{fma}\left(\sinh \ell, \mathsf{fma}\left(\left(K \cdot K\right) \cdot J, \frac{-1}{4}, 2 \cdot J\right), U\right) \]
      12. lower-*.f6468.1%

        \[\leadsto \mathsf{fma}\left(\sinh \ell, \mathsf{fma}\left(\left(K \cdot K\right) \cdot J, -0.25, 2 \cdot J\right), U\right) \]
      13. lift-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\sinh \ell, \mathsf{fma}\left(\left(K \cdot K\right) \cdot J, \frac{-1}{4}, J + J\right), U\right) \]
      15. lower-+.f6468.1%

        \[\leadsto \mathsf{fma}\left(\sinh \ell, \mathsf{fma}\left(\left(K \cdot K\right) \cdot J, -0.25, J + J\right), U\right) \]
    8. Applied rewrites68.1%

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

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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 86.3% accurate, 1.0× speedup?

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

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


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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(J \cdot \left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right)\right)\right) + U \]
      4. lower-pow.f6448.9%

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\left(\ell \cdot K\right) \cdot K\right)\right)\right) + U \]
    9. Applied rewrites50.4%

      \[\leadsto 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\left(\ell \cdot K\right) \cdot K\right)\right)\right) + U \]
    10. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

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

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

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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 86.0% accurate, 1.0× speedup?

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

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


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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(J \cdot \left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right)\right)\right) + U \]
      4. lower-pow.f6448.9%

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

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

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

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

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

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

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

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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 85.6% accurate, 1.1× speedup?

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

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


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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(J \cdot \left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right)\right)\right) + U \]
      4. lower-pow.f6448.9%

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\left(\ell \cdot K\right) \cdot K\right)\right)\right) + U \]
    9. Applied rewrites50.4%

      \[\leadsto 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\left(\ell \cdot K\right) \cdot K\right)\right)\right) + U \]
    10. Step-by-step derivation
      1. Applied rewrites50.4%

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

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

      1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 68.7% accurate, 2.8× speedup?

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

      1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

        if -8.2e8 < l

        1. Initial program 86.5%

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

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

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

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

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

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

            \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U \]
        4. Applied rewrites64.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-*.f6454.6%

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

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

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

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

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

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

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

      Alternative 9: 62.3% accurate, 1.2× speedup?

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

        1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

            \[\leadsto 2 \cdot \left(J \cdot \left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right)\right)\right) + U \]
          4. lower-pow.f6448.9%

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

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

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

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

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

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

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

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

            \[\leadsto 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\left(\ell \cdot K\right) \cdot K\right)\right)\right) + U \]
        9. Applied rewrites50.4%

          \[\leadsto 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\left(\ell \cdot K\right) \cdot K\right)\right)\right) + U \]
        10. Step-by-step derivation
          1. Applied rewrites50.4%

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

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

          1. Initial program 86.5%

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

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

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

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

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

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

              \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U \]
          4. Applied rewrites64.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-*.f6454.6%

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

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

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

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

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

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

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

        Alternative 10: 61.6% accurate, 1.2× speedup?

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

          1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

              \[\leadsto 2 \cdot \left(J \cdot \left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right)\right)\right) + U \]
            4. lower-pow.f6448.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 86.5%

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

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

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

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

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

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

              \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U \]
          4. Applied rewrites64.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-*.f6454.6%

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

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

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

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

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

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

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

        Alternative 11: 57.6% accurate, 4.3× speedup?

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

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

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

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

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

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

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

            \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U \]
        4. Applied rewrites64.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-*.f6454.6%

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

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

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

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

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

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

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

        Alternative 12: 54.6% 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.5%

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

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

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

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

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

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

            \[\leadsto 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U \]
        4. Applied rewrites64.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-*.f6454.6%

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

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

        Alternative 13: 37.7% 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.5%

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

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

          Reproduce

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