Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.2% → 99.9%
Time: 8.5s
Alternatives: 15
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;
}
real(8) function code(j, l, k, u)
    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 15 alternatives:

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

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

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

Alternative 1: 99.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \left(\cos \left(K \cdot -0.5\right) \cdot \left(\sinh \ell \cdot 2\right)\right) \cdot J + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ (* (* (cos (* K -0.5)) (* (sinh l) 2.0)) J) U))
double code(double J, double l, double K, double U) {
	return ((cos((K * -0.5)) * (sinh(l) * 2.0)) * J) + U;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = ((cos((k * (-0.5d0))) * (sinh(l) * 2.0d0)) * j) + u
end function
public static double code(double J, double l, double K, double U) {
	return ((Math.cos((K * -0.5)) * (Math.sinh(l) * 2.0)) * J) + U;
}
def code(J, l, K, U):
	return ((math.cos((K * -0.5)) * (math.sinh(l) * 2.0)) * J) + U
function code(J, l, K, U)
	return Float64(Float64(Float64(cos(Float64(K * -0.5)) * Float64(sinh(l) * 2.0)) * J) + U)
end
function tmp = code(J, l, K, U)
	tmp = ((cos((K * -0.5)) * (sinh(l) * 2.0)) * J) + U;
end
code[J_, l_, K_, U_] := N[(N[(N[(N[Cos[N[(K * -0.5), $MachinePrecision]], $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

Alternative 2: 86.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+162} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+148}\right):\\ \;\;\;\;\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\sinh \ell \cdot 2\right)\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;\left(\left(2 \cdot \ell\right) \cdot \cos \left(-0.5 \cdot K\right)\right) \cdot J + U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0)))))
   (if (or (<= t_0 -1e+162) (not (<= t_0 2e+148)))
     (+ (* (* (fma (* K K) -0.125 1.0) (* (sinh l) 2.0)) J) U)
     (+ (* (* (* 2.0 l) (cos (* -0.5 K))) J) U))))
double code(double J, double l, double K, double U) {
	double t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0));
	double tmp;
	if ((t_0 <= -1e+162) || !(t_0 <= 2e+148)) {
		tmp = ((fma((K * K), -0.125, 1.0) * (sinh(l) * 2.0)) * J) + U;
	} else {
		tmp = (((2.0 * l) * cos((-0.5 * K))) * J) + U;
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0)))
	tmp = 0.0
	if ((t_0 <= -1e+162) || !(t_0 <= 2e+148))
		tmp = Float64(Float64(Float64(fma(Float64(K * K), -0.125, 1.0) * Float64(sinh(l) * 2.0)) * J) + U);
	else
		tmp = Float64(Float64(Float64(Float64(2.0 * l) * cos(Float64(-0.5 * K))) * J) + U);
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e+162], N[Not[LessEqual[t$95$0, 2e+148]], $MachinePrecision]], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(2.0 * l), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+162} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+148}\right):\\
\;\;\;\;\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\sinh \ell \cdot 2\right)\right) \cdot J + U\\

\mathbf{else}:\\
\;\;\;\;\left(\left(2 \cdot \ell\right) \cdot \cos \left(-0.5 \cdot K\right)\right) \cdot J + U\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < -9.9999999999999994e161 or 2.0000000000000001e148 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64))))

    1. Initial program 99.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. 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 \]
      4. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

    if -9.9999999999999994e161 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < 2.0000000000000001e148

    1. Initial program 75.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. 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 \]
      4. *-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot \cos \color{blue}{\left(-0.5 \cdot K\right)}\right) \cdot J + U \]
    7. Applied rewrites99.3%

      \[\leadsto \color{blue}{\left(\left(2 \cdot \ell\right) \cdot \cos \left(-0.5 \cdot K\right)\right)} \cdot J + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) \leq -1 \cdot 10^{+162} \lor \neg \left(\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) \leq 2 \cdot 10^{+148}\right):\\ \;\;\;\;\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\sinh \ell \cdot 2\right)\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;\left(\left(2 \cdot \ell\right) \cdot \cos \left(-0.5 \cdot K\right)\right) \cdot J + U\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 69.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 0\right):\\ \;\;\;\;\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \ell\right) \cdot J + U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0)))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 0.0)))
     (+ (* (* (* (* l l) J) 0.3333333333333333) l) U)
     (+ (* (* 2.0 l) J) U))))
