Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.3% → 99.9%
Time: 8.9s
Alternatives: 24
Speedup: 2.1×

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}

Sampling outcomes in binary64 precision:

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 24 alternatives:

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

Initial Program: 86.3% accurate, 1.0× speedup?

\[\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, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{-2}\right)\\ \mathsf{fma}\left(\frac{{t\_0}^{2} \cdot \left(\sinh \ell \cdot 2\right)}{t\_0}, J, U\right) \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K -2.0))))
   (fma (/ (* (pow t_0 2.0) (* (sinh l) 2.0)) t_0) J U)))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / -2.0));
	return fma(((pow(t_0, 2.0) * (sinh(l) * 2.0)) / t_0), J, U);
}
function code(J, l, K, U)
	t_0 = cos(Float64(K / -2.0))
	return fma(Float64(Float64((t_0 ^ 2.0) * Float64(sinh(l) * 2.0)) / t_0), J, U)
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / -2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{-2}\right)\\
\mathsf{fma}\left(\frac{{t\_0}^{2} \cdot \left(\sinh \ell \cdot 2\right)}{t\_0}, J, U\right)
\end{array}
\end{array}
Derivation
  1. Initial program 84.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\sin \left(\frac{K}{2}\right), \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos \left(\frac{K}{2}\right) \cdot \sin \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2}\right)}\right) \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
    18. lower-PI.f6499.9

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\sin \left(\frac{K}{2}\right), \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos \left(\frac{K}{2}\right) \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
  7. Applied rewrites100.0%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\left(0 - {\cos \left(\frac{K}{-2}\right)}^{2}\right) \cdot \left(\sinh \ell \cdot 2\right)}{-\cos \left(\frac{K}{-2}\right)}}, J, U\right) \]
  8. Final simplification100.0%

    \[\leadsto \mathsf{fma}\left(\frac{{\cos \left(\frac{K}{-2}\right)}^{2} \cdot \left(\sinh \ell \cdot 2\right)}{\cos \left(\frac{K}{-2}\right)}, J, U\right) \]
  9. Add Preprocessing

Alternative 2: 87.5% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \sinh \ell \cdot 2\\
\mathbf{if}\;t\_0 \leq -0.92:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right)\\

