Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.1% → 99.7%
Time: 10.2s
Alternatives: 15
Speedup: 2.7×

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.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
	return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
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.7% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_1 \leq -20000 \lor \neg \left(t\_1 \leq 5 \cdot 10^{-11}\right):\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, t\_0 \cdot \left(\ell \cdot 2\right), U\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -2e4 or 5.00000000000000018e-11 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

    if -2e4 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.00000000000000018e-11

    1. Initial program 66.6%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*66.6%

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\left(\ell \cdot 2\right)} \cdot \cos \left(\frac{K}{2}\right), U\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification100.0%

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

Alternative 2: 77.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -0.53:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + {K}^{2} \cdot -0.25\right)\right)\\ \mathbf{elif}\;t\_0 \leq 0.0041:\\ \;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 -0.53)
     (+ U (* J (* l (+ 2.0 (* (pow K 2.0) -0.25)))))
     (if (<= t_0 0.0041)
       (+ U (* t_0 (* l (* J 2.0))))
       (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double tmp;
	if (t_0 <= -0.53) {
		tmp = U + (J * (l * (2.0 + (pow(K, 2.0) * -0.25))));
	} else if (t_0 <= 0.0041) {
		tmp = U + (t_0 * (l * (J * 2.0)));
	} else {
		tmp = U + (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0)))));
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    if (t_0 <= (-0.53d0)) then
        tmp = u + (j * (l * (2.0d0 + ((k ** 2.0d0) * (-0.25d0)))))
    else if (t_0 <= 0.0041d0) then
        tmp = u + (t_0 * (l * (j * 2.0d0)))
    else
        tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0)))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	double tmp;
	if (t_0 <= -0.53) {
		tmp = U + (J * (l * (2.0 + (Math.pow(K, 2.0) * -0.25))));
	} else if (t_0 <= 0.0041) {
		tmp = U + (t_0 * (l * (J * 2.0)));
	} else {
		tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if t_0 <= -0.53:
		tmp = U + (J * (l * (2.0 + (math.pow(K, 2.0) * -0.25))))
	elif t_0 <= 0.0041:
		tmp = U + (t_0 * (l * (J * 2.0)))
	else:
		tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= -0.53)
		tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64((K ^ 2.0) * -0.25)))));
	elseif (t_0 <= 0.0041)
		tmp = Float64(U + Float64(t_0 * Float64(l * Float64(J * 2.0))));
	else
		tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K / 2.0));
	tmp = 0.0;
	if (t_0 <= -0.53)
		tmp = U + (J * (l * (2.0 + ((K ^ 2.0) * -0.25))));
	elseif (t_0 <= 0.0041)
		tmp = U + (t_0 * (l * (J * 2.0)));
	else
		tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))));
	end
	tmp_2 = 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.53], N[(U + N[(J * N[(l * N[(2.0 + N[(N[Power[K, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0041], N[(U + N[(t$95$0 * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.53:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + {K}^{2} \cdot -0.25\right)\right)\\

\mathbf{elif}\;t\_0 \leq 0.0041:\\
\;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\

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


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

    1. Initial program 86.1%

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

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

        \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) \cdot 2} + U \]
      2. associate-*l*58.3%

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

        \[\leadsto J \cdot \left(\color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot \ell\right)} \cdot 2\right) + U \]
      4. associate-*l*58.3%

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

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

      \[\leadsto J \cdot \color{blue}{\left(-0.25 \cdot \left({K}^{2} \cdot \ell\right) + 2 \cdot \ell\right)} + U \]
    7. Step-by-step derivation
      1. associate-*r*74.2%

        \[\leadsto J \cdot \left(\color{blue}{\left(-0.25 \cdot {K}^{2}\right) \cdot \ell} + 2 \cdot \ell\right) + U \]
      2. distribute-rgt-out74.2%

        \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(-0.25 \cdot {K}^{2} + 2\right)\right)} + U \]
      3. *-commutative74.2%

        \[\leadsto J \cdot \left(\ell \cdot \left(\color{blue}{{K}^{2} \cdot -0.25} + 2\right)\right) + U \]
    8. Simplified74.2%

      \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left({K}^{2} \cdot -0.25 + 2\right)\right)} + U \]

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

    1. Initial program 77.1%

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

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

        \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. *-commutative67.7%

        \[\leadsto \left(\color{blue}{\left(J \cdot 2\right)} \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Simplified67.7%

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

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

    1. Initial program 84.9%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Taylor expanded in K around 0 82.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.53:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + {K}^{2} \cdot -0.25\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq 0.0041:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 95.2% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
t_1 := \cos \left(\frac{K}{2}\right)\\
t_2 := U + t\_1 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\
\mathbf{if}\;\ell \leq -9 \cdot 10^{+87}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\ell \leq -6.6:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq 7:\\
\;\;\;\;\mathsf{fma}\left(J, t\_1 \cdot \left(\ell \cdot 2\right), U\right)\\

\mathbf{elif}\;\ell \leq 2.7 \cdot 10^{+100}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -9.0000000000000005e87 or 2.69999999999999998e100 < l

    1. Initial program 100.0%

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

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Applied egg-rr99.0%

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

    if -9.0000000000000005e87 < l < -6.5999999999999996 or 7 < l < 2.69999999999999998e100

    1. Initial program 100.0%

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

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

    if -6.5999999999999996 < l < 7

    1. Initial program 67.2%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*67.2%

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\left(\ell \cdot 2\right)} \cdot \cos \left(\frac{K}{2}\right), U\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9 \cdot 10^{+87}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq -6.6:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 7:\\ \;\;\;\;\mathsf{fma}\left(J, \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot 2\right), U\right)\\ \mathbf{elif}\;\ell \leq 2.7 \cdot 10^{+100}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 95.2% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{if}\;\ell \leq -8.5 \cdot 10^{+87}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq -6.6:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq 0.55:\\ \;\;\;\;U + J \cdot \left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+100}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0
         (+
          U
          (*
           (cos (/ K 2.0))
           (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))
        (t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
   (if (<= l -8.5e+87)
     t_0
     (if (<= l -6.6)
       t_1
       (if (<= l 0.55)
         (+ U (* J (* (* l 2.0) (cos (* K 0.5)))))
         (if (<= l 1.55e+100) t_1 t_0))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	double t_1 = ((exp(l) - exp(-l)) * J) + U;
	double tmp;
	if (l <= -8.5e+87) {
		tmp = t_0;
	} else if (l <= -6.6) {
		tmp = t_1;
	} else if (l <= 0.55) {
		tmp = U + (J * ((l * 2.0) * cos((K * 0.5))));
	} else if (l <= 1.55e+100) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
    t_1 = ((exp(l) - exp(-l)) * j) + u
    if (l <= (-8.5d+87)) then
        tmp = t_0
    else if (l <= (-6.6d0)) then
        tmp = t_1
    else if (l <= 0.55d0) then
        tmp = u + (j * ((l * 2.0d0) * cos((k * 0.5d0))))
    else if (l <= 1.55d+100) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
	double tmp;
	if (l <= -8.5e+87) {
		tmp = t_0;
	} else if (l <= -6.6) {
		tmp = t_1;
	} else if (l <= 0.55) {
		tmp = U + (J * ((l * 2.0) * Math.cos((K * 0.5))));
	} else if (l <= 1.55e+100) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))))
	t_1 = ((math.exp(l) - math.exp(-l)) * J) + U
	tmp = 0
	if l <= -8.5e+87:
		tmp = t_0
	elif l <= -6.6:
		tmp = t_1
	elif l <= 0.55:
		tmp = U + (J * ((l * 2.0) * math.cos((K * 0.5))))
	elif l <= 1.55e+100:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l)))))))
	t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U)
	tmp = 0.0
	if (l <= -8.5e+87)
		tmp = t_0;
	elseif (l <= -6.6)
		tmp = t_1;
	elseif (l <= 0.55)
		tmp = Float64(U + Float64(J * Float64(Float64(l * 2.0) * cos(Float64(K * 0.5)))));
	elseif (l <= 1.55e+100)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	t_1 = ((exp(l) - exp(-l)) * J) + U;
	tmp = 0.0;
	if (l <= -8.5e+87)
		tmp = t_0;
	elseif (l <= -6.6)
		tmp = t_1;
	elseif (l <= 0.55)
		tmp = U + (J * ((l * 2.0) * cos((K * 0.5))));
	elseif (l <= 1.55e+100)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -8.5e+87], t$95$0, If[LessEqual[l, -6.6], t$95$1, If[LessEqual[l, 0.55], N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.55e+100], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -6.6:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\ell \leq 0.55:\\
\;\;\;\;U + J \cdot \left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\

\mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+100}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -8.5000000000000001e87 or 1.55000000000000003e100 < l

    1. Initial program 100.0%

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

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Applied egg-rr99.0%

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

    if -8.5000000000000001e87 < l < -6.5999999999999996 or 0.55000000000000004 < l < 1.55000000000000003e100

    1. Initial program 100.0%

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

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

    if -6.5999999999999996 < l < 0.55000000000000004

    1. Initial program 67.2%

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

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

        \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) \cdot 2} + U \]
      2. associate-*l*99.3%

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

        \[\leadsto J \cdot \left(\color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot \ell\right)} \cdot 2\right) + U \]
      4. associate-*l*99.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -8.5 \cdot 10^{+87}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq -6.6:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 0.55:\\ \;\;\;\;U + J \cdot \left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+100}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 97.6% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\ell \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(J, t\_1 \cdot \left(\ell \cdot 2\right), U\right)\\

