Maksimov and Kolovsky, Equation (4)

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

\\
\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(\sinh \ell \cdot 2\right), J, U\right)
\end{array}
Derivation
  1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.9% accurate, 0.4× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < -inf.0 or 2.00000000000000004e-169 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64))))

    1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot \sinh \ell\right) \cdot \left(J + J\right)} \]

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

      1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\cos \left(\frac{-1}{2} \cdot K\right) \cdot \left(\ell + \color{blue}{\ell}\right), J, U\right) \]
        4. lift-+.f6463.9

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

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

    Alternative 3: 99.3% accurate, 1.2× speedup?

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

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Applied rewrites99.9%

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

    Alternative 4: 93.8% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.99998:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right), J, 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.99998)
       (fma (* (cos (* -0.5 K)) (* (fma (* l l) 0.3333333333333333 2.0) l)) J U)
       (fma (+ J J) (sinh l) U)))
    double code(double J, double l, double K, double U) {
    	double tmp;
    	if (cos((K / 2.0)) <= 0.99998) {
    		tmp = fma((cos((-0.5 * K)) * (fma((l * l), 0.3333333333333333, 2.0) * l)), J, U);
    	} else {
    		tmp = fma((J + J), sinh(l), U);
    	}
    	return tmp;
    }
    
    function code(J, l, K, U)
    	tmp = 0.0
    	if (cos(Float64(K / 2.0)) <= 0.99998)
    		tmp = fma(Float64(cos(Float64(-0.5 * K)) * Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l)), J, U);
    	else
    		tmp = fma(Float64(J + J), sinh(l), U);
    	end
    	return tmp
    end
    
    code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.99998], N[(N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + 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.99998:\\
    \;\;\;\;\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right), J, 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.99997999999999998

      1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\cos \left(\frac{-1}{2} \cdot K\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, \frac{1}{3}, 2\right) \cdot \ell\right), J, U\right) \]
        9. lower-*.f6488.0

          \[\leadsto \mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right), J, U\right) \]
      6. Applied rewrites88.0%

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

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

      1. Initial program 86.1%

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

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

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
        5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

    Alternative 5: 88.0% accurate, 0.8× speedup?

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

      1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\cos \left(\frac{-1}{2} \cdot K\right) \cdot \left(\ell + \color{blue}{\ell}\right), J, U\right) \]
        4. lift-+.f6463.9

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

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

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

      1. Initial program 86.1%

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

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

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
        5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

    Alternative 6: 87.1% accurate, 0.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.25:\\ \;\;\;\;\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.25)
       (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.25) {
    		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.25)
    		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.25], 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.25:\\
    \;\;\;\;\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.25

      1. Initial program 86.1%

        \[\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}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
      3. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(K \cdot \frac{1}{2}\right)\right), U\right) \]
        14. mult-flipN/A

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

          \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{K}{2}\right)\right), U\right) \]
        16. mult-flipN/A

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

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

          \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
        19. distribute-lft-neg-inN/A

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

          \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
        21. metadata-eval63.9

          \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
      4. Applied rewrites63.9%

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

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

      1. Initial program 86.1%

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

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

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
        5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

    Alternative 7: 87.1% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

      1. Initial program 86.1%

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

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

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
        5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

    Alternative 8: 86.8% 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(K \cdot K, -0.125, 1\right) \cdot \sinh \ell, J + J, 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) (sinh l)) (+ J J) U)
       (fma (+ J J) (sinh l) U)))
    double code(double J, double l, double K, double U) {
    	double tmp;
    	if (cos((K / 2.0)) <= -0.05) {
    		tmp = fma((fma((K * K), -0.125, 1.0) * sinh(l)), (J + J), U);
    	} else {
    		tmp = fma((J + J), sinh(l), U);
    	}
    	return tmp;
    }
    
    function code(J, l, K, U)
    	tmp = 0.0
    	if (cos(Float64(K / 2.0)) <= -0.05)
    		tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * sinh(l)), Float64(J + J), U);
    	else
    		tmp = fma(Float64(J + J), sinh(l), U);
    	end
    	return tmp
    end
    
    code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(J + J), $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(K \cdot K, -0.125, 1\right) \cdot \sinh \ell, J + J, 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.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right) \cdot \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot J\right)} + U \]
        10. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 86.1%

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

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

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
        5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

    Alternative 9: 86.8% 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(\left(K \cdot K\right) \cdot -0.125\right) \cdot \left(\sinh \ell \cdot 2\right), J, 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 (* (* (* K K) -0.125) (* (sinh l) 2.0)) J U)
       (fma (+ J J) (sinh l) U)))
    double code(double J, double l, double K, double U) {
    	double tmp;
    	if (cos((K / 2.0)) <= -0.05) {
    		tmp = fma((((K * K) * -0.125) * (sinh(l) * 2.0)), J, U);
    	} else {
    		tmp = fma((J + J), sinh(l), U);
    	}
    	return tmp;
    }
    
    function code(J, l, K, U)
    	tmp = 0.0
    	if (cos(Float64(K / 2.0)) <= -0.05)
    		tmp = fma(Float64(Float64(Float64(K * K) * -0.125) * Float64(sinh(l) * 2.0)), J, U);
    	else
    		tmp = fma(Float64(J + J), sinh(l), U);
    	end
    	return tmp
    end
    
    code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + 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(\left(K \cdot K\right) \cdot -0.125\right) \cdot \left(\sinh \ell \cdot 2\right), J, 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.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right) \cdot \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot J\right)} + U \]
        10. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

      1. Initial program 86.1%

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

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

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
        5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

    Alternative 10: 86.1% 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(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J, 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)
        (* (* (fma (* l l) 0.3333333333333333 2.0) l) J)
        U)
       (fma (+ J J) (sinh l) U)))
    double code(double J, double l, double K, double U) {
    	double tmp;
    	if (cos((K / 2.0)) <= -0.05) {
    		tmp = fma(fma(-0.125, (K * K), 1.0), ((fma((l * l), 0.3333333333333333, 2.0) * l) * J), U);
    	} else {
    		tmp = fma((J + J), sinh(l), U);
    	}
    	return tmp;
    }
    
    function code(J, l, K, U)
    	tmp = 0.0
    	if (cos(Float64(K / 2.0)) <= -0.05)
    		tmp = fma(fma(-0.125, Float64(K * K), 1.0), Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J), U);
    	else
    		tmp = fma(Float64(J + J), sinh(l), U);
    	end
    	return tmp
    end
    
    code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $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(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J, 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.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\cos \left(\frac{-1}{2} \cdot K\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, \frac{1}{3}, 2\right) \cdot \ell\right), J, U\right) \]
        9. lower-*.f6488.0

          \[\leadsto \mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right), J, U\right) \]
      6. Applied rewrites88.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-0.125, K \cdot \color{blue}{K}, 1\right), \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J, U\right) \]
      11. Applied rewrites61.3%

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

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

      1. Initial program 86.1%

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

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

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
        5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

    Alternative 11: 84.0% accurate, 1.1× speedup?

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

        \[\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}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
      3. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(K \cdot \frac{1}{2}\right)\right), U\right) \]
        14. mult-flipN/A

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

          \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{K}{2}\right)\right), U\right) \]
        16. mult-flipN/A

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

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

          \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
        19. distribute-lft-neg-inN/A

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

          \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
        21. metadata-eval63.9

          \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
      4. Applied rewrites63.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 86.1%

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

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

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
        5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

    Alternative 12: 80.8% 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\\ t_1 := \left(J + J\right) \cdot \sinh \ell\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 10^{+304}:\\ \;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (J l K U)
     :precision binary64
     (let* ((t_0 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
            (t_1 (* (+ J J) (sinh l))))
       (if (<= t_0 (- INFINITY)) t_1 (if (<= t_0 1e+304) (fma (+ J J) l U) t_1))))
    double code(double J, double l, double K, double U) {
    	double t_0 = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
    	double t_1 = (J + J) * sinh(l);
    	double tmp;
    	if (t_0 <= -((double) INFINITY)) {
    		tmp = t_1;
    	} else if (t_0 <= 1e+304) {
    		tmp = fma((J + J), l, U);
    	} else {
    		tmp = t_1;
    	}
    	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)
    	t_1 = Float64(Float64(J + J) * sinh(l))
    	tmp = 0.0
    	if (t_0 <= Float64(-Inf))
    		tmp = t_1;
    	elseif (t_0 <= 1e+304)
    		tmp = fma(Float64(J + J), l, U);
    	else
    		tmp = t_1;
    	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]}, Block[{t$95$1 = N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 1e+304], N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision], t$95$1]]]]
    
    \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\\
    t_1 := \left(J + J\right) \cdot \sinh \ell\\
    \mathbf{if}\;t\_0 \leq -\infty:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;t\_0 \leq 10^{+304}:\\
    \;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < -inf.0 or 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.1%

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

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

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
        5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto J \cdot \color{blue}{\left(e^{\ell} - \frac{1}{e^{\ell}}\right)} \]
      6. Step-by-step derivation
        1. rec-expN/A

          \[\leadsto J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \]
        2. mul-1-negN/A

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) \]
        3. mul-1-negN/A

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

          \[\leadsto J \cdot \left(2 \cdot \sinh \ell\right) \]
        5. associate-*l*N/A

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

          \[\leadsto \left(2 \cdot J\right) \cdot \sinh \ell \]
        7. lower-*.f64N/A

          \[\leadsto \left(2 \cdot J\right) \cdot \sinh \ell \]
        8. count-2-revN/A

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

          \[\leadsto \left(J + J\right) \cdot \sinh \ell \]
        10. lift-sinh.f6446.7

          \[\leadsto \left(J + J\right) \cdot \sinh \ell \]
      7. Applied rewrites46.7%

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

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

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

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

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

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

          \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
        5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

      Alternative 13: 60.1% accurate, 2.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\frac{J + J}{U} \cdot \ell, U, U\right)\\ \mathbf{if}\;\ell \leq -3.4 \cdot 10^{+106}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq -850:\\ \;\;\;\;\left(\ell \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right) \cdot J\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+33}:\\ \;\;\;\;\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 (fma (* (/ (+ J J) U) l) U U)))
         (if (<= l -3.4e+106)
           t_0
           (if (<= l -850.0)
             (* (* l (fma -0.25 (* K K) 2.0)) J)
             (if (<= l 5e+33) (fma (+ J J) l U) t_0)))))
      double code(double J, double l, double K, double U) {
      	double t_0 = fma((((J + J) / U) * l), U, U);
      	double tmp;
      	if (l <= -3.4e+106) {
      		tmp = t_0;
      	} else if (l <= -850.0) {
      		tmp = (l * fma(-0.25, (K * K), 2.0)) * J;
      	} else if (l <= 5e+33) {
      		tmp = fma((J + J), l, U);
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(J, l, K, U)
      	t_0 = fma(Float64(Float64(Float64(J + J) / U) * l), U, U)
      	tmp = 0.0
      	if (l <= -3.4e+106)
      		tmp = t_0;
      	elseif (l <= -850.0)
      		tmp = Float64(Float64(l * fma(-0.25, Float64(K * K), 2.0)) * J);
      	elseif (l <= 5e+33)
      		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[(N[(N[(N[(J + J), $MachinePrecision] / U), $MachinePrecision] * l), $MachinePrecision] * U + U), $MachinePrecision]}, If[LessEqual[l, -3.4e+106], t$95$0, If[LessEqual[l, -850.0], N[(N[(l * N[(-0.25 * N[(K * K), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision], If[LessEqual[l, 5e+33], N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision], t$95$0]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \mathsf{fma}\left(\frac{J + J}{U} \cdot \ell, U, U\right)\\
      \mathbf{if}\;\ell \leq -3.4 \cdot 10^{+106}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;\ell \leq -850:\\
      \;\;\;\;\left(\ell \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right) \cdot J\\
      
      \mathbf{elif}\;\ell \leq 5 \cdot 10^{+33}:\\
      \;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if l < -3.39999999999999994e106 or 4.99999999999999973e33 < l

        1. Initial program 86.1%

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

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

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

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

            \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
          5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{J \cdot \left(2 \cdot \sinh \ell\right)}{U}, U, U\right) \]
          10. associate-*l*N/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{\left(J + J\right) \cdot \sinh \ell}{U}, U, U\right) \]
          15. lift-sinh.f6479.9

            \[\leadsto \mathsf{fma}\left(\frac{\left(J + J\right) \cdot \sinh \ell}{U}, U, U\right) \]
        7. Applied rewrites79.9%

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

          \[\leadsto \mathsf{fma}\left(2 \cdot \frac{J \cdot \ell}{U}, U, U\right) \]
        9. Step-by-step derivation
          1. associate-*r/N/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\left(2 \cdot \frac{J}{U}\right) \cdot \ell, U, U\right) \]
          6. associate-*r/N/A

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

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

            \[\leadsto \mathsf{fma}\left(\frac{J + J}{U} \cdot \ell, U, U\right) \]
          9. lift-+.f6455.1

            \[\leadsto \mathsf{fma}\left(\frac{J + J}{U} \cdot \ell, U, U\right) \]
        10. Applied rewrites55.1%

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

        if -3.39999999999999994e106 < l < -850

        1. Initial program 86.1%

          \[\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}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
        3. Step-by-step derivation
          1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(K \cdot \frac{1}{2}\right)\right), U\right) \]
          14. mult-flipN/A

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

            \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{K}{2}\right)\right), U\right) \]
          16. mult-flipN/A

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

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

            \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
          19. distribute-lft-neg-inN/A

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

            \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
          21. metadata-eval63.9

            \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
        4. Applied rewrites63.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J, \frac{-1}{4}, \mathsf{fma}\left(\ell + \ell, J, U\right)\right) \]
          16. lift-+.f6444.3

            \[\leadsto \mathsf{fma}\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J, -0.25, \mathsf{fma}\left(\ell + \ell, J, U\right)\right) \]
        7. Applied rewrites44.3%

          \[\leadsto \mathsf{fma}\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J, \color{blue}{-0.25}, \mathsf{fma}\left(\ell + \ell, J, U\right)\right) \]
        8. Taylor expanded in J around inf

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

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

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

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

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

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

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

            \[\leadsto \left(\ell \cdot \mathsf{fma}\left(\frac{-1}{4}, K \cdot K, 2\right)\right) \cdot J \]
          8. lift-*.f6425.2

            \[\leadsto \left(\ell \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right) \cdot J \]
        10. Applied rewrites25.2%

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

        if -850 < l < 4.99999999999999973e33

        1. Initial program 86.1%

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

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

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

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

            \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
          5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

        Alternative 14: 58.9% accurate, 3.1× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\ell \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right) \cdot J\\ \mathbf{if}\;\ell \leq -850:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+22}:\\ \;\;\;\;\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 (* (* l (fma -0.25 (* K K) 2.0)) J)))
           (if (<= l -850.0) t_0 (if (<= l 1.1e+22) (fma (+ J J) l U) t_0))))
        double code(double J, double l, double K, double U) {
        	double t_0 = (l * fma(-0.25, (K * K), 2.0)) * J;
        	double tmp;
        	if (l <= -850.0) {
        		tmp = t_0;
        	} else if (l <= 1.1e+22) {
        		tmp = fma((J + J), l, U);
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        function code(J, l, K, U)
        	t_0 = Float64(Float64(l * fma(-0.25, Float64(K * K), 2.0)) * J)
        	tmp = 0.0
        	if (l <= -850.0)
        		tmp = t_0;
        	elseif (l <= 1.1e+22)
        		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[(N[(l * N[(-0.25 * N[(K * K), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[l, -850.0], t$95$0, If[LessEqual[l, 1.1e+22], N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \left(\ell \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right) \cdot J\\
        \mathbf{if}\;\ell \leq -850:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+22}:\\
        \;\;\;\;\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 < -850 or 1.1e22 < l

          1. Initial program 86.1%

            \[\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}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
          3. Step-by-step derivation
            1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(K \cdot \frac{1}{2}\right)\right), U\right) \]
            14. mult-flipN/A

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

              \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{K}{2}\right)\right), U\right) \]
            16. mult-flipN/A

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

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

              \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right), U\right) \]
            19. distribute-lft-neg-inN/A

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

              \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right), U\right) \]
            21. metadata-eval63.9

              \[\leadsto \mathsf{fma}\left(\left(\ell + \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right) \]
          4. Applied rewrites63.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J, \frac{-1}{4}, \mathsf{fma}\left(\ell + \ell, J, U\right)\right) \]
            16. lift-+.f6444.3

              \[\leadsto \mathsf{fma}\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J, -0.25, \mathsf{fma}\left(\ell + \ell, J, U\right)\right) \]
          7. Applied rewrites44.3%

            \[\leadsto \mathsf{fma}\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J, \color{blue}{-0.25}, \mathsf{fma}\left(\ell + \ell, J, U\right)\right) \]
          8. Taylor expanded in J around inf

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

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

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

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

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

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

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

              \[\leadsto \left(\ell \cdot \mathsf{fma}\left(\frac{-1}{4}, K \cdot K, 2\right)\right) \cdot J \]
            8. lift-*.f6425.2

              \[\leadsto \left(\ell \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right) \cdot J \]
          10. Applied rewrites25.2%

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

          if -850 < l < 1.1e22

          1. Initial program 86.1%

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

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

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

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

              \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
            5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

          Alternative 15: 54.1% 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.1%

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

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

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

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

              \[\leadsto J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right) + U \]
            5. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

            Alternative 16: 37.0% 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.1%

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

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

              Reproduce

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