Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.5% → 99.9%
Time: 4.1s
Alternatives: 15
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
	return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(j, l, k, u)
use fmin_fmax_functions
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
	return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U):
	return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U)
	return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U)
end
function tmp = code(J, l, K, U)
	tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}

\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 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?

\[\begin{array}{l} \\ \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
	return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(j, l, k, u)
use fmin_fmax_functions
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
	return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U):
	return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U)
	return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U)
end
function tmp = code(J, l, K, U)
	tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}

\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}

Alternative 1: 99.9% accurate, 1.2× speedup?

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

\\
\mathsf{fma}\left(\cos \left(K \cdot -0.5\right) \cdot J, \sinh \ell \cdot 2, U\right)
\end{array}
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. lower-fma.f64N/A

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

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

Alternative 2: 87.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(0.5 \cdot K\right) \cdot J, \ell + \ell, U\right)\\

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


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

    1. Initial program 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.8

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

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

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

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

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

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

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

    if -0.050000000000000003 < (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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 87.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(0.5 \cdot K\right), U\right)\\

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


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

    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.8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.050000000000000003 < (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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 87.3% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 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. lower-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.050000000000000003 < (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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 87.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 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. lower-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.050000000000000003 < (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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 85.7% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 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.8

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

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

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

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

        \[\leadsto \left(2 \cdot J\right) \cdot \color{blue}{\left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right)\right)} + U \]
      5. count-2-revN/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-+.f6449.7

        \[\leadsto \left(J + J\right) \cdot \left(\color{blue}{\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. lift-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \left(J + J\right) \cdot \left(\ell + \left(\left(K \cdot K\right) \cdot \frac{-1}{8}\right) \cdot \ell\right) + U \]
      15. distribute-rgt1-inN/A

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

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

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

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

    if -0.050000000000000003 < (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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 70.4% accurate, 2.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.4 \cdot 10^{-35}:\\
\;\;\;\;U + J \cdot \left(1 - e^{-\ell}\right)\\

\mathbf{elif}\;\ell \leq 2.7 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\

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


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

    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.f6473.9

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

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

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

      if -1.4e-35 < l < 2.6999999999999998e-12

      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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 2.6999999999999998e-12 < 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.8

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

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

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

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

            \[\leadsto \left(2 \cdot J\right) \cdot \color{blue}{\left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right)\right)} + U \]
          5. count-2-revN/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-+.f6449.7

            \[\leadsto \left(J + J\right) \cdot \left(\color{blue}{\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. lift-*.f64N/A

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

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

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

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

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

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

            \[\leadsto \left(J + J\right) \cdot \left(\ell + \left(\left(K \cdot K\right) \cdot \frac{-1}{8}\right) \cdot \ell\right) + U \]
          15. distribute-rgt1-inN/A

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

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

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

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

      Alternative 8: 62.9% accurate, 0.4× speedup?

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

        1. Initial program 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.8

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

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

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

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

            \[\leadsto \left(2 \cdot J\right) \cdot \color{blue}{\left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right)\right)} + U \]
          5. count-2-revN/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-+.f6449.7

            \[\leadsto \left(J + J\right) \cdot \left(\color{blue}{\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. lift-*.f64N/A

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

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

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

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

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

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

            \[\leadsto \left(J + J\right) \cdot \left(\ell + \left(\left(K \cdot K\right) \cdot \frac{-1}{8}\right) \cdot \ell\right) + U \]
          15. distribute-rgt1-inN/A

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

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

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

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

        if -inf.0 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < 9.9999999999999994e303

        1. Initial program 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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \]
          11. Taylor expanded in U around inf

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

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

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

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

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

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

        Alternative 9: 61.9% accurate, 0.4× speedup?

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

          1. Initial program 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. lower-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -inf.0 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < 9.9999999999999994e303

            1. Initial program 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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              1. Initial program 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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \]
              11. Taylor expanded in U around inf

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

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

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

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

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

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

            Alternative 10: 61.2% accurate, 2.6× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := J \cdot \left(U \cdot \mathsf{fma}\left(2, \frac{\ell}{U}, \frac{1}{J}\right)\right)\\ \mathbf{if}\;\ell \leq -9.5 \cdot 10^{+38}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 900:\\ \;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
            (FPCore (J l K U)
             :precision binary64
             (let* ((t_0 (* J (* U (fma 2.0 (/ l U) (/ 1.0 J))))))
               (if (<= l -9.5e+38) t_0 (if (<= l 900.0) (fma (+ J J) l U) t_0))))
            double code(double J, double l, double K, double U) {
            	double t_0 = J * (U * fma(2.0, (l / U), (1.0 / J)));
            	double tmp;
            	if (l <= -9.5e+38) {
            		tmp = t_0;
            	} else if (l <= 900.0) {
            		tmp = fma((J + J), l, U);
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            function code(J, l, K, U)
            	t_0 = Float64(J * Float64(U * fma(2.0, Float64(l / U), Float64(1.0 / J))))
            	tmp = 0.0
            	if (l <= -9.5e+38)
            		tmp = t_0;
            	elseif (l <= 900.0)
            		tmp = fma(Float64(J + J), l, U);
            	else
            		tmp = t_0;
            	end
            	return tmp
            end
            
            code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(U * N[(2.0 * N[(l / U), $MachinePrecision] + N[(1.0 / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -9.5e+38], t$95$0, If[LessEqual[l, 900.0], N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision], t$95$0]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := J \cdot \left(U \cdot \mathsf{fma}\left(2, \frac{\ell}{U}, \frac{1}{J}\right)\right)\\
            \mathbf{if}\;\ell \leq -9.5 \cdot 10^{+38}:\\
            \;\;\;\;t\_0\\
            
            \mathbf{elif}\;\ell \leq 900:\\
            \;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_0\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if l < -9.4999999999999995e38 or 900 < 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 K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \]
              11. Taylor expanded in U around inf

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

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

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

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

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

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

              if -9.4999999999999995e38 < l < 900

              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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 11: 56.2% accurate, 1.7× speedup?

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

                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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  if 9.99999999999999999e-15 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 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 K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                Alternative 12: 56.1% accurate, 1.6× speedup?

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

                  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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if 1.99999999999999991e-6 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 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 K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \]
                    11. Taylor expanded in l around inf

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

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

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

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

                        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \frac{U}{J \cdot \ell}\right)\right) \]
                    13. Applied rewrites39.8%

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

                  Alternative 13: 54.7% accurate, 7.9× speedup?

                  \[\begin{array}{l} \\ \mathsf{fma}\left(J + J, \ell, U\right) \end{array} \]
                  (FPCore (J l K U) :precision binary64 (fma (+ J J) l U))
                  double code(double J, double l, double K, double U) {
                  	return fma((J + J), l, U);
                  }
                  
                  function code(J, l, K, U)
                  	return fma(Float64(J + J), l, U)
                  end
                  
                  code[J_, l_, K_, U_] := N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  \mathsf{fma}\left(J + J, \ell, U\right)
                  \end{array}
                  
                  Derivation
                  1. Initial program 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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 14: 44.0% accurate, 4.7× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := J \cdot \left(2 \cdot \ell\right)\\ \mathbf{if}\;J \leq -4.55 \cdot 10^{+198}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;J \leq 5.4 \cdot 10^{+135}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                    (FPCore (J l K U)
                     :precision binary64
                     (let* ((t_0 (* J (* 2.0 l))))
                       (if (<= J -4.55e+198) t_0 (if (<= J 5.4e+135) U t_0))))
                    double code(double J, double l, double K, double U) {
                    	double t_0 = J * (2.0 * l);
                    	double tmp;
                    	if (J <= -4.55e+198) {
                    		tmp = t_0;
                    	} else if (J <= 5.4e+135) {
                    		tmp = U;
                    	} else {
                    		tmp = t_0;
                    	}
                    	return tmp;
                    }
                    
                    module fmin_fmax_functions
                        implicit none
                        private
                        public fmax
                        public fmin
                    
                        interface fmax
                            module procedure fmax88
                            module procedure fmax44
                            module procedure fmax84
                            module procedure fmax48
                        end interface
                        interface fmin
                            module procedure fmin88
                            module procedure fmin44
                            module procedure fmin84
                            module procedure fmin48
                        end interface
                    contains
                        real(8) function fmax88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmax44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmax84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmax48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                        end function
                        real(8) function fmin88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmin44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmin84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmin48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                        end function
                    end module
                    
                    real(8) function code(j, l, k, u)
                    use fmin_fmax_functions
                        real(8), intent (in) :: j
                        real(8), intent (in) :: l
                        real(8), intent (in) :: k
                        real(8), intent (in) :: u
                        real(8) :: t_0
                        real(8) :: tmp
                        t_0 = j * (2.0d0 * l)
                        if (j <= (-4.55d+198)) then
                            tmp = t_0
                        else if (j <= 5.4d+135) then
                            tmp = u
                        else
                            tmp = t_0
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double J, double l, double K, double U) {
                    	double t_0 = J * (2.0 * l);
                    	double tmp;
                    	if (J <= -4.55e+198) {
                    		tmp = t_0;
                    	} else if (J <= 5.4e+135) {
                    		tmp = U;
                    	} else {
                    		tmp = t_0;
                    	}
                    	return tmp;
                    }
                    
                    def code(J, l, K, U):
                    	t_0 = J * (2.0 * l)
                    	tmp = 0
                    	if J <= -4.55e+198:
                    		tmp = t_0
                    	elif J <= 5.4e+135:
                    		tmp = U
                    	else:
                    		tmp = t_0
                    	return tmp
                    
                    function code(J, l, K, U)
                    	t_0 = Float64(J * Float64(2.0 * l))
                    	tmp = 0.0
                    	if (J <= -4.55e+198)
                    		tmp = t_0;
                    	elseif (J <= 5.4e+135)
                    		tmp = U;
                    	else
                    		tmp = t_0;
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(J, l, K, U)
                    	t_0 = J * (2.0 * l);
                    	tmp = 0.0;
                    	if (J <= -4.55e+198)
                    		tmp = t_0;
                    	elseif (J <= 5.4e+135)
                    		tmp = U;
                    	else
                    		tmp = t_0;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -4.55e+198], t$95$0, If[LessEqual[J, 5.4e+135], U, t$95$0]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    t_0 := J \cdot \left(2 \cdot \ell\right)\\
                    \mathbf{if}\;J \leq -4.55 \cdot 10^{+198}:\\
                    \;\;\;\;t\_0\\
                    
                    \mathbf{elif}\;J \leq 5.4 \cdot 10^{+135}:\\
                    \;\;\;\;U\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;t\_0\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if J < -4.5499999999999998e198 or 5.3999999999999997e135 < J

                      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.f6473.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto J \cdot \mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \]
                      11. Taylor expanded in J around inf

                        \[\leadsto J \cdot \left(2 \cdot \ell\right) \]
                      12. Step-by-step derivation
                        1. lower-*.f6419.6

                          \[\leadsto J \cdot \left(2 \cdot \ell\right) \]
                      13. Applied rewrites19.6%

                        \[\leadsto J \cdot \left(2 \cdot \ell\right) \]

                      if -4.5499999999999998e198 < J < 5.3999999999999997e135

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

                          \[\leadsto \color{blue}{U} \]
                      4. Recombined 2 regimes into one program.
                      5. Add Preprocessing

                      Alternative 15: 37.8% accurate, 68.7× speedup?

                      \[\begin{array}{l} \\ U \end{array} \]
                      (FPCore (J l K U) :precision binary64 U)
                      double code(double J, double l, double K, double U) {
                      	return U;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(j, l, k, u)
                      use fmin_fmax_functions
                          real(8), intent (in) :: j
                          real(8), intent (in) :: l
                          real(8), intent (in) :: k
                          real(8), intent (in) :: u
                          code = u
                      end function
                      
                      public static double code(double J, double l, double K, double U) {
                      	return U;
                      }
                      
                      def code(J, l, K, U):
                      	return U
                      
                      function code(J, l, K, U)
                      	return U
                      end
                      
                      function tmp = code(J, l, K, U)
                      	tmp = U;
                      end
                      
                      code[J_, l_, K_, U_] := U
                      
                      \begin{array}{l}
                      
                      \\
                      U
                      \end{array}
                      
                      Derivation
                      1. Initial program 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.8%

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

                        Reproduce

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