\mathbf{elif}\;\ell \leq 3 \cdot 10^{+100}:\\
\;\;\;\;\left(e^{\ell} - t\_0\right) \cdot J + U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -6.5999999999999996

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Add Preprocessing
    3. Applied egg-rr99.0%

      \[\leadsto \left(J \cdot \left(\color{blue}{27} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]

    if -6.5999999999999996 < l < 0.599999999999999978

    1. Initial program 67.2%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*67.2%

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

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

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

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

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

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

    if 0.599999999999999978 < l < 2.99999999999999985e100

    1. Initial program 100.0%

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

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

    if 2.99999999999999985e100 < l

    1. Initial program 100.0%

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

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

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Applied egg-rr100.0%

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Recombined 4 regimes into one program.
  4. Final simplification97.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6.6:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(27 - e^{-\ell}\right)\right)\\ \mathbf{elif}\;\ell \leq 0.6:\\ \;\;\;\;\mathsf{fma}\left(J, \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot 2\right), U\right)\\ \mathbf{elif}\;\ell \leq 3 \cdot 10^{+100}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 79.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.0041:\\ \;\;\;\;U + J \cdot \left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= (cos (/ K 2.0)) 0.0041)
   (+ U (* J (* (* l 2.0) (cos (* K 0.5)))))
   (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (cos((K / 2.0)) <= 0.0041) {
		tmp = U + (J * ((l * 2.0) * cos((K * 0.5))));
	} else {
		tmp = U + (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0)))));
	}
	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.0041d0) then
        tmp = u + (j * ((l * 2.0d0) * cos((k * 0.5d0))))
    else
        tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0)))))
    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.0041) {
		tmp = U + (J * ((l * 2.0) * Math.cos((K * 0.5))));
	} else {
		tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if math.cos((K / 2.0)) <= 0.0041:
		tmp = U + (J * ((l * 2.0) * math.cos((K * 0.5))))
	else:
		tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (cos(Float64(K / 2.0)) <= 0.0041)
		tmp = Float64(U + Float64(J * Float64(Float64(l * 2.0) * cos(Float64(K * 0.5)))));
	else
		tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (cos((K / 2.0)) <= 0.0041)
		tmp = U + (J * ((l * 2.0) * cos((K * 0.5))));
	else
		tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.0041], N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 82.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 61.8%

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

        \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) \cdot 2} + U \]
      2. associate-*l*61.8%

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

        \[\leadsto J \cdot \left(\color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot \ell\right)} \cdot 2\right) + U \]
      4. associate-*l*61.8%

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

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

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

    1. Initial program 84.9%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Taylor expanded in K around 0 82.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.0041:\\ \;\;\;\;U + J \cdot \left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 87.4% accurate, 2.7× speedup?

