Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.6% → 99.8%
Time: 16.7s
Alternatives: 14
Speedup: 1.4×

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 14 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.6% 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.8% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;U + t_1 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, t_0 \cdot t_1, U\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0

    1. Initial program 100.0%

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 4.99999999999999977e-7

    1. Initial program 73.9%

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

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

    if 4.99999999999999977e-7 < (-.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. 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-def100.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)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification100.0%

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

Alternative 2: 99.8% 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 -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{-7}\right):\\ \;\;\;\;t_0 \cdot \left(t_1 \cdot J\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\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 (- INFINITY)) (not (<= t_1 5e-7)))
     (+ (* t_0 (* t_1 J)) U)
     (+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))))
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 <= -((double) INFINITY)) || !(t_1 <= 5e-7)) {
		tmp = (t_0 * (t_1 * J)) + U;
	} else {
		tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	double t_1 = Math.exp(l) - Math.exp(-l);
	double tmp;
	if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e-7)) {
		tmp = (t_0 * (t_1 * J)) + U;
	} else {
		tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = math.exp(l) - math.exp(-l)
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 5e-7):
		tmp = (t_0 * (t_1 * J)) + U
	else:
		tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))
	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 <= Float64(-Inf)) || !(t_1 <= 5e-7))
		tmp = Float64(Float64(t_0 * Float64(t_1 * J)) + U);
	else
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K / 2.0));
	t_1 = exp(l) - exp(-l);
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 5e-7)))
		tmp = (t_0 * (t_1 * J)) + U;
	else
		tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (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]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e-7]], $MachinePrecision]], N[(N[(t$95$0 * N[(t$95$1 * J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{-7}\right):\\
\;\;\;\;t_0 \cdot \left(t_1 \cdot J\right) + U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 4.99999999999999977e-7 < (-.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 \]

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 4.99999999999999977e-7

    1. Initial program 73.9%

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

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

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

Alternative 3: 94.4% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\ell \leq -350:\\
\;\;\;\;U + t_0 \cdot \left(J + -0.125 \cdot \left(K \cdot \left(J \cdot K\right)\right)\right)\\

\mathbf{elif}\;\ell \leq 0.21:\\
\;\;\;\;U + t_1 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\

\mathbf{elif}\;\ell \leq 4.5 \cdot 10^{+68}:\\
\;\;\;\;U + t_0 \cdot J\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -4.4999999999999997e76 or 4.5000000000000003e68 < 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. Taylor expanded in l around 0 95.8%

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

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

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

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

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

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

    if -4.4999999999999997e76 < l < -350

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J + -0.125 \cdot \left({K}^{2} \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\right)\right)} + U \]
    3. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \left(\color{blue}{J \cdot \left(e^{\ell} - e^{-\ell}\right)} + -0.125 \cdot \left({K}^{2} \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\right)\right) + U \]
      2. associate-*r*0.0%

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

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{-\ell}\right) + \left(-0.125 \cdot {K}^{2}\right) \cdot \color{blue}{\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right)}\right) + U \]
      4. associate-*r*0.0%

        \[\leadsto \left(J \cdot \left(e^{\ell} - e^{-\ell}\right) + \color{blue}{\left(\left(-0.125 \cdot {K}^{2}\right) \cdot J\right) \cdot \left(e^{\ell} - e^{-\ell}\right)}\right) + U \]
      5. distribute-rgt-out85.7%

        \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot \left(J + \left(-0.125 \cdot {K}^{2}\right) \cdot J\right)} + U \]
      6. associate-*l*85.7%

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

        \[\leadsto \left(e^{\ell} - e^{-\ell}\right) \cdot \left(J + -0.125 \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot J\right)\right) + U \]
      8. associate-*l*85.7%

        \[\leadsto \left(e^{\ell} - e^{-\ell}\right) \cdot \left(J + -0.125 \cdot \color{blue}{\left(K \cdot \left(K \cdot J\right)\right)}\right) + U \]
    4. Simplified85.7%

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

    if -350 < l < 0.209999999999999992

    1. Initial program 73.9%

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

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

    if 0.209999999999999992 < l < 4.5000000000000003e68

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+76}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq -350:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot \left(J + -0.125 \cdot \left(K \cdot \left(J \cdot K\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 0.21:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 4.5 \cdot 10^{+68}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \end{array} \]

Alternative 4: 94.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ t_1 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{if}\;\ell \leq -2.7 \cdot 10^{+99}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -340:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 0.0062:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 4.5 \cdot 10^{+68}:\\ \;\;\;\;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)) (* (pow l 3.0) (* J 0.3333333333333333)))))
        (t_1 (+ U (* (- (exp l) (exp (- l))) J))))
   (if (<= l -2.7e+99)
     t_0
     (if (<= l -340.0)
       t_1
       (if (<= l 0.0062)
         (+ U (* 2.0 (* l (* J (cos (* K 0.5))))))
         (if (<= l 4.5e+68) t_1 t_0))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (cos((K / 2.0)) * (pow(l, 3.0) * (J * 0.3333333333333333)));
	double t_1 = U + ((exp(l) - exp(-l)) * J);
	double tmp;
	if (l <= -2.7e+99) {
		tmp = t_0;
	} else if (l <= -340.0) {
		tmp = t_1;
	} else if (l <= 0.0062) {
		tmp = U + (2.0 * (l * (J * cos((K * 0.5)))));
	} else if (l <= 4.5e+68) {
		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)) * ((l ** 3.0d0) * (j * 0.3333333333333333d0)))
    t_1 = u + ((exp(l) - exp(-l)) * j)
    if (l <= (-2.7d+99)) then
        tmp = t_0
    else if (l <= (-340.0d0)) then
        tmp = t_1
    else if (l <= 0.0062d0) then
        tmp = u + (2.0d0 * (l * (j * cos((k * 0.5d0)))))
    else if (l <= 4.5d+68) 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)) * (Math.pow(l, 3.0) * (J * 0.3333333333333333)));
	double t_1 = U + ((Math.exp(l) - Math.exp(-l)) * J);
	double tmp;
	if (l <= -2.7e+99) {
		tmp = t_0;
	} else if (l <= -340.0) {
		tmp = t_1;
	} else if (l <= 0.0062) {
		tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
	} else if (l <= 4.5e+68) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (math.cos((K / 2.0)) * (math.pow(l, 3.0) * (J * 0.3333333333333333)))
	t_1 = U + ((math.exp(l) - math.exp(-l)) * J)
	tmp = 0
	if l <= -2.7e+99:
		tmp = t_0
	elif l <= -340.0:
		tmp = t_1
	elif l <= 0.0062:
		tmp = U + (2.0 * (l * (J * math.cos((K * 0.5)))))
	elif l <= 4.5e+68:
		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((l ^ 3.0) * Float64(J * 0.3333333333333333))))
	t_1 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J))
	tmp = 0.0
	if (l <= -2.7e+99)
		tmp = t_0;
	elseif (l <= -340.0)
		tmp = t_1;
	elseif (l <= 0.0062)
		tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5))))));
	elseif (l <= 4.5e+68)
		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)) * ((l ^ 3.0) * (J * 0.3333333333333333)));
	t_1 = U + ((exp(l) - exp(-l)) * J);
	tmp = 0.0;
	if (l <= -2.7e+99)
		tmp = t_0;
	elseif (l <= -340.0)
		tmp = t_1;
	elseif (l <= 0.0062)
		tmp = U + (2.0 * (l * (J * cos((K * 0.5)))));
	elseif (l <= 4.5e+68)
		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[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.7e+99], t$95$0, If[LessEqual[l, -340.0], t$95$1, If[LessEqual[l, 0.0062], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.5e+68], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -340:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\ell \leq 4.5 \cdot 10^{+68}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.69999999999999989e99 or 4.5000000000000003e68 < 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. Taylor expanded in l around 0 96.6%

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

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

        \[\leadsto \color{blue}{\left(\left(0.3333333333333333 \cdot {\ell}^{3}\right) \cdot J\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. *-commutative96.6%

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

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

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

    if -2.69999999999999989e99 < l < -340 or 0.00619999999999999978 < l < 4.5000000000000003e68

    1. Initial program 100.0%

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

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

    if -340 < l < 0.00619999999999999978

    1. Initial program 73.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.7 \cdot 10^{+99}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq -340:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 0.0062:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 4.5 \cdot 10^{+68}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \end{array} \]

Alternative 5: 87.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + K \cdot \left(K \cdot -0.041666666666666664\right)\right)\\ t_1 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{if}\;\ell \leq -6 \cdot 10^{+244}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -340:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 0.0033:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 2 \cdot 10^{+137}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0
         (+
          U
          (*
           (* J (pow l 3.0))
           (+ 0.3333333333333333 (* K (* K -0.041666666666666664))))))
        (t_1 (+ U (* (- (exp l) (exp (- l))) J))))
   (if (<= l -6e+244)
     t_0
     (if (<= l -340.0)
       t_1
       (if (<= l 0.0033)
         (+ U (* 2.0 (* l (* J (cos (* K 0.5))))))
         (if (<= l 2e+137) t_1 t_0))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + ((J * pow(l, 3.0)) * (0.3333333333333333 + (K * (K * -0.041666666666666664))));
	double t_1 = U + ((exp(l) - exp(-l)) * J);
	double tmp;
	if (l <= -6e+244) {
		tmp = t_0;
	} else if (l <= -340.0) {
		tmp = t_1;
	} else if (l <= 0.0033) {
		tmp = U + (2.0 * (l * (J * cos((K * 0.5)))));
	} else if (l <= 2e+137) {
		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 + ((j * (l ** 3.0d0)) * (0.3333333333333333d0 + (k * (k * (-0.041666666666666664d0)))))
    t_1 = u + ((exp(l) - exp(-l)) * j)
    if (l <= (-6d+244)) then
        tmp = t_0
    else if (l <= (-340.0d0)) then
        tmp = t_1
    else if (l <= 0.0033d0) then
        tmp = u + (2.0d0 * (l * (j * cos((k * 0.5d0)))))
    else if (l <= 2d+137) 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 + ((J * Math.pow(l, 3.0)) * (0.3333333333333333 + (K * (K * -0.041666666666666664))));
	double t_1 = U + ((Math.exp(l) - Math.exp(-l)) * J);
	double tmp;
	if (l <= -6e+244) {
		tmp = t_0;
	} else if (l <= -340.0) {
		tmp = t_1;
	} else if (l <= 0.0033) {
		tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
	} else if (l <= 2e+137) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + ((J * math.pow(l, 3.0)) * (0.3333333333333333 + (K * (K * -0.041666666666666664))))
	t_1 = U + ((math.exp(l) - math.exp(-l)) * J)
	tmp = 0
	if l <= -6e+244:
		tmp = t_0
	elif l <= -340.0:
		tmp = t_1
	elif l <= 0.0033:
		tmp = U + (2.0 * (l * (J * math.cos((K * 0.5)))))
	elif l <= 2e+137:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(Float64(J * (l ^ 3.0)) * Float64(0.3333333333333333 + Float64(K * Float64(K * -0.041666666666666664)))))
	t_1 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J))
	tmp = 0.0
	if (l <= -6e+244)
		tmp = t_0;
	elseif (l <= -340.0)
		tmp = t_1;
	elseif (l <= 0.0033)
		tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5))))));
	elseif (l <= 2e+137)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + ((J * (l ^ 3.0)) * (0.3333333333333333 + (K * (K * -0.041666666666666664))));
	t_1 = U + ((exp(l) - exp(-l)) * J);
	tmp = 0.0;
	if (l <= -6e+244)
		tmp = t_0;
	elseif (l <= -340.0)
		tmp = t_1;
	elseif (l <= 0.0033)
		tmp = U + (2.0 * (l * (J * cos((K * 0.5)))));
	elseif (l <= 2e+137)
		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[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 + N[(K * N[(K * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -6e+244], t$95$0, If[LessEqual[l, -340.0], t$95$1, If[LessEqual[l, 0.0033], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2e+137], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + K \cdot \left(K \cdot -0.041666666666666664\right)\right)\\
t_1 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -6 \cdot 10^{+244}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -340:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\ell \leq 2 \cdot 10^{+137}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -5.9999999999999995e244 or 2.0000000000000001e137 < 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. Taylor expanded in l around 0 100.0%

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

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

        \[\leadsto \color{blue}{\left(\left(0.3333333333333333 \cdot {\ell}^{3}\right) \cdot J\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. *-commutative100.0%

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

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

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

      \[\leadsto \color{blue}{\left(-0.041666666666666664 \cdot \left({K}^{2} \cdot \left({\ell}^{3} \cdot J\right)\right) + 0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right)\right)} + U \]
    7. Step-by-step derivation
      1. +-commutative0.0%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + -0.041666666666666664 \cdot \left({K}^{2} \cdot \left({\ell}^{3} \cdot J\right)\right)\right)} + U \]
      2. unpow20.0%

        \[\leadsto \left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + -0.041666666666666664 \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot \left({\ell}^{3} \cdot J\right)\right)\right) + U \]
      3. associate-*r*0.0%

        \[\leadsto \left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + \color{blue}{\left(-0.041666666666666664 \cdot \left(K \cdot K\right)\right) \cdot \left({\ell}^{3} \cdot J\right)}\right) + U \]
      4. distribute-rgt-out86.4%

        \[\leadsto \color{blue}{\left({\ell}^{3} \cdot J\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)} + U \]
      5. associate-*r*86.4%

        \[\leadsto \left({\ell}^{3} \cdot J\right) \cdot \left(0.3333333333333333 + \color{blue}{\left(-0.041666666666666664 \cdot K\right) \cdot K}\right) + U \]
    8. Simplified86.4%

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

    if -5.9999999999999995e244 < l < -340 or 0.0033 < l < 2.0000000000000001e137

    1. Initial program 100.0%

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

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

    if -340 < l < 0.0033

    1. Initial program 73.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6 \cdot 10^{+244}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + K \cdot \left(K \cdot -0.041666666666666664\right)\right)\\ \mathbf{elif}\;\ell \leq -340:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 0.0033:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 2 \cdot 10^{+137}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + K \cdot \left(K \cdot -0.041666666666666664\right)\right)\\ \end{array} \]