double code(double J, double l, double K, double U) {
	double t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0));
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 0.0)) {
		tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
	} else {
		tmp = ((2.0 * l) * J) + U;
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double t_0 = (J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0));
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 0.0)) {
		tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
	} else {
		tmp = ((2.0 * l) * J) + U;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = (J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 0.0):
		tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U
	else:
		tmp = ((2.0 * l) * J) + U
	return tmp
function code(J, l, K, U)
	t_0 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0)))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 0.0))
		tmp = Float64(Float64(Float64(Float64(Float64(l * l) * J) * 0.3333333333333333) * l) + U);
	else
		tmp = Float64(Float64(Float64(2.0 * l) * J) + U);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0));
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 0.0)))
		tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
	else
		tmp = ((2.0 * l) * J) + U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(N[(N[(N[(N[(l * l), $MachinePrecision] * J), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(2.0 * l), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U\\

\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \ell\right) \cdot J + U\\


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

    1. Initial program 99.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 K around 0

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

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

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

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

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

        \[\leadsto \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right) \cdot J + U \]
      6. lower-neg.f6468.7

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

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

        \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
      2. Taylor expanded in l around 0

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

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

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

            \[\leadsto \left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U \]

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

          1. Initial program 75.5%

            \[\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 K around 0

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

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

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

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

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

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

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

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

              \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
            2. Taylor expanded in l around 0

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

                \[\leadsto \left(2 \cdot \ell\right) \cdot \color{blue}{J} + U \]
            4. Recombined 2 regimes into one program.
            5. Final simplification63.6%

              \[\leadsto \begin{array}{l} \mathbf{if}\;\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) \leq -\infty \lor \neg \left(\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) \leq 0\right):\\ \;\;\;\;\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \ell\right) \cdot J + U\\ \end{array} \]
            6. Add Preprocessing

            Alternative 4: 78.7% accurate, 1.1× speedup?

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

              1. Initial program 92.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 \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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \ell \cdot \ell, \frac{1}{60}\right), \ell \cdot \ell, \frac{1}{3}\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                16. lower-*.f6495.9

                  \[\leadsto \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), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              5. Applied rewrites95.9%

                \[\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 \]
              6. Step-by-step derivation
                1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(\mathsf{fma}\left(\color{blue}{K \cdot K}, \frac{-1}{8}, 1\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, \frac{1}{2520}, \frac{1}{60}\right), \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell\right) + U \]
                10. lower-*.f6482.9

                  \[\leadsto \left(\mathsf{fma}\left(\color{blue}{K \cdot K}, -0.125, 1\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) + U \]
              10. Applied rewrites82.9%

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

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

              1. Initial program 80.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 K around 0

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

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

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

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

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

                  \[\leadsto \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right) \cdot J + U \]
                6. lower-neg.f6480.8

                  \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
              5. Applied rewrites80.8%

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

                  \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                2. Taylor expanded in l around 0

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

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

                      \[\leadsto \left(J \cdot \mathsf{fma}\left(0.3333333333333333 \cdot \ell, \ell, 2\right)\right) \cdot \ell + U \]
                  3. Recombined 2 regimes into one program.
                  4. Final simplification79.9%

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

                  Alternative 5: 96.2% accurate, 1.2× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.95:\\ \;\;\;\;\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}:\\ \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\ \end{array} \end{array} \]
                  (FPCore (J l K U)
                   :precision binary64
                   (let* ((t_0 (cos (/ K 2.0))))
                     (if (<= t_0 0.95)
                       (+
                        (*
                         (*
                          J
                          (*
                           (fma
                            (fma 0.016666666666666666 (* l l) 0.3333333333333333)
                            (* l l)
                            2.0)
                           l))
                         t_0)
                        U)
                       (+ (* (* (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.95) {
                  		tmp = ((J * (fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * t_0) + U;
                  	} else {
                  		tmp = ((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.95)
                  		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 = Float64(Float64(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.95], 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[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \cos \left(\frac{K}{2}\right)\\
                  \mathbf{if}\;t\_0 \leq 0.95:\\
                  \;\;\;\;\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}:\\
                  \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996

                    1. Initial program 85.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 \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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

                      \[\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.94999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

                    1. Initial program 93.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 K around 0

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

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

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

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

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

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

                        \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                    5. Applied rewrites93.9%

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

                        \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                    7. Recombined 2 regimes into one program.
                    8. Add Preprocessing

                    Alternative 6: 95.8% accurate, 1.3× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\ \;\;\;\;\left(\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right)\right) \cdot \ell + U\\ \mathbf{else}:\\ \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\ \end{array} \end{array} \]
                    (FPCore (J l K U)
                     :precision binary64
                     (if (<= (cos (/ K 2.0)) 0.95)
                       (+
                        (*
                         (*
                          (* (cos (* 0.5 K)) J)
                          (fma (fma 0.016666666666666666 (* l l) 0.3333333333333333) (* l l) 2.0))
                         l)
                        U)
                       (+ (* (* (sinh l) 2.0) J) U)))
                    double code(double J, double l, double K, double U) {
                    	double tmp;
                    	if (cos((K / 2.0)) <= 0.95) {
                    		tmp = (((cos((0.5 * K)) * J) * fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0)) * l) + U;
                    	} else {
                    		tmp = ((sinh(l) * 2.0) * J) + U;
                    	}
                    	return tmp;
                    }
                    
                    function code(J, l, K, U)
                    	tmp = 0.0
                    	if (cos(Float64(K / 2.0)) <= 0.95)
                    		tmp = Float64(Float64(Float64(Float64(cos(Float64(0.5 * K)) * J) * fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0)) * l) + U);
                    	else
                    		tmp = Float64(Float64(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.95], N[(N[(N[(N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\
                    \;\;\;\;\left(\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right)\right) \cdot \ell + U\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996

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

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

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

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

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

                      1. Initial program 93.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 K around 0

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

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

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

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

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

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

                          \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                      5. Applied rewrites93.9%

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

                          \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                      7. Recombined 2 regimes into one program.
                      8. Add Preprocessing

                      Alternative 7: 73.4% accurate, 1.3× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -0.953:\\ \;\;\;\;\left(1 - \mathsf{fma}\left(\mathsf{fma}\left(0.5, \ell, -1\right), \ell, 1\right)\right) \cdot J + U\\ \mathbf{elif}\;t\_0 \leq -0.2:\\ \;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U\\ \mathbf{else}:\\ \;\;\;\;\left(J \cdot \mathsf{fma}\left(0.3333333333333333 \cdot \ell, \ell, 2\right)\right) \cdot \ell + U\\ \end{array} \end{array} \]
                      (FPCore (J l K U)
                       :precision binary64
                       (let* ((t_0 (cos (/ K 2.0))))
                         (if (<= t_0 -0.953)
                           (+ (* (- 1.0 (fma (fma 0.5 l -1.0) l 1.0)) J) U)
                           (if (<= t_0 -0.2)
                             (+ (* (* (* (* K K) l) J) -0.25) U)
                             (+ (* (* J (fma (* 0.3333333333333333 l) l 2.0)) l) U)))))
                      double code(double J, double l, double K, double U) {
                      	double t_0 = cos((K / 2.0));
                      	double tmp;
                      	if (t_0 <= -0.953) {
                      		tmp = ((1.0 - fma(fma(0.5, l, -1.0), l, 1.0)) * J) + U;
                      	} else if (t_0 <= -0.2) {
                      		tmp = ((((K * K) * l) * J) * -0.25) + U;
                      	} else {
                      		tmp = ((J * fma((0.3333333333333333 * l), l, 2.0)) * l) + U;
                      	}
                      	return tmp;
                      }
                      
                      function code(J, l, K, U)
                      	t_0 = cos(Float64(K / 2.0))
                      	tmp = 0.0
                      	if (t_0 <= -0.953)
                      		tmp = Float64(Float64(Float64(1.0 - fma(fma(0.5, l, -1.0), l, 1.0)) * J) + U);
                      	elseif (t_0 <= -0.2)
                      		tmp = Float64(Float64(Float64(Float64(Float64(K * K) * l) * J) * -0.25) + U);
                      	else
                      		tmp = Float64(Float64(Float64(J * fma(Float64(0.3333333333333333 * l), l, 2.0)) * l) + 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.953], N[(N[(N[(1.0 - N[(N[(0.5 * l + -1.0), $MachinePrecision] * l + 1.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, -0.2], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J * N[(N[(0.3333333333333333 * l), $MachinePrecision] * l + 2.0), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision]]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_0 := \cos \left(\frac{K}{2}\right)\\
                      \mathbf{if}\;t\_0 \leq -0.953:\\
                      \;\;\;\;\left(1 - \mathsf{fma}\left(\mathsf{fma}\left(0.5, \ell, -1\right), \ell, 1\right)\right) \cdot J + U\\
                      
                      \mathbf{elif}\;t\_0 \leq -0.2:\\
                      \;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\left(J \cdot \mathsf{fma}\left(0.3333333333333333 \cdot \ell, \ell, 2\right)\right) \cdot \ell + U\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 3 regimes
                      2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.952999999999999958

                        1. Initial program 81.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 K around 0

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

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

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

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

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

                            \[\leadsto \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right) \cdot J + U \]
                          6. lower-neg.f6441.0

                            \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                        5. Applied rewrites41.0%

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

                          \[\leadsto \left(1 - e^{-\ell}\right) \cdot J + U \]
                        7. Step-by-step derivation
                          1. Applied rewrites41.4%

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

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

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

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

                            1. Initial program 91.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}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
                            4. Step-by-step derivation
                              1. associate-*r*N/A

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

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

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

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

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

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

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

                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot 2\right) \cdot \cos \color{blue}{\left(0.5 \cdot K\right)} + U \]
                            5. Applied rewrites55.2%

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

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

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

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

                                  \[\leadsto \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U \]

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

                                1. Initial program 89.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 K around 0

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

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

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

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

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

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

                                    \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                                5. Applied rewrites89.3%

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

                                    \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                                  2. Taylor expanded in l around 0

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

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

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

                                    Alternative 8: 65.8% accurate, 1.3× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -0.953:\\ \;\;\;\;\left(1 - \mathsf{fma}\left(\mathsf{fma}\left(0.5, \ell, -1\right), \ell, 1\right)\right) \cdot J + U\\ \mathbf{elif}\;t\_0 \leq -0.2:\\ \;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U\\ \end{array} \end{array} \]
                                    (FPCore (J l K U)
                                     :precision binary64
                                     (let* ((t_0 (cos (/ K 2.0))))
                                       (if (<= t_0 -0.953)
                                         (+ (* (- 1.0 (fma (fma 0.5 l -1.0) l 1.0)) J) U)
                                         (if (<= t_0 -0.2)
                                           (+ (* (* (* (* K K) l) J) -0.25) U)
                                           (+ (* (* (* (* l l) J) 0.3333333333333333) l) U)))))
                                    double code(double J, double l, double K, double U) {
                                    	double t_0 = cos((K / 2.0));
                                    	double tmp;
                                    	if (t_0 <= -0.953) {
                                    		tmp = ((1.0 - fma(fma(0.5, l, -1.0), l, 1.0)) * J) + U;
                                    	} else if (t_0 <= -0.2) {
                                    		tmp = ((((K * K) * l) * J) * -0.25) + U;
                                    	} else {
                                    		tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    function code(J, l, K, U)
                                    	t_0 = cos(Float64(K / 2.0))
                                    	tmp = 0.0
                                    	if (t_0 <= -0.953)
                                    		tmp = Float64(Float64(Float64(1.0 - fma(fma(0.5, l, -1.0), l, 1.0)) * J) + U);
                                    	elseif (t_0 <= -0.2)
                                    		tmp = Float64(Float64(Float64(Float64(Float64(K * K) * l) * J) * -0.25) + U);
                                    	else
                                    		tmp = Float64(Float64(Float64(Float64(Float64(l * l) * J) * 0.3333333333333333) * l) + 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.953], N[(N[(N[(1.0 - N[(N[(0.5 * l + -1.0), $MachinePrecision] * l + 1.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, -0.2], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(N[(l * l), $MachinePrecision] * J), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision]]]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    t_0 := \cos \left(\frac{K}{2}\right)\\
                                    \mathbf{if}\;t\_0 \leq -0.953:\\
                                    \;\;\;\;\left(1 - \mathsf{fma}\left(\mathsf{fma}\left(0.5, \ell, -1\right), \ell, 1\right)\right) \cdot J + U\\
                                    
                                    \mathbf{elif}\;t\_0 \leq -0.2:\\
                                    \;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 3 regimes
                                    2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.952999999999999958

                                      1. Initial program 81.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 K around 0

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

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

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

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

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

                                          \[\leadsto \left(e^{\ell} - \color{blue}{e^{\mathsf{neg}\left(\ell\right)}}\right) \cdot J + U \]
                                        6. lower-neg.f6441.0

                                          \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                                      5. Applied rewrites41.0%

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

                                        \[\leadsto \left(1 - e^{-\ell}\right) \cdot J + U \]
                                      7. Step-by-step derivation
                                        1. Applied rewrites41.4%

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

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

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

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

                                          1. Initial program 91.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}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
                                          4. Step-by-step derivation
                                            1. associate-*r*N/A

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

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

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

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

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

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

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

                                              \[\leadsto \left(\left(J \cdot \ell\right) \cdot 2\right) \cdot \cos \color{blue}{\left(0.5 \cdot K\right)} + U \]
                                          5. Applied rewrites55.2%

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

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

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

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

                                                \[\leadsto \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U \]

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

                                              1. Initial program 89.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 K around 0

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

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

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

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

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

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

                                                  \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                                              5. Applied rewrites89.3%

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

                                                  \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                                                2. Taylor expanded in l around 0

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

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

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

                                                      \[\leadsto \left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U \]
                                                  4. Recombined 3 regimes into one program.
                                                  5. Add Preprocessing

                                                  Alternative 9: 94.0% accurate, 1.3× speedup?

                                                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.95:\\ \;\;\;\;\left(J \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right)\right) \cdot t\_0 + U\\ \mathbf{else}:\\ \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\ \end{array} \end{array} \]
                                                  (FPCore (J l K U)
                                                   :precision binary64
                                                   (let* ((t_0 (cos (/ K 2.0))))
                                                     (if (<= t_0 0.95)
                                                       (+ (* (* J (* (fma (* l l) 0.3333333333333333 2.0) l)) t_0) U)
                                                       (+ (* (* (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.95) {
                                                  		tmp = ((J * (fma((l * l), 0.3333333333333333, 2.0) * l)) * t_0) + U;
                                                  	} else {
                                                  		tmp = ((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.95)
                                                  		tmp = Float64(Float64(Float64(J * Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l)) * t_0) + U);
                                                  	else
                                                  		tmp = Float64(Float64(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.95], N[(N[(N[(J * N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]]
                                                  
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  \begin{array}{l}
                                                  t_0 := \cos \left(\frac{K}{2}\right)\\
                                                  \mathbf{if}\;t\_0 \leq 0.95:\\
                                                  \;\;\;\;\left(J \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right)\right) \cdot t\_0 + U\\
                                                  
                                                  \mathbf{else}:\\
                                                  \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
                                                  
                                                  
                                                  \end{array}
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Split input into 2 regimes
                                                  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996

                                                    1. Initial program 85.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 \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                    4. Step-by-step derivation
                                                      1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                                                    1. Initial program 93.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 K around 0

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

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

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

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

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

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

                                                        \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                                                    5. Applied rewrites93.9%

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

                                                        \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                                                    7. Recombined 2 regimes into one program.
                                                    8. Add Preprocessing

                                                    Alternative 10: 92.8% accurate, 1.3× speedup?

                                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\ \;\;\;\;\left(\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right) \cdot \ell + U\\ \mathbf{else}:\\ \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\ \end{array} \end{array} \]
                                                    (FPCore (J l K U)
                                                     :precision binary64
                                                     (if (<= (cos (/ K 2.0)) 0.95)
                                                       (+ (* (* (* (cos (* 0.5 K)) J) (fma (* l l) 0.3333333333333333 2.0)) l) U)
                                                       (+ (* (* (sinh l) 2.0) J) U)))
                                                    double code(double J, double l, double K, double U) {
                                                    	double tmp;
                                                    	if (cos((K / 2.0)) <= 0.95) {
                                                    		tmp = (((cos((0.5 * K)) * J) * fma((l * l), 0.3333333333333333, 2.0)) * l) + U;
                                                    	} else {
                                                    		tmp = ((sinh(l) * 2.0) * J) + U;
                                                    	}
                                                    	return tmp;
                                                    }
                                                    
                                                    function code(J, l, K, U)
                                                    	tmp = 0.0
                                                    	if (cos(Float64(K / 2.0)) <= 0.95)
                                                    		tmp = Float64(Float64(Float64(Float64(cos(Float64(0.5 * K)) * J) * fma(Float64(l * l), 0.3333333333333333, 2.0)) * l) + U);
                                                    	else
                                                    		tmp = Float64(Float64(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.95], N[(N[(N[(N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
                                                    
                                                    \begin{array}{l}
                                                    
                                                    \\
                                                    \begin{array}{l}
                                                    \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\
                                                    \;\;\;\;\left(\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right) \cdot \ell + U\\
                                                    
                                                    \mathbf{else}:\\
                                                    \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
                                                    
                                                    
                                                    \end{array}
                                                    \end{array}
                                                    
                                                    Derivation
                                                    1. Split input into 2 regimes
                                                    2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996

                                                      1. Initial program 85.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}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
                                                      4. Step-by-step derivation
                                                        1. associate-*r*N/A

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

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

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

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

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

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

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

                                                          \[\leadsto \left(\left(J \cdot \ell\right) \cdot 2\right) \cdot \cos \color{blue}{\left(0.5 \cdot K\right)} + U \]
                                                      5. Applied rewrites62.0%

                                                        \[\leadsto \color{blue}{\left(\left(J \cdot \ell\right) \cdot 2\right) \cdot \cos \left(0.5 \cdot K\right)} + U \]
                                                      6. Taylor expanded in l around 0

                                                        \[\leadsto \color{blue}{\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)} + U \]
                                                      7. Step-by-step derivation
                                                        1. *-commutativeN/A

                                                          \[\leadsto \color{blue}{\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) \cdot \ell} + U \]
                                                        2. *-commutativeN/A

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

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

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

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

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

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

                                                      1. Initial program 93.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 K around 0

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

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

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

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

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

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

                                                          \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                                                      5. Applied rewrites93.9%

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

                                                          \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                                                      7. Recombined 2 regimes into one program.
                                                      8. Add Preprocessing

                                                      Alternative 11: 92.9% accurate, 1.3× speedup?

                                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\ \;\;\;\;\left(\left(J \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) + U\\ \mathbf{else}:\\ \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\ \end{array} \end{array} \]
                                                      (FPCore (J l K U)
                                                       :precision binary64
                                                       (if (<= (cos (/ K 2.0)) 0.95)
                                                         (+ (* (* (* J l) (cos (* 0.5 K))) (fma (* l l) 0.3333333333333333 2.0)) U)
                                                         (+ (* (* (sinh l) 2.0) J) U)))
                                                      double code(double J, double l, double K, double U) {
                                                      	double tmp;
                                                      	if (cos((K / 2.0)) <= 0.95) {
                                                      		tmp = (((J * l) * cos((0.5 * K))) * fma((l * l), 0.3333333333333333, 2.0)) + U;
                                                      	} else {
                                                      		tmp = ((sinh(l) * 2.0) * J) + U;
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      function code(J, l, K, U)
                                                      	tmp = 0.0
                                                      	if (cos(Float64(K / 2.0)) <= 0.95)
                                                      		tmp = Float64(Float64(Float64(Float64(J * l) * cos(Float64(0.5 * K))) * fma(Float64(l * l), 0.3333333333333333, 2.0)) + U);
                                                      	else
                                                      		tmp = Float64(Float64(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.95], N[(N[(N[(N[(J * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
                                                      
                                                      \begin{array}{l}
                                                      
                                                      \\
                                                      \begin{array}{l}
                                                      \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\
                                                      \;\;\;\;\left(\left(J \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) + U\\
                                                      
                                                      \mathbf{else}:\\
                                                      \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
                                                      
                                                      
                                                      \end{array}
                                                      \end{array}
                                                      
                                                      Derivation
                                                      1. Split input into 2 regimes
                                                      2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996

                                                        1. Initial program 85.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}{\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)} + U \]
                                                        4. Step-by-step derivation
                                                          1. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                        1. Initial program 93.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 K around 0

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

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

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

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

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

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

                                                            \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                                                        5. Applied rewrites93.9%

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

                                                            \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                                                        7. Recombined 2 regimes into one program.
                                                        8. Add Preprocessing

                                                        Alternative 12: 86.1% accurate, 1.4× speedup?

                                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.2:\\ \;\;\;\;\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) + U\\ \mathbf{else}:\\ \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\ \end{array} \end{array} \]
                                                        (FPCore (J l K U)
                                                         :precision binary64
                                                         (if (<= (cos (/ K 2.0)) -0.2)
                                                           (+
                                                            (*
                                                             (* (fma (* K K) -0.125 1.0) J)
                                                             (*
                                                              (fma
                                                               (fma
                                                                (fma (* l l) 0.0003968253968253968 0.016666666666666666)
                                                                (* l l)
                                                                0.3333333333333333)
                                                               (* l l)
                                                               2.0)
                                                              l))
                                                            U)
                                                           (+ (* (* (sinh l) 2.0) J) U)))
                                                        double code(double J, double l, double K, double U) {
                                                        	double tmp;
                                                        	if (cos((K / 2.0)) <= -0.2) {
                                                        		tmp = ((fma((K * K), -0.125, 1.0) * J) * (fma(fma(fma((l * l), 0.0003968253968253968, 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)) + U;
                                                        	} else {
                                                        		tmp = ((sinh(l) * 2.0) * J) + U;
                                                        	}
                                                        	return tmp;
                                                        }
                                                        
                                                        function code(J, l, K, U)
                                                        	tmp = 0.0
                                                        	if (cos(Float64(K / 2.0)) <= -0.2)
                                                        		tmp = Float64(Float64(Float64(fma(Float64(K * K), -0.125, 1.0) * J) * Float64(fma(fma(fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) + U);
                                                        	else
                                                        		tmp = Float64(Float64(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.2], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * J), $MachinePrecision] * N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        \begin{array}{l}
                                                        \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.2:\\
                                                        \;\;\;\;\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) + U\\
                                                        
                                                        \mathbf{else}:\\
                                                        \;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
                                                        
                                                        
                                                        \end{array}
                                                        \end{array}
                                                        
                                                        Derivation
                                                        1. Split input into 2 regimes
                                                        2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.20000000000000001

                                                          1. Initial program 89.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 \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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                              \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \ell \cdot \ell, \frac{1}{60}\right), \ell \cdot \ell, \frac{1}{3}\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                            16. lower-*.f6495.0

                                                              \[\leadsto \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), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                          5. Applied rewrites95.0%

                                                            \[\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 \]
                                                          6. Step-by-step derivation
                                                            1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                              \[\leadsto \left(\mathsf{fma}\left(\color{blue}{K \cdot K}, \frac{-1}{8}, 1\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, \frac{1}{2520}, \frac{1}{60}\right), \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell\right) + U \]
                                                            10. lower-*.f6463.5

                                                              \[\leadsto \left(\mathsf{fma}\left(\color{blue}{K \cdot K}, -0.125, 1\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) + U \]
                                                          10. Applied rewrites63.5%

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

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

                                                          1. Initial program 89.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 K around 0

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

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

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

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

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

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

                                                              \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                                                          5. Applied rewrites89.3%

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

                                                              \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                                                          7. Recombined 2 regimes into one program.
                                                          8. Add Preprocessing

                                                          Alternative 13: 94.8% accurate, 2.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                              \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \ell \cdot \ell, \frac{1}{60}\right), \ell \cdot \ell, \frac{1}{3}\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                            16. lower-*.f6496.2

                                                              \[\leadsto \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), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                                          5. 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 \]
                                                          6. Step-by-step derivation
                                                            1. lift-*.f64N/A

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

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

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

                                                              \[\leadsto \color{blue}{\left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \ell \cdot \ell, \frac{1}{60}\right), \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell\right)} + U \]
                                                          7. Applied rewrites96.2%

                                                            \[\leadsto \color{blue}{\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)} + U \]
                                                          8. Add Preprocessing

                                                          Alternative 14: 66.2% accurate, 2.3× speedup?

                                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.2:\\ \;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U\\ \end{array} \end{array} \]
                                                          (FPCore (J l K U)
                                                           :precision binary64
                                                           (if (<= (cos (/ K 2.0)) -0.2)
                                                             (+ (* (* (* (* K K) l) J) -0.25) U)
                                                             (+ (* (* (* (* l l) J) 0.3333333333333333) l) U)))
                                                          double code(double J, double l, double K, double U) {
                                                          	double tmp;
                                                          	if (cos((K / 2.0)) <= -0.2) {
                                                          		tmp = ((((K * K) * l) * J) * -0.25) + U;
                                                          	} else {
                                                          		tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          real(8) function code(j, l, k, u)
                                                              real(8), intent (in) :: j
                                                              real(8), intent (in) :: l
                                                              real(8), intent (in) :: k
                                                              real(8), intent (in) :: u
                                                              real(8) :: tmp
                                                              if (cos((k / 2.0d0)) <= (-0.2d0)) then
                                                                  tmp = ((((k * k) * l) * j) * (-0.25d0)) + u
                                                              else
                                                                  tmp = ((((l * l) * j) * 0.3333333333333333d0) * l) + u
                                                              end if
                                                              code = tmp
                                                          end function
                                                          
                                                          public static double code(double J, double l, double K, double U) {
                                                          	double tmp;
                                                          	if (Math.cos((K / 2.0)) <= -0.2) {
                                                          		tmp = ((((K * K) * l) * J) * -0.25) + U;
                                                          	} else {
                                                          		tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          def code(J, l, K, U):
                                                          	tmp = 0
                                                          	if math.cos((K / 2.0)) <= -0.2:
                                                          		tmp = ((((K * K) * l) * J) * -0.25) + U
                                                          	else:
                                                          		tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U
                                                          	return tmp
                                                          
                                                          function code(J, l, K, U)
                                                          	tmp = 0.0
                                                          	if (cos(Float64(K / 2.0)) <= -0.2)
                                                          		tmp = Float64(Float64(Float64(Float64(Float64(K * K) * l) * J) * -0.25) + U);
                                                          	else
                                                          		tmp = Float64(Float64(Float64(Float64(Float64(l * l) * J) * 0.3333333333333333) * l) + U);
                                                          	end
                                                          	return tmp
                                                          end
                                                          
                                                          function tmp_2 = code(J, l, K, U)
                                                          	tmp = 0.0;
                                                          	if (cos((K / 2.0)) <= -0.2)
                                                          		tmp = ((((K * K) * l) * J) * -0.25) + U;
                                                          	else
                                                          		tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
                                                          	end
                                                          	tmp_2 = tmp;
                                                          end
                                                          
                                                          code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.2], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(N[(l * l), $MachinePrecision] * J), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision]]
                                                          
                                                          \begin{array}{l}
                                                          
                                                          \\
                                                          \begin{array}{l}
                                                          \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.2:\\
                                                          \;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U\\
                                                          
                                                          
                                                          \end{array}
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 2 regimes
                                                          2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.20000000000000001

                                                            1. Initial program 89.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}{2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
                                                            4. Step-by-step derivation
                                                              1. associate-*r*N/A

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

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

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

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

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

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

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

                                                                \[\leadsto \left(\left(J \cdot \ell\right) \cdot 2\right) \cdot \cos \color{blue}{\left(0.5 \cdot K\right)} + U \]
                                                            5. Applied rewrites57.6%

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

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

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

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

                                                                  \[\leadsto \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U \]

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

                                                                1. Initial program 89.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 K around 0

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

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

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

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

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

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

                                                                    \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                                                                5. Applied rewrites89.3%

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

                                                                    \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                                                                  2. Taylor expanded in l around 0

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

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

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

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

                                                                    Alternative 15: 53.6% accurate, 23.6× speedup?

                                                                    \[\begin{array}{l} \\ \left(2 \cdot \ell\right) \cdot J + U \end{array} \]
                                                                    (FPCore (J l K U) :precision binary64 (+ (* (* 2.0 l) J) U))
                                                                    double code(double J, double l, double K, double U) {
                                                                    	return ((2.0 * l) * J) + U;
                                                                    }
                                                                    
                                                                    real(8) function code(j, l, k, u)
                                                                        real(8), intent (in) :: j
                                                                        real(8), intent (in) :: l
                                                                        real(8), intent (in) :: k
                                                                        real(8), intent (in) :: u
                                                                        code = ((2.0d0 * l) * j) + u
                                                                    end function
                                                                    
                                                                    public static double code(double J, double l, double K, double U) {
                                                                    	return ((2.0 * l) * J) + U;
                                                                    }
                                                                    
                                                                    def code(J, l, K, U):
                                                                    	return ((2.0 * l) * J) + U
                                                                    
                                                                    function code(J, l, K, U)
                                                                    	return Float64(Float64(Float64(2.0 * l) * J) + U)
                                                                    end
                                                                    
                                                                    function tmp = code(J, l, K, U)
                                                                    	tmp = ((2.0 * l) * J) + U;
                                                                    end
                                                                    
                                                                    code[J_, l_, K_, U_] := N[(N[(N[(2.0 * l), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]
                                                                    
                                                                    \begin{array}{l}
                                                                    
                                                                    \\
                                                                    \left(2 \cdot \ell\right) \cdot J + U
                                                                    \end{array}
                                                                    
                                                                    Derivation
                                                                    1. Initial program 89.4%

                                                                      \[\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 K around 0

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

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

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

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

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

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

                                                                        \[\leadsto \left(e^{\ell} - e^{\color{blue}{-\ell}}\right) \cdot J + U \]
                                                                    5. Applied rewrites71.6%

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

                                                                        \[\leadsto \left(\sinh \ell \cdot 2\right) \cdot J + U \]
                                                                      2. Taylor expanded in l around 0

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

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

                                                                        Reproduce

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