\[\begin{array}{l} \\ U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ U (* (cos (/ K 2.0)) (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))
double code(double J, double l, double K, double U) {
	return U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
}
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 = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
end function
public static double code(double J, double l, double K, double U) {
	return U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
}
def code(J, l, K, U):
	return U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))))
function code(J, l, K, U)
	return Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l)))))))
end
function tmp = code(J, l, K, U)
	tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
end
code[J_, l_, K_, U_] := N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 84.2%

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

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

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  5. Applied egg-rr89.5%

    \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  6. Final simplification89.5%

    \[\leadsto U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \]
  7. Add Preprocessing

Alternative 8: 64.1% accurate, 2.8× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) \cdot 2} + U \]
    2. associate-*l*62.2%

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

      \[\leadsto J \cdot \left(\color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot \ell\right)} \cdot 2\right) + U \]
    4. associate-*l*62.2%

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

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

    \[\leadsto U + J \cdot \left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right) \]
  7. Add Preprocessing

Alternative 9: 42.9% accurate, 20.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.35 \cdot 10^{+28}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 1020:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-4 - U \cdot U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -1.35e+28) (* U (- U -4.0)) (if (<= l 1020.0) U (- -4.0 (* U U)))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -1.35e+28) {
		tmp = U * (U - -4.0);
	} else if (l <= 1020.0) {
		tmp = U;
	} else {
		tmp = -4.0 - (U * 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 (l <= (-1.35d+28)) then
        tmp = u * (u - (-4.0d0))
    else if (l <= 1020.0d0) then
        tmp = u
    else
        tmp = (-4.0d0) - (u * u)
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -1.35e+28) {
		tmp = U * (U - -4.0);
	} else if (l <= 1020.0) {
		tmp = U;
	} else {
		tmp = -4.0 - (U * U);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -1.35e+28:
		tmp = U * (U - -4.0)
	elif l <= 1020.0:
		tmp = U
	else:
		tmp = -4.0 - (U * U)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -1.35e+28)
		tmp = Float64(U * Float64(U - -4.0));
	elseif (l <= 1020.0)
		tmp = U;
	else
		tmp = Float64(-4.0 - Float64(U * U));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -1.35e+28)
		tmp = U * (U - -4.0);
	elseif (l <= 1020.0)
		tmp = U;
	else
		tmp = -4.0 - (U * U);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.35e+28], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1020.0], U, N[(-4.0 - N[(U * U), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.35 \cdot 10^{+28}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

\mathbf{elif}\;\ell \leq 1020:\\
\;\;\;\;U\\

\mathbf{else}:\\
\;\;\;\;-4 - U \cdot U\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.3500000000000001e28

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*100.0%

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

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

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

      \[\leadsto \color{blue}{U \cdot \left(U - -4\right)} \]

    if -1.3500000000000001e28 < l < 1020

    1. Initial program 68.9%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*68.9%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in J around 0 62.8%

      \[\leadsto \color{blue}{U} \]

    if 1020 < l

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*100.0%

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

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

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

      \[\leadsto \color{blue}{-4 + \left(-U\right) \cdot U} \]
    6. Step-by-step derivation
      1. cancel-sign-sub-inv18.4%

        \[\leadsto \color{blue}{-4 - U \cdot U} \]
    7. Simplified18.4%

      \[\leadsto \color{blue}{-4 - U \cdot U} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 42.8% accurate, 20.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.35 \cdot 10^{+28}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 0.54:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(2 - U\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -1.35e+28) (* U (- U -4.0)) (if (<= l 0.54) U (* U (- 2.0 U)))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -1.35e+28) {
		tmp = U * (U - -4.0);
	} else if (l <= 0.54) {
		tmp = U;
	} else {
		tmp = U * (2.0 - 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 (l <= (-1.35d+28)) then
        tmp = u * (u - (-4.0d0))
    else if (l <= 0.54d0) then
        tmp = u
    else
        tmp = u * (2.0d0 - u)
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -1.35e+28) {
		tmp = U * (U - -4.0);
	} else if (l <= 0.54) {
		tmp = U;
	} else {
		tmp = U * (2.0 - U);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -1.35e+28:
		tmp = U * (U - -4.0)
	elif l <= 0.54:
		tmp = U
	else:
		tmp = U * (2.0 - U)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -1.35e+28)
		tmp = Float64(U * Float64(U - -4.0));
	elseif (l <= 0.54)
		tmp = U;
	else
		tmp = Float64(U * Float64(2.0 - U));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -1.35e+28)
		tmp = U * (U - -4.0);
	elseif (l <= 0.54)
		tmp = U;
	else
		tmp = U * (2.0 - U);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.35e+28], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.54], U, N[(U * N[(2.0 - U), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.35 \cdot 10^{+28}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

\mathbf{elif}\;\ell \leq 0.54:\\
\;\;\;\;U\\

\mathbf{else}:\\
\;\;\;\;U \cdot \left(2 - U\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.3500000000000001e28

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*100.0%

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

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

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

      \[\leadsto \color{blue}{U \cdot \left(U - -4\right)} \]

    if -1.3500000000000001e28 < l < 0.54000000000000004

    1. Initial program 68.7%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*68.7%

        \[\leadsto \color{blue}{J \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
      2. fma-define68.7%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in J around 0 63.3%

      \[\leadsto \color{blue}{U} \]

    if 0.54000000000000004 < l

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*100.0%

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

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

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

      \[\leadsto \color{blue}{U + \mathsf{fma}\left(-U, U, U\right)} \]
    6. Taylor expanded in U around 0 18.0%

      \[\leadsto \color{blue}{U \cdot \left(2 + -1 \cdot U\right)} \]
    7. Step-by-step derivation
      1. mul-1-neg18.0%

        \[\leadsto U \cdot \left(2 + \color{blue}{\left(-U\right)}\right) \]
      2. unsub-neg18.0%

        \[\leadsto U \cdot \color{blue}{\left(2 - U\right)} \]
    8. Simplified18.0%

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

Alternative 11: 42.7% accurate, 20.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -6.6 \cdot 10^{+35}:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq 0.54:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(2 - U\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -6.6e+35) (* U U) (if (<= l 0.54) U (* U (- 2.0 U)))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -6.6e+35) {
		tmp = U * U;
	} else if (l <= 0.54) {
		tmp = U;
	} else {
		tmp = U * (2.0 - 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 (l <= (-6.6d+35)) then
        tmp = u * u
    else if (l <= 0.54d0) then
        tmp = u
    else
        tmp = u * (2.0d0 - u)
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -6.6e+35) {
		tmp = U * U;
	} else if (l <= 0.54) {
		tmp = U;
	} else {
		tmp = U * (2.0 - U);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -6.6e+35:
		tmp = U * U
	elif l <= 0.54:
		tmp = U
	else:
		tmp = U * (2.0 - U)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -6.6e+35)
		tmp = Float64(U * U);
	elseif (l <= 0.54)
		tmp = U;
	else
		tmp = Float64(U * Float64(2.0 - U));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -6.6e+35)
		tmp = U * U;
	elseif (l <= 0.54)
		tmp = U;
	else
		tmp = U * (2.0 - U);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -6.6e+35], N[(U * U), $MachinePrecision], If[LessEqual[l, 0.54], U, N[(U * N[(2.0 - U), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.6 \cdot 10^{+35}:\\
\;\;\;\;U \cdot U\\

\mathbf{elif}\;\ell \leq 0.54:\\
\;\;\;\;U\\

\mathbf{else}:\\
\;\;\;\;U \cdot \left(2 - U\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -6.6000000000000003e35

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*100.0%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Applied egg-rr24.7%

      \[\leadsto \color{blue}{U \cdot U} \]

    if -6.6000000000000003e35 < l < 0.54000000000000004

    1. Initial program 68.9%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*68.9%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in J around 0 62.8%

      \[\leadsto \color{blue}{U} \]

    if 0.54000000000000004 < l

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*100.0%

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

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

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

      \[\leadsto \color{blue}{U + \mathsf{fma}\left(-U, U, U\right)} \]
    6. Taylor expanded in U around 0 18.0%

      \[\leadsto \color{blue}{U \cdot \left(2 + -1 \cdot U\right)} \]
    7. Step-by-step derivation
      1. mul-1-neg18.0%

        \[\leadsto U \cdot \left(2 + \color{blue}{\left(-U\right)}\right) \]
      2. unsub-neg18.0%

        \[\leadsto U \cdot \color{blue}{\left(2 - U\right)} \]
    8. Simplified18.0%

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

Alternative 12: 42.8% accurate, 23.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -6.6 \cdot 10^{+35} \lor \neg \left(\ell \leq 15000\right):\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -6.6e+35) (not (<= l 15000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -6.6e+35) || !(l <= 15000.0)) {
		tmp = U * U;
	} else {
		tmp = 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 ((l <= (-6.6d+35)) .or. (.not. (l <= 15000.0d0))) then
        tmp = u * u
    else
        tmp = u
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -6.6e+35) || !(l <= 15000.0)) {
		tmp = U * U;
	} else {
		tmp = U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -6.6e+35) or not (l <= 15000.0):
		tmp = U * U
	else:
		tmp = U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -6.6e+35) || !(l <= 15000.0))
		tmp = Float64(U * U);
	else
		tmp = U;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if ((l <= -6.6e+35) || ~((l <= 15000.0)))
		tmp = U * U;
	else
		tmp = U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -6.6e+35], N[Not[LessEqual[l, 15000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.6 \cdot 10^{+35} \lor \neg \left(\ell \leq 15000\right):\\
\;\;\;\;U \cdot U\\

\mathbf{else}:\\
\;\;\;\;U\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -6.6000000000000003e35 or 15000 < l

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*100.0%

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

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

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

      \[\leadsto \color{blue}{U \cdot U} \]

    if -6.6000000000000003e35 < l < 15000

    1. Initial program 69.4%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*69.4%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in J around 0 61.9%

      \[\leadsto \color{blue}{U} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification41.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6.6 \cdot 10^{+35} \lor \neg \left(\ell \leq 15000\right):\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 54.5% accurate, 44.6× speedup?

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

\\
U + \ell \cdot \left(J \cdot 2\right)
\end{array}
Derivation
  1. Initial program 84.2%

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

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

      \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) \cdot 2} + U \]
    2. associate-*l*62.2%

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

      \[\leadsto J \cdot \left(\color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot \ell\right)} \cdot 2\right) + U \]
    4. associate-*l*62.2%

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

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

    \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} + U \]
  7. Step-by-step derivation
    1. associate-*r*50.5%

      \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \ell} + U \]
    2. *-commutative50.5%

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

    \[\leadsto \color{blue}{\ell \cdot \left(2 \cdot J\right)} + U \]
  9. Final simplification50.5%

    \[\leadsto U + \ell \cdot \left(J \cdot 2\right) \]
  10. Add Preprocessing