Alternative 6: 79.3% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K 2)) < -2e-3

    1. Initial program 86.4%

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

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

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

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

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

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

    if -2e-3 < (cos.f64 (/.f64 K 2))

    1. Initial program 86.2%

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

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

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

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

Alternative 7: 88.2% accurate, 1.4× speedup?

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

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

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

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

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

Alternative 8: 63.1% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{if}\;\ell \leq -9.6 \cdot 10^{+242}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -1.02 \cdot 10^{+39}:\\ \;\;\;\;U + \left|K \cdot \left(J \cdot K\right)\right|\\ \mathbf{elif}\;\ell \leq 620:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ U (* 2.0 (* l (* J (cos (* K 0.5))))))))
   (if (<= l -9.6e+242)
     t_0
     (if (<= l -1.02e+39)
       (+ U (fabs (* K (* J K))))
       (if (<= l 620.0) t_0 (+ U (* (* l J) (+ 2.0 (* (* K K) -0.25)))))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (2.0 * (l * (J * cos((K * 0.5)))));
	double tmp;
	if (l <= -9.6e+242) {
		tmp = t_0;
	} else if (l <= -1.02e+39) {
		tmp = U + fabs((K * (J * K)));
	} else if (l <= 620.0) {
		tmp = t_0;
	} else {
		tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	}
	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 = u + (2.0d0 * (l * (j * cos((k * 0.5d0)))))
    if (l <= (-9.6d+242)) then
        tmp = t_0
    else if (l <= (-1.02d+39)) then
        tmp = u + abs((k * (j * k)))
    else if (l <= 620.0d0) then
        tmp = t_0
    else
        tmp = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
	double tmp;
	if (l <= -9.6e+242) {
		tmp = t_0;
	} else if (l <= -1.02e+39) {
		tmp = U + Math.abs((K * (J * K)));
	} else if (l <= 620.0) {
		tmp = t_0;
	} else {
		tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (2.0 * (l * (J * math.cos((K * 0.5)))))
	tmp = 0
	if l <= -9.6e+242:
		tmp = t_0
	elif l <= -1.02e+39:
		tmp = U + math.fabs((K * (J * K)))
	elif l <= 620.0:
		tmp = t_0
	else:
		tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5))))))
	tmp = 0.0
	if (l <= -9.6e+242)
		tmp = t_0;
	elseif (l <= -1.02e+39)
		tmp = Float64(U + abs(Float64(K * Float64(J * K))));
	elseif (l <= 620.0)
		tmp = t_0;
	else
		tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + (2.0 * (l * (J * cos((K * 0.5)))));
	tmp = 0.0;
	if (l <= -9.6e+242)
		tmp = t_0;
	elseif (l <= -1.02e+39)
		tmp = U + abs((K * (J * K)));
	elseif (l <= 620.0)
		tmp = t_0;
	else
		tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -9.6e+242], t$95$0, If[LessEqual[l, -1.02e+39], N[(U + N[Abs[N[(K * N[(J * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 620.0], t$95$0, N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{if}\;\ell \leq -9.6 \cdot 10^{+242}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -1.02 \cdot 10^{+39}:\\
\;\;\;\;U + \left|K \cdot \left(J \cdot K\right)\right|\\

\mathbf{elif}\;\ell \leq 620:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -9.60000000000000049e242 or -1.02e39 < l < 620

    1. Initial program 77.6%

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

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

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

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

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

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

    if -9.60000000000000049e242 < l < -1.02e39

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{-8}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 16.1%

      \[\leadsto \color{blue}{\left({K}^{2} \cdot J + -8 \cdot J\right)} + U \]
    4. Step-by-step derivation
      1. distribute-rgt-out16.1%

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

        \[\leadsto J \cdot \left(\color{blue}{K \cdot K} + -8\right) + U \]
    5. Simplified16.1%

      \[\leadsto \color{blue}{J \cdot \left(K \cdot K + -8\right)} + U \]
    6. Taylor expanded in K around inf 16.0%

      \[\leadsto \color{blue}{{K}^{2} \cdot J} + U \]
    7. Step-by-step derivation
      1. unpow216.0%

        \[\leadsto \color{blue}{\left(K \cdot K\right)} \cdot J + U \]
      2. *-commutative16.0%

        \[\leadsto \color{blue}{J \cdot \left(K \cdot K\right)} + U \]
    8. Simplified16.0%

      \[\leadsto \color{blue}{J \cdot \left(K \cdot K\right)} + U \]
    9. Step-by-step derivation
      1. add-sqr-sqrt13.2%

        \[\leadsto \color{blue}{\sqrt{J \cdot \left(K \cdot K\right)} \cdot \sqrt{J \cdot \left(K \cdot K\right)}} + U \]
      2. sqrt-unprod34.8%

        \[\leadsto \color{blue}{\sqrt{\left(J \cdot \left(K \cdot K\right)\right) \cdot \left(J \cdot \left(K \cdot K\right)\right)}} + U \]
      3. swap-sqr27.2%

        \[\leadsto \sqrt{\color{blue}{\left(J \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot \left(K \cdot K\right)\right)}} + U \]
      4. pow227.2%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot \left(\color{blue}{{K}^{2}} \cdot \left(K \cdot K\right)\right)} + U \]
      5. pow227.2%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot \left({K}^{2} \cdot \color{blue}{{K}^{2}}\right)} + U \]
      6. pow-prod-up27.2%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot \color{blue}{{K}^{\left(2 + 2\right)}}} + U \]
      7. metadata-eval27.2%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot {K}^{\color{blue}{4}}} + U \]
    10. Applied egg-rr27.2%

      \[\leadsto \color{blue}{\sqrt{\left(J \cdot J\right) \cdot {K}^{4}}} + U \]
    11. Step-by-step derivation
      1. metadata-eval27.2%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot {K}^{\color{blue}{\left(2 \cdot 2\right)}}} + U \]
      2. pow-sqr27.2%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot \color{blue}{\left({K}^{2} \cdot {K}^{2}\right)}} + U \]
      3. unswap-sqr34.8%

        \[\leadsto \sqrt{\color{blue}{\left(J \cdot {K}^{2}\right) \cdot \left(J \cdot {K}^{2}\right)}} + U \]
      4. unpow234.8%

        \[\leadsto \sqrt{\left(J \cdot \color{blue}{\left(K \cdot K\right)}\right) \cdot \left(J \cdot {K}^{2}\right)} + U \]
      5. associate-*r*34.8%

        \[\leadsto \sqrt{\color{blue}{\left(\left(J \cdot K\right) \cdot K\right)} \cdot \left(J \cdot {K}^{2}\right)} + U \]
      6. *-commutative34.8%

        \[\leadsto \sqrt{\color{blue}{\left(K \cdot \left(J \cdot K\right)\right)} \cdot \left(J \cdot {K}^{2}\right)} + U \]
      7. unpow234.8%

        \[\leadsto \sqrt{\left(K \cdot \left(J \cdot K\right)\right) \cdot \left(J \cdot \color{blue}{\left(K \cdot K\right)}\right)} + U \]
      8. associate-*r*32.4%

        \[\leadsto \sqrt{\left(K \cdot \left(J \cdot K\right)\right) \cdot \color{blue}{\left(\left(J \cdot K\right) \cdot K\right)}} + U \]
      9. *-commutative32.4%

        \[\leadsto \sqrt{\left(K \cdot \left(J \cdot K\right)\right) \cdot \color{blue}{\left(K \cdot \left(J \cdot K\right)\right)}} + U \]
      10. rem-sqrt-square32.5%

        \[\leadsto \color{blue}{\left|K \cdot \left(J \cdot K\right)\right|} + U \]
      11. *-commutative32.5%

        \[\leadsto \left|K \cdot \color{blue}{\left(K \cdot J\right)}\right| + U \]
    12. Simplified32.5%

      \[\leadsto \color{blue}{\left|K \cdot \left(K \cdot J\right)\right|} + U \]

    if 620 < 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. Taylor expanded in l around 0 22.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\ell \cdot J\right) \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot -0.25 + 2\right) + U \]
    7. Simplified34.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.6 \cdot 10^{+242}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq -1.02 \cdot 10^{+39}:\\ \;\;\;\;U + \left|K \cdot \left(J \cdot K\right)\right|\\ \mathbf{elif}\;\ell \leq 620:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \end{array} \]