\mathbf{elif}\;t\_0 \leq -0.001:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot t\_1, J, U\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot t\_1, J, U\right)\\


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

    1. Initial program 74.3%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Add Preprocessing
    3. 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)} \]
    4. Step-by-step derivation
      1. Applied rewrites80.0%

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

      if -0.92000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3

      1. Initial program 90.9%

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

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

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

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

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

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

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

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

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

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

        if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

        1. Initial program 84.2%

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
        6. Step-by-step derivation
          1. Applied rewrites96.2%

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

        Alternative 3: 87.3% accurate, 0.9× speedup?

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

          1. Initial program 74.3%

            \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
          2. Add Preprocessing
          3. 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)} \]
          4. Step-by-step derivation
            1. Applied rewrites80.0%

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

            if -0.92000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3

            1. Initial program 90.9%

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right) \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}, J, U\right) \]
              3. Step-by-step derivation
                1. Applied rewrites70.7%

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520} \cdot {\ell}^{2}, \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites70.7%

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

                  if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                  1. Initial program 84.2%

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                  6. Step-by-step derivation
                    1. Applied rewrites96.2%

                      \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                  7. Recombined 3 regimes into one program.
                  8. Final simplification90.7%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.92:\\ \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968 \cdot \left(\ell \cdot \ell\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\ \end{array} \]
                  9. Add Preprocessing

                  Alternative 4: 96.6% accurate, 1.2× speedup?

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

                    1. Initial program 85.7%

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

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

                        \[\leadsto \left(J \cdot \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]

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

                      1. Initial program 83.8%

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

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

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

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

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                      6. Step-by-step derivation
                        1. Applied rewrites98.8%

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

                      Alternative 5: 95.8% accurate, 1.2× speedup?

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

                        1. Initial program 85.7%

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

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

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

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

                          1. Initial program 83.8%

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

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

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

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

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

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

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

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

                            \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                          6. Step-by-step derivation
                            1. Applied rewrites98.8%

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

                          Alternative 6: 93.6% accurate, 1.3× speedup?

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

                            1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

                              1. Initial program 84.1%

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

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

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

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

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                              6. Step-by-step derivation
                                1. Applied rewrites97.6%

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

                              Alternative 7: 92.4% accurate, 1.3× speedup?

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

                                1. Initial program 85.6%

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

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

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

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

                                  1. Initial program 84.1%

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

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

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

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

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

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

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

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

                                    \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                  6. Step-by-step derivation
                                    1. Applied rewrites97.6%

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

                                  Alternative 8: 86.9% accurate, 1.4× speedup?

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

                                    1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

                                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right) \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}, J, U\right) \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites64.2%

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

                                          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520} \cdot {\ell}^{2}, \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right) \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites64.2%

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

                                          if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                          1. Initial program 84.2%

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

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

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

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

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

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

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

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

                                            \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                          6. Step-by-step derivation
                                            1. Applied rewrites96.2%

                                              \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                          7. Recombined 2 regimes into one program.
                                          8. Final simplification88.4%

                                            \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968 \cdot \left(\ell \cdot \ell\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\ \end{array} \]
                                          9. Add Preprocessing

                                          Alternative 9: 99.9% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

                                          Alternative 10: 83.3% accurate, 1.9× speedup?

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

                                            1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right) \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}, J, U\right) \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites64.2%

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

                                                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, \frac{-1}{8}, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520} \cdot {\ell}^{2}, \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right) \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites64.2%

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

                                                  if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                  1. Initial program 84.2%

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

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

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

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

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

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

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

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

                                                    \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                                  6. Step-by-step derivation
                                                    1. Applied rewrites96.2%

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

                                                      \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}, J, U\right) \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites90.4%

                                                        \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)}, J, U\right) \]
                                                    4. Recombined 2 regimes into one program.
                                                    5. Final simplification84.0%

                                                      \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968 \cdot \left(\ell \cdot \ell\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \end{array} \]
                                                    6. Add Preprocessing

                                                    Alternative 11: 83.1% accurate, 2.0× speedup?

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

                                                      1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

                                                          if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                          1. Initial program 84.2%

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

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

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

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

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

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

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

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

                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                                          6. Step-by-step derivation
                                                            1. Applied rewrites96.2%

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

                                                              \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}, J, U\right) \]
                                                            3. Step-by-step derivation
                                                              1. Applied rewrites90.4%

                                                                \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)}, J, U\right) \]
                                                            4. Recombined 2 regimes into one program.
                                                            5. Final simplification84.0%

                                                              \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \end{array} \]
                                                            6. Add Preprocessing

                                                            Alternative 12: 82.5% accurate, 2.0× speedup?

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

                                                              1. Initial program 85.8%

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

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

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

                                                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right) + J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                3. Step-by-step derivation
                                                                  1. Applied rewrites19.2%

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

                                                                    \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \ell, U\right) \]
                                                                  3. Step-by-step derivation
                                                                    1. Applied rewrites61.1%

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

                                                                    if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                                    1. Initial program 84.2%

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

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

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

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

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

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

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

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

                                                                      \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                                                    6. Step-by-step derivation
                                                                      1. Applied rewrites96.2%

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

                                                                        \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}, J, U\right) \]
                                                                      3. Step-by-step derivation
                                                                        1. Applied rewrites90.4%

                                                                          \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)}, J, U\right) \]
                                                                      4. Recombined 2 regimes into one program.
                                                                      5. Final simplification83.3%

                                                                        \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\ \;\;\;\;\mathsf{fma}\left(\left(-0.125 \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \end{array} \]
                                                                      6. Add Preprocessing

                                                                      Alternative 13: 92.9% accurate, 2.1× speedup?

                                                                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(0.5 \cdot K\right)\\ t_1 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot t\_0\\ \mathbf{if}\;\ell \leq -1.02 \cdot 10^{+117}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+33}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 0.0048:\\ \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot t\_0, J, U\right)\\ \mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+98}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                                                                      (FPCore (J l K U)
                                                                       :precision binary64
                                                                       (let* ((t_0 (cos (* 0.5 K)))
                                                                              (t_1 (* (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) t_0)))
                                                                         (if (<= l -1.02e+117)
                                                                           t_1
                                                                           (if (<= l -2.2e+33)
                                                                             (fma
                                                                              (*
                                                                               1.0
                                                                               (*
                                                                                (fma
                                                                                 (fma
                                                                                  (fma 0.0003968253968253968 (* l l) 0.016666666666666666)
                                                                                  (* l l)
                                                                                  0.3333333333333333)
                                                                                 (* l l)
                                                                                 2.0)
                                                                                l))
                                                                              J
                                                                              U)
                                                                             (if (<= l 0.0048)
                                                                               (fma (* (* 2.0 l) t_0) J U)
                                                                               (if (<= l 8.2e+98) (fma (* 1.0 (* (sinh l) 2.0)) J U) t_1))))))
                                                                      double code(double J, double l, double K, double U) {
                                                                      	double t_0 = cos((0.5 * K));
                                                                      	double t_1 = ((fma((l * l), 0.3333333333333333, 2.0) * l) * J) * t_0;
                                                                      	double tmp;
                                                                      	if (l <= -1.02e+117) {
                                                                      		tmp = t_1;
                                                                      	} else if (l <= -2.2e+33) {
                                                                      		tmp = fma((1.0 * (fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)), J, U);
                                                                      	} else if (l <= 0.0048) {
                                                                      		tmp = fma(((2.0 * l) * t_0), J, U);
                                                                      	} else if (l <= 8.2e+98) {
                                                                      		tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
                                                                      	} else {
                                                                      		tmp = t_1;
                                                                      	}
                                                                      	return tmp;
                                                                      }
                                                                      
                                                                      function code(J, l, K, U)
                                                                      	t_0 = cos(Float64(0.5 * K))
                                                                      	t_1 = Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * t_0)
                                                                      	tmp = 0.0
                                                                      	if (l <= -1.02e+117)
                                                                      		tmp = t_1;
                                                                      	elseif (l <= -2.2e+33)
                                                                      		tmp = fma(Float64(1.0 * Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)), J, U);
                                                                      	elseif (l <= 0.0048)
                                                                      		tmp = fma(Float64(Float64(2.0 * l) * t_0), J, U);
                                                                      	elseif (l <= 8.2e+98)
                                                                      		tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U);
                                                                      	else
                                                                      		tmp = t_1;
                                                                      	end
                                                                      	return tmp
                                                                      end
                                                                      
                                                                      code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[l, -1.02e+117], t$95$1, If[LessEqual[l, -2.2e+33], N[(N[(1.0 * N[(N[(N[(N[(0.0003968253968253968 * N[(l * l), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 0.0048], N[(N[(N[(2.0 * l), $MachinePrecision] * t$95$0), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 8.2e+98], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], t$95$1]]]]]]
                                                                      
                                                                      \begin{array}{l}
                                                                      
                                                                      \\
                                                                      \begin{array}{l}
                                                                      t_0 := \cos \left(0.5 \cdot K\right)\\
                                                                      t_1 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot t\_0\\
                                                                      \mathbf{if}\;\ell \leq -1.02 \cdot 10^{+117}:\\
                                                                      \;\;\;\;t\_1\\
                                                                      
                                                                      \mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+33}:\\
                                                                      \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
                                                                      
                                                                      \mathbf{elif}\;\ell \leq 0.0048:\\
                                                                      \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot t\_0, J, U\right)\\
                                                                      
                                                                      \mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+98}:\\
                                                                      \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
                                                                      
                                                                      \mathbf{else}:\\
                                                                      \;\;\;\;t\_1\\
                                                                      
                                                                      
                                                                      \end{array}
                                                                      \end{array}
                                                                      
                                                                      Derivation
                                                                      1. Split input into 4 regimes
                                                                      2. if l < -1.02e117 or 8.2000000000000001e98 < l

                                                                        1. Initial program 100.0%

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

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

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

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

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

                                                                            if -1.02e117 < l < -2.19999999999999994e33

                                                                            1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                                              \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                                                            6. Step-by-step derivation
                                                                              1. Applied rewrites100.0%

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

                                                                                \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}, J, U\right) \]
                                                                              3. Step-by-step derivation
                                                                                1. Applied rewrites100.0%

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

                                                                                if -2.19999999999999994e33 < l < 0.00479999999999999958

                                                                                1. Initial program 68.9%

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

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

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

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

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

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

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

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

                                                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{2 \cdot \left(\ell \cdot \cos \left(\frac{-1}{2} \cdot K\right)\right)}, J, U\right) \]
                                                                                6. Step-by-step derivation
                                                                                  1. Applied rewrites98.3%

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

                                                                                  if 0.00479999999999999958 < l < 8.2000000000000001e98

                                                                                  1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                                                    \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                                                                  6. Step-by-step derivation
                                                                                    1. Applied rewrites84.0%

                                                                                      \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                                                                  7. Recombined 4 regimes into one program.
                                                                                  8. Final simplification97.6%

                                                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.02 \cdot 10^{+117}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(0.5 \cdot K\right)\\ \mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+33}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 0.0048:\\ \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+98}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(0.5 \cdot K\right)\\ \end{array} \]
                                                                                  9. Add Preprocessing

                                                                                  Alternative 14: 90.4% accurate, 2.1× speedup?

                                                                                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(J \cdot \ell\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \cos \left(-0.5 \cdot K\right)\right)\\ \mathbf{if}\;\ell \leq -1.4 \cdot 10^{+149}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+33}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 0.0048:\\ \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+98}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                                                                  (FPCore (J l K U)
                                                                                   :precision binary64
                                                                                   (let* ((t_0
                                                                                           (*
                                                                                            (* J l)
                                                                                            (* (fma (* l l) 0.3333333333333333 2.0) (cos (* -0.5 K))))))
                                                                                     (if (<= l -1.4e+149)
                                                                                       t_0
                                                                                       (if (<= l -2.2e+33)
                                                                                         (fma
                                                                                          (*
                                                                                           1.0
                                                                                           (*
                                                                                            (fma
                                                                                             (fma
                                                                                              (fma 0.0003968253968253968 (* l l) 0.016666666666666666)
                                                                                              (* l l)
                                                                                              0.3333333333333333)
                                                                                             (* l l)
                                                                                             2.0)
                                                                                            l))
                                                                                          J
                                                                                          U)
                                                                                         (if (<= l 0.0048)
                                                                                           (fma (* (* 2.0 l) (cos (* 0.5 K))) J U)
                                                                                           (if (<= l 8.2e+98) (fma (* 1.0 (* (sinh l) 2.0)) J U) t_0))))))
                                                                                  double code(double J, double l, double K, double U) {
                                                                                  	double t_0 = (J * l) * (fma((l * l), 0.3333333333333333, 2.0) * cos((-0.5 * K)));
                                                                                  	double tmp;
                                                                                  	if (l <= -1.4e+149) {
                                                                                  		tmp = t_0;
                                                                                  	} else if (l <= -2.2e+33) {
                                                                                  		tmp = fma((1.0 * (fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)), J, U);
                                                                                  	} else if (l <= 0.0048) {
                                                                                  		tmp = fma(((2.0 * l) * cos((0.5 * K))), J, U);
                                                                                  	} else if (l <= 8.2e+98) {
                                                                                  		tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
                                                                                  	} else {
                                                                                  		tmp = t_0;
                                                                                  	}
                                                                                  	return tmp;
                                                                                  }
                                                                                  
                                                                                  function code(J, l, K, U)
                                                                                  	t_0 = Float64(Float64(J * l) * Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * cos(Float64(-0.5 * K))))
                                                                                  	tmp = 0.0
                                                                                  	if (l <= -1.4e+149)
                                                                                  		tmp = t_0;
                                                                                  	elseif (l <= -2.2e+33)
                                                                                  		tmp = fma(Float64(1.0 * Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)), J, U);
                                                                                  	elseif (l <= 0.0048)
                                                                                  		tmp = fma(Float64(Float64(2.0 * l) * cos(Float64(0.5 * K))), J, U);
                                                                                  	elseif (l <= 8.2e+98)
                                                                                  		tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U);
                                                                                  	else
                                                                                  		tmp = t_0;
                                                                                  	end
                                                                                  	return tmp
                                                                                  end
                                                                                  
                                                                                  code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J * l), $MachinePrecision] * N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.4e+149], t$95$0, If[LessEqual[l, -2.2e+33], N[(N[(1.0 * N[(N[(N[(N[(0.0003968253968253968 * N[(l * l), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 0.0048], N[(N[(N[(2.0 * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 8.2e+98], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], t$95$0]]]]]
                                                                                  
                                                                                  \begin{array}{l}
                                                                                  
                                                                                  \\
                                                                                  \begin{array}{l}
                                                                                  t_0 := \left(J \cdot \ell\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \cos \left(-0.5 \cdot K\right)\right)\\
                                                                                  \mathbf{if}\;\ell \leq -1.4 \cdot 10^{+149}:\\
                                                                                  \;\;\;\;t\_0\\
                                                                                  
                                                                                  \mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+33}:\\
                                                                                  \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
                                                                                  
                                                                                  \mathbf{elif}\;\ell \leq 0.0048:\\
                                                                                  \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), J, U\right)\\
                                                                                  
                                                                                  \mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+98}:\\
                                                                                  \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
                                                                                  
                                                                                  \mathbf{else}:\\
                                                                                  \;\;\;\;t\_0\\
                                                                                  
                                                                                  
                                                                                  \end{array}
                                                                                  \end{array}
                                                                                  
                                                                                  Derivation
                                                                                  1. Split input into 4 regimes
                                                                                  2. if l < -1.4e149 or 8.2000000000000001e98 < l

                                                                                    1. Initial program 100.0%

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

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

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

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

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

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

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

                                                                                          if -1.4e149 < l < -2.19999999999999994e33

                                                                                          1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                                                            \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                                                                          6. Step-by-step derivation
                                                                                            1. Applied rewrites94.1%

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

                                                                                              \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}, J, U\right) \]
                                                                                            3. Step-by-step derivation
                                                                                              1. Applied rewrites94.1%

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

                                                                                              if -2.19999999999999994e33 < l < 0.00479999999999999958

                                                                                              1. Initial program 68.9%

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

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

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

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

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

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

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

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

                                                                                                \[\leadsto \mathsf{fma}\left(\color{blue}{2 \cdot \left(\ell \cdot \cos \left(\frac{-1}{2} \cdot K\right)\right)}, J, U\right) \]
                                                                                              6. Step-by-step derivation
                                                                                                1. Applied rewrites98.3%

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

                                                                                                if 0.00479999999999999958 < l < 8.2000000000000001e98

                                                                                                1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                                                                  \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                                                                                6. Step-by-step derivation
                                                                                                  1. Applied rewrites84.0%

                                                                                                    \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                                                                                7. Recombined 4 regimes into one program.
                                                                                                8. Final simplification96.4%

                                                                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.4 \cdot 10^{+149}:\\ \;\;\;\;\left(J \cdot \ell\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \cos \left(-0.5 \cdot K\right)\right)\\ \mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+33}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 0.0048:\\ \;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), J, U\right)\\ \mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+98}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(J \cdot \ell\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \cos \left(-0.5 \cdot K\right)\right)\\ \end{array} \]
                                                                                                9. Add Preprocessing

                                                                                                Alternative 15: 81.0% accurate, 2.1× speedup?

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

                                                                                                  1. Initial program 85.8%

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

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

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

                                                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right) + J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                                                    3. Step-by-step derivation
                                                                                                      1. Applied rewrites19.2%

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

                                                                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \ell, U\right) \]
                                                                                                      3. Step-by-step derivation
                                                                                                        1. Applied rewrites61.1%

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

                                                                                                        if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                                                                        1. Initial program 84.2%

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

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

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

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

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

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

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

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

                                                                                                          \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \left(\sinh \ell \cdot 2\right), J, U\right) \]
                                                                                                        6. Step-by-step derivation
                                                                                                          1. Applied rewrites96.2%

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

                                                                                                            \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}, J, U\right) \]
                                                                                                          3. Step-by-step derivation
                                                                                                            1. Applied rewrites88.3%

                                                                                                              \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)}, J, U\right) \]
                                                                                                          4. Recombined 2 regimes into one program.
                                                                                                          5. Final simplification81.8%

                                                                                                            \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\ \;\;\;\;\mathsf{fma}\left(\left(-0.125 \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\ \end{array} \]
                                                                                                          6. Add Preprocessing

                                                                                                          Alternative 16: 78.6% accurate, 2.1× speedup?

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

                                                                                                            1. Initial program 85.8%

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

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

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

                                                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right) + J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                                                              3. Step-by-step derivation
                                                                                                                1. Applied rewrites19.2%

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

                                                                                                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \ell, U\right) \]
                                                                                                                3. Step-by-step derivation
                                                                                                                  1. Applied rewrites61.1%

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

                                                                                                                  if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                                                                                  1. Initial program 84.2%

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

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

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

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

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

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

                                                                                                                          \[\leadsto \mathsf{fma}\left(\frac{\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J}{U}, U, U\right) \]
                                                                                                                        2. Step-by-step derivation
                                                                                                                          1. Applied rewrites86.7%

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

                                                                                                                        Alternative 17: 75.4% accurate, 2.1× speedup?

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

                                                                                                                          1. Initial program 85.8%

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

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

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

                                                                                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right) + J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                                                                            3. Step-by-step derivation
                                                                                                                              1. Applied rewrites19.2%

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

                                                                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \ell, U\right) \]
                                                                                                                              3. Step-by-step derivation
                                                                                                                                1. Applied rewrites61.1%

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

                                                                                                                                if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                                                                                                                                1. Initial program 84.2%

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

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

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

                                                                                                                                    \[\leadsto \mathsf{fma}\left(J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                                                                                  3. Step-by-step derivation
                                                                                                                                    1. Applied rewrites80.5%

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

                                                                                                                                  Alternative 18: 74.1% accurate, 2.3× speedup?

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

                                                                                                                                    1. Initial program 84.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                                                        1. Initial program 84.6%

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

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

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

                                                                                                                                            \[\leadsto \mathsf{fma}\left(J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                                                                                          3. Step-by-step derivation
                                                                                                                                            1. Applied rewrites80.0%

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

                                                                                                                                          Alternative 19: 71.6% accurate, 2.4× speedup?

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

                                                                                                                                            1. Initial program 83.7%

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

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

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

                                                                                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right) + J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                                                                                              3. Step-by-step derivation
                                                                                                                                                1. Applied rewrites23.1%

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

                                                                                                                                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right) + 2 \cdot J, \ell, U\right) \]
                                                                                                                                                3. Step-by-step derivation
                                                                                                                                                  1. Applied rewrites58.8%

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

                                                                                                                                                    \[\leadsto \mathsf{fma}\left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right), \ell, U\right) \]
                                                                                                                                                  3. Step-by-step derivation
                                                                                                                                                    1. Applied rewrites61.2%

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

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

                                                                                                                                                    1. Initial program 84.8%

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

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

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

                                                                                                                                                        \[\leadsto \mathsf{fma}\left(J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                                                                                                      3. Step-by-step derivation
                                                                                                                                                        1. Applied rewrites77.2%

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

                                                                                                                                                      Alternative 20: 71.6% accurate, 2.4× speedup?

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

                                                                                                                                                        1. Initial program 83.7%

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

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

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

                                                                                                                                                            \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right) + J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                                                                                                          3. Step-by-step derivation
                                                                                                                                                            1. Applied rewrites23.1%

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

                                                                                                                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right) + 2 \cdot J, \ell, U\right) \]
                                                                                                                                                            3. Step-by-step derivation
                                                                                                                                                              1. Applied rewrites58.8%

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

                                                                                                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right), \ell, U\right) \]
                                                                                                                                                              3. Step-by-step derivation
                                                                                                                                                                1. Applied rewrites61.2%

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

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

                                                                                                                                                                1. Initial program 84.8%

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

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

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

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

                                                                                                                                                                      \[\leadsto \mathsf{fma}\left(J \cdot \ell, \color{blue}{\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)}, U\right) \]
                                                                                                                                                                    2. Step-by-step derivation
                                                                                                                                                                      1. Applied rewrites77.2%

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

                                                                                                                                                                    Alternative 21: 71.6% accurate, 9.7× speedup?

                                                                                                                                                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.3 \cdot 10^{+33} \lor \neg \left(\ell \leq 1.5\right):\\ \;\;\;\;\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\ \end{array} \end{array} \]
                                                                                                                                                                    (FPCore (J l K U)
                                                                                                                                                                     :precision binary64
                                                                                                                                                                     (if (or (<= l -2.3e+33) (not (<= l 1.5)))
                                                                                                                                                                       (* (* (fma (* l l) 0.3333333333333333 2.0) l) J)
                                                                                                                                                                       (fma (* 2.0 J) l U)))
                                                                                                                                                                    double code(double J, double l, double K, double U) {
                                                                                                                                                                    	double tmp;
                                                                                                                                                                    	if ((l <= -2.3e+33) || !(l <= 1.5)) {
                                                                                                                                                                    		tmp = (fma((l * l), 0.3333333333333333, 2.0) * l) * J;
                                                                                                                                                                    	} else {
                                                                                                                                                                    		tmp = fma((2.0 * J), l, U);
                                                                                                                                                                    	}
                                                                                                                                                                    	return tmp;
                                                                                                                                                                    }
                                                                                                                                                                    
                                                                                                                                                                    function code(J, l, K, U)
                                                                                                                                                                    	tmp = 0.0
                                                                                                                                                                    	if ((l <= -2.3e+33) || !(l <= 1.5))
                                                                                                                                                                    		tmp = Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J);
                                                                                                                                                                    	else
                                                                                                                                                                    		tmp = fma(Float64(2.0 * J), l, U);
                                                                                                                                                                    	end
                                                                                                                                                                    	return tmp
                                                                                                                                                                    end
                                                                                                                                                                    
                                                                                                                                                                    code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.3e+33], N[Not[LessEqual[l, 1.5]], $MachinePrecision]], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision], N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision]]
                                                                                                                                                                    
                                                                                                                                                                    \begin{array}{l}
                                                                                                                                                                    
                                                                                                                                                                    \\
                                                                                                                                                                    \begin{array}{l}
                                                                                                                                                                    \mathbf{if}\;\ell \leq -2.3 \cdot 10^{+33} \lor \neg \left(\ell \leq 1.5\right):\\
                                                                                                                                                                    \;\;\;\;\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\\
                                                                                                                                                                    
                                                                                                                                                                    \mathbf{else}:\\
                                                                                                                                                                    \;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\
                                                                                                                                                                    
                                                                                                                                                                    
                                                                                                                                                                    \end{array}
                                                                                                                                                                    \end{array}
                                                                                                                                                                    
                                                                                                                                                                    Derivation
                                                                                                                                                                    1. Split input into 2 regimes
                                                                                                                                                                    2. if l < -2.30000000000000011e33 or 1.5 < l

                                                                                                                                                                      1. Initial program 100.0%

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

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

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

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

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

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

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

                                                                                                                                                                            if -2.30000000000000011e33 < l < 1.5

                                                                                                                                                                            1. Initial program 68.9%

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

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

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

                                                                                                                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right) + J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                                                                                                                              3. Step-by-step derivation
                                                                                                                                                                                1. Applied rewrites64.2%

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

                                                                                                                                                                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right) + 2 \cdot J, \ell, U\right) \]
                                                                                                                                                                                3. Step-by-step derivation
                                                                                                                                                                                  1. Applied rewrites63.4%

                                                                                                                                                                                    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(K \cdot K\right) \cdot J, -0.25, 2 \cdot J\right), \ell, U\right) \]
                                                                                                                                                                                  2. Taylor expanded in K around 0

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

                                                                                                                                                                                      \[\leadsto \mathsf{fma}\left(2 \cdot J, \ell, U\right) \]
                                                                                                                                                                                  4. Recombined 2 regimes into one program.
                                                                                                                                                                                  5. Final simplification70.4%

                                                                                                                                                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.3 \cdot 10^{+33} \lor \neg \left(\ell \leq 1.5\right):\\ \;\;\;\;\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\ \end{array} \]
                                                                                                                                                                                  6. Add Preprocessing

                                                                                                                                                                                  Alternative 22: 53.7% accurate, 27.5× speedup?

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

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

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

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

                                                                                                                                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right) + J \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right), \ell, U\right) \]
                                                                                                                                                                                    3. Step-by-step derivation
                                                                                                                                                                                      1. Applied rewrites35.5%

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

                                                                                                                                                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{4} \cdot \left(J \cdot {K}^{2}\right) + 2 \cdot J, \ell, U\right) \]
                                                                                                                                                                                      3. Step-by-step derivation
                                                                                                                                                                                        1. Applied rewrites47.0%

                                                                                                                                                                                          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(K \cdot K\right) \cdot J, -0.25, 2 \cdot J\right), \ell, U\right) \]
                                                                                                                                                                                        2. Taylor expanded in K around 0

                                                                                                                                                                                          \[\leadsto \mathsf{fma}\left(2 \cdot J, \ell, U\right) \]
                                                                                                                                                                                        3. Step-by-step derivation
                                                                                                                                                                                          1. Applied rewrites51.3%

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

                                                                                                                                                                                          Alternative 23: 53.7% accurate, 27.5× speedup?

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

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

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

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

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

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

                                                                                                                                                                                                \[\leadsto \mathsf{fma}\left(J \cdot \ell, 2, U\right) \]
                                                                                                                                                                                              3. Step-by-step derivation
                                                                                                                                                                                                1. Applied rewrites51.3%

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

                                                                                                                                                                                                Alternative 24: 36.3% accurate, 330.0× 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 84.6%

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

                                                                                                                                                                                                  \[\leadsto \color{blue}{U} \]
                                                                                                                                                                                                4. Step-by-step derivation
                                                                                                                                                                                                  1. Applied rewrites33.5%

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

                                                                                                                                                                                                  Reproduce

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