Alternative 14: 37.1% accurate, 312.0× speedup?

\[\begin{array}{l} \\ U \end{array} \]
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
	return U;
}
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 = u
end function
public static double code(double J, double l, double K, double U) {
	return U;
}
def code(J, l, K, U):
	return U
function code(J, l, K, U)
	return U
end
function tmp = code(J, l, K, U)
	tmp = U;
end
code[J_, l_, K_, U_] := U
\begin{array}{l}

\\
U
\end{array}
Derivation
  1. Initial program 84.2%

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Step-by-step derivation
    1. associate-*l*84.2%

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in J around 0 33.0%

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

Alternative 15: 2.7% accurate, 312.0× speedup?

\[\begin{array}{l} \\ -4 \end{array} \]
(FPCore (J l K U) :precision binary64 -4.0)
double code(double J, double l, double K, double U) {
	return -4.0;
}
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 = -4.0d0
end function
public static double code(double J, double l, double K, double U) {
	return -4.0;
}
def code(J, l, K, U):
	return -4.0
function code(J, l, K, U)
	return -4.0
end
function tmp = code(J, l, K, U)
	tmp = -4.0;
end
code[J_, l_, K_, U_] := -4.0
\begin{array}{l}

\\
-4
\end{array}
Derivation
  1. Initial program 84.2%

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Step-by-step derivation
    1. associate-*l*84.2%

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

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

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

    \[\leadsto \color{blue}{-4 + U} \]
  6. Step-by-step derivation
    1. +-commutative24.0%

      \[\leadsto \color{blue}{U + -4} \]
  7. Simplified24.0%

    \[\leadsto \color{blue}{U + -4} \]
  8. Taylor expanded in U around 0 2.7%

    \[\leadsto \color{blue}{-4} \]
  9. Add Preprocessing

Reproduce

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