Alternative 9: 56.7% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{if}\;\ell \leq -7.5 \cdot 10^{+242}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -9 \cdot 10^{+67}:\\ \;\;\;\;U + \left|K \cdot \left(J \cdot K\right)\right|\\ \mathbf{elif}\;\ell \leq -3.2 \cdot 10^{+34} \lor \neg \left(\ell \leq 360\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ U (* (* l J) (+ 2.0 (* (* K K) -0.25))))))
   (if (<= l -7.5e+242)
     t_0
     (if (<= l -9e+67)
       (+ U (fabs (* K (* J K))))
       (if (or (<= l -3.2e+34) (not (<= l 360.0)))
         t_0
         (+ U (* 2.0 (* l J))))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	double tmp;
	if (l <= -7.5e+242) {
		tmp = t_0;
	} else if (l <= -9e+67) {
		tmp = U + fabs((K * (J * K)));
	} else if ((l <= -3.2e+34) || !(l <= 360.0)) {
		tmp = t_0;
	} else {
		tmp = U + (2.0 * (l * J));
	}
	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 = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
    if (l <= (-7.5d+242)) then
        tmp = t_0
    else if (l <= (-9d+67)) then
        tmp = u + abs((k * (j * k)))
    else if ((l <= (-3.2d+34)) .or. (.not. (l <= 360.0d0))) then
        tmp = t_0
    else
        tmp = u + (2.0d0 * (l * j))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	double tmp;
	if (l <= -7.5e+242) {
		tmp = t_0;
	} else if (l <= -9e+67) {
		tmp = U + Math.abs((K * (J * K)));
	} else if ((l <= -3.2e+34) || !(l <= 360.0)) {
		tmp = t_0;
	} else {
		tmp = U + (2.0 * (l * J));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + ((l * J) * (2.0 + ((K * K) * -0.25)))
	tmp = 0
	if l <= -7.5e+242:
		tmp = t_0
	elif l <= -9e+67:
		tmp = U + math.fabs((K * (J * K)))
	elif (l <= -3.2e+34) or not (l <= 360.0):
		tmp = t_0
	else:
		tmp = U + (2.0 * (l * J))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25))))
	tmp = 0.0
	if (l <= -7.5e+242)
		tmp = t_0;
	elseif (l <= -9e+67)
		tmp = Float64(U + abs(Float64(K * Float64(J * K))));
	elseif ((l <= -3.2e+34) || !(l <= 360.0))
		tmp = t_0;
	else
		tmp = Float64(U + Float64(2.0 * Float64(l * J)));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	tmp = 0.0;
	if (l <= -7.5e+242)
		tmp = t_0;
	elseif (l <= -9e+67)
		tmp = U + abs((K * (J * K)));
	elseif ((l <= -3.2e+34) || ~((l <= 360.0)))
		tmp = t_0;
	else
		tmp = U + (2.0 * (l * J));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -7.5e+242], t$95$0, If[LessEqual[l, -9e+67], N[(U + N[Abs[N[(K * N[(J * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, -3.2e+34], N[Not[LessEqual[l, 360.0]], $MachinePrecision]], t$95$0, N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{+242}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -9 \cdot 10^{+67}:\\
\;\;\;\;U + \left|K \cdot \left(J \cdot K\right)\right|\\

\mathbf{elif}\;\ell \leq -3.2 \cdot 10^{+34} \lor \neg \left(\ell \leq 360\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -7.49999999999999961e242 or -8.9999999999999997e67 < l < -3.1999999999999998e34 or 360 < 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. Taylor expanded in l around 0 29.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.49999999999999961e242 < l < -8.9999999999999997e67

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{-8}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 13.0%

      \[\leadsto \color{blue}{\left({K}^{2} \cdot J + -8 \cdot J\right)} + U \]
    4. Step-by-step derivation
      1. distribute-rgt-out13.0%

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

        \[\leadsto J \cdot \left(\color{blue}{K \cdot K} + -8\right) + U \]
    5. Simplified13.0%

      \[\leadsto \color{blue}{J \cdot \left(K \cdot K + -8\right)} + U \]
    6. Taylor expanded in K around inf 12.9%

      \[\leadsto \color{blue}{{K}^{2} \cdot J} + U \]
    7. Step-by-step derivation
      1. unpow212.9%

        \[\leadsto \color{blue}{\left(K \cdot K\right)} \cdot J + U \]
      2. *-commutative12.9%

        \[\leadsto \color{blue}{J \cdot \left(K \cdot K\right)} + U \]
    8. Simplified12.9%

      \[\leadsto \color{blue}{J \cdot \left(K \cdot K\right)} + U \]
    9. Step-by-step derivation
      1. add-sqr-sqrt9.7%

        \[\leadsto \color{blue}{\sqrt{J \cdot \left(K \cdot K\right)} \cdot \sqrt{J \cdot \left(K \cdot K\right)}} + U \]
      2. sqrt-unprod35.6%

        \[\leadsto \color{blue}{\sqrt{\left(J \cdot \left(K \cdot K\right)\right) \cdot \left(J \cdot \left(K \cdot K\right)\right)}} + U \]
      3. swap-sqr26.7%

        \[\leadsto \sqrt{\color{blue}{\left(J \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot \left(K \cdot K\right)\right)}} + U \]
      4. pow226.7%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot \left(\color{blue}{{K}^{2}} \cdot \left(K \cdot K\right)\right)} + U \]
      5. pow226.7%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot \left({K}^{2} \cdot \color{blue}{{K}^{2}}\right)} + U \]
      6. pow-prod-up26.7%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot \color{blue}{{K}^{\left(2 + 2\right)}}} + U \]
      7. metadata-eval26.7%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot {K}^{\color{blue}{4}}} + U \]
    10. Applied egg-rr26.7%

      \[\leadsto \color{blue}{\sqrt{\left(J \cdot J\right) \cdot {K}^{4}}} + U \]
    11. Step-by-step derivation
      1. metadata-eval26.7%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot {K}^{\color{blue}{\left(2 \cdot 2\right)}}} + U \]
      2. pow-sqr26.7%

        \[\leadsto \sqrt{\left(J \cdot J\right) \cdot \color{blue}{\left({K}^{2} \cdot {K}^{2}\right)}} + U \]
      3. unswap-sqr35.6%

        \[\leadsto \sqrt{\color{blue}{\left(J \cdot {K}^{2}\right) \cdot \left(J \cdot {K}^{2}\right)}} + U \]
      4. unpow235.6%

        \[\leadsto \sqrt{\left(J \cdot \color{blue}{\left(K \cdot K\right)}\right) \cdot \left(J \cdot {K}^{2}\right)} + U \]
      5. associate-*r*35.6%

        \[\leadsto \sqrt{\color{blue}{\left(\left(J \cdot K\right) \cdot K\right)} \cdot \left(J \cdot {K}^{2}\right)} + U \]
      6. *-commutative35.6%

        \[\leadsto \sqrt{\color{blue}{\left(K \cdot \left(J \cdot K\right)\right)} \cdot \left(J \cdot {K}^{2}\right)} + U \]
      7. unpow235.6%

        \[\leadsto \sqrt{\left(K \cdot \left(J \cdot K\right)\right) \cdot \left(J \cdot \color{blue}{\left(K \cdot K\right)}\right)} + U \]
      8. associate-*r*32.8%

        \[\leadsto \sqrt{\left(K \cdot \left(J \cdot K\right)\right) \cdot \color{blue}{\left(\left(J \cdot K\right) \cdot K\right)}} + U \]
      9. *-commutative32.8%

        \[\leadsto \sqrt{\left(K \cdot \left(J \cdot K\right)\right) \cdot \color{blue}{\left(K \cdot \left(J \cdot K\right)\right)}} + U \]
      10. rem-sqrt-square32.8%

        \[\leadsto \color{blue}{\left|K \cdot \left(J \cdot K\right)\right|} + U \]
      11. *-commutative32.8%

        \[\leadsto \left|K \cdot \color{blue}{\left(K \cdot J\right)}\right| + U \]
    12. Simplified32.8%

      \[\leadsto \color{blue}{\left|K \cdot \left(K \cdot J\right)\right|} + U \]

    if -3.1999999999999998e34 < l < 360

    1. Initial program 74.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.5 \cdot 10^{+242}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq -9 \cdot 10^{+67}:\\ \;\;\;\;U + \left|K \cdot \left(J \cdot K\right)\right|\\ \mathbf{elif}\;\ell \leq -3.2 \cdot 10^{+34} \lor \neg \left(\ell \leq 360\right):\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \end{array} \]

Alternative 10: 59.1% accurate, 18.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.3 \cdot 10^{+34} \lor \neg \left(\ell \leq 255\right):\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.2999999999999998e34 or 255 < 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. Taylor expanded in l around 0 25.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\ell \cdot J\right) \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot -0.25 + 2\right) + U \]
    7. Simplified34.0%

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

    if -2.2999999999999998e34 < l < 255

    1. Initial program 74.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.3 \cdot 10^{+34} \lor \neg \left(\ell \leq 255\right):\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \end{array} \]

Alternative 11: 53.7% accurate, 44.6× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto 2 \cdot \left(\ell \cdot \color{blue}{J}\right) + U \]
  6. Final simplification54.1%

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

Alternative 12: 40.1% accurate, 61.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 280000:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \end{array} \]
(FPCore (J l K U) :precision binary64 (if (<= l 280000.0) U (* U U)))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 280000.0) {
		tmp = U;
	} else {
		tmp = 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 <= 280000.0d0) then
        tmp = u
    else
        tmp = u * u
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 280000.0) {
		tmp = U;
	} else {
		tmp = U * U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= 280000.0:
		tmp = U
	else:
		tmp = U * U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= 280000.0)
		tmp = U;
	else
		tmp = Float64(U * U);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= 280000.0)
		tmp = U;
	else
		tmp = U * U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, 280000.0], U, N[(U * U), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 280000:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 2.8e5

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

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

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

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

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

    if 2.8e5 < 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-def100.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. Applied egg-rr15.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 280000:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]

Alternative 13: 2.8% accurate, 312.0× speedup?

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

\\
1
\end{array}
Derivation
  1. Initial program 86.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*86.2%

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

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

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

    \[\leadsto \color{blue}{\frac{-8 - U}{-8 - U}} \]
  5. Step-by-step derivation
    1. *-inverses2.8%

      \[\leadsto \color{blue}{1} \]
  6. Simplified2.8%

    \[\leadsto \color{blue}{1} \]
  7. Final simplification2.8%

    \[\leadsto 1 \]

Alternative 14: 37.0% 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 86.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*86.2%

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

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

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

    \[\leadsto \color{blue}{U} \]
  5. Final simplification39.5%

    \[\leadsto U \]

Reproduce

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