Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.1% → 99.7%
Time: 14.7s
Alternatives: 21
Speedup: 1.5×

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 21 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 -\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 67.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 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 2: 77.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{if}\;t_0 \leq -0.985:\\ \;\;\;\;U + \left(J \cdot 2\right) \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;t_0 \leq -0.9:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -0.82:\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;t_0 \leq -0.01:\\ \;\;\;\;t_1\\ \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
 (let* ((t_0 (cos (/ K 2.0)))
        (t_1 (+ U (* (* l J) (+ 2.0 (* (* K K) -0.25))))))
   (if (<= t_0 -0.985)
     (+ U (* (* J 2.0) (* l (cos (* K 0.5)))))
     (if (<= t_0 -0.9)
       t_1
       (if (<= t_0 -0.82)
         (+ U (* t_0 (* J (* l 2.0))))
         (if (<= t_0 -0.01)
           t_1
           (+ U (* 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 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	double tmp;
	if (t_0 <= -0.985) {
		tmp = U + ((J * 2.0) * (l * cos((K * 0.5))));
	} else if (t_0 <= -0.9) {
		tmp = t_1;
	} else if (t_0 <= -0.82) {
		tmp = U + (t_0 * (J * (l * 2.0)));
	} else if (t_0 <= -0.01) {
		tmp = t_1;
	} 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    t_1 = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
    if (t_0 <= (-0.985d0)) then
        tmp = u + ((j * 2.0d0) * (l * cos((k * 0.5d0))))
    else if (t_0 <= (-0.9d0)) then
        tmp = t_1
    else if (t_0 <= (-0.82d0)) then
        tmp = u + (t_0 * (j * (l * 2.0d0)))
    else if (t_0 <= (-0.01d0)) then
        tmp = t_1
    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 t_0 = Math.cos((K / 2.0));
	double t_1 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	double tmp;
	if (t_0 <= -0.985) {
		tmp = U + ((J * 2.0) * (l * Math.cos((K * 0.5))));
	} else if (t_0 <= -0.9) {
		tmp = t_1;
	} else if (t_0 <= -0.82) {
		tmp = U + (t_0 * (J * (l * 2.0)));
	} else if (t_0 <= -0.01) {
		tmp = t_1;
	} else {
		tmp = U + (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 = U + ((l * J) * (2.0 + ((K * K) * -0.25)))
	tmp = 0
	if t_0 <= -0.985:
		tmp = U + ((J * 2.0) * (l * math.cos((K * 0.5))))
	elif t_0 <= -0.9:
		tmp = t_1
	elif t_0 <= -0.82:
		tmp = U + (t_0 * (J * (l * 2.0)))
	elif t_0 <= -0.01:
		tmp = t_1
	else:
		tmp = U + (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(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25))))
	tmp = 0.0
	if (t_0 <= -0.985)
		tmp = Float64(U + Float64(Float64(J * 2.0) * Float64(l * cos(Float64(K * 0.5)))));
	elseif (t_0 <= -0.9)
		tmp = t_1;
	elseif (t_0 <= -0.82)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * 2.0))));
	elseif (t_0 <= -0.01)
		tmp = t_1;
	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)
	t_0 = cos((K / 2.0));
	t_1 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	tmp = 0.0;
	if (t_0 <= -0.985)
		tmp = U + ((J * 2.0) * (l * cos((K * 0.5))));
	elseif (t_0 <= -0.9)
		tmp = t_1;
	elseif (t_0 <= -0.82)
		tmp = U + (t_0 * (J * (l * 2.0)));
	elseif (t_0 <= -0.01)
		tmp = t_1;
	else
		tmp = U + (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[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.985], N[(U + N[(N[(J * 2.0), $MachinePrecision] * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.9], t$95$1, If[LessEqual[t$95$0, -0.82], N[(U + N[(t$95$0 * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.01], t$95$1, 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}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\
\mathbf{if}\;t_0 \leq -0.985:\\
\;\;\;\;U + \left(J \cdot 2\right) \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\\

\mathbf{elif}\;t_0 \leq -0.9:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq -0.82:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\

\mathbf{elif}\;t_0 \leq -0.01:\\
\;\;\;\;t_1\\

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


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

    1. Initial program 67.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 90.2%

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

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

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

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

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

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

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

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

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

    if -0.984999999999999987 < (cos.f64 (/.f64 K 2)) < -0.900000000000000022 or -0.819999999999999951 < (cos.f64 (/.f64 K 2)) < -0.0100000000000000002

    1. Initial program 90.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 40.5%

      \[\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. *-commutative40.5%

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

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

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

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

      \[\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. +-commutative57.8%

        \[\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*57.8%

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

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

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

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

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

    if -0.900000000000000022 < (cos.f64 (/.f64 K 2)) < -0.819999999999999951

    1. Initial program 90.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 80.5%

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

    if -0.0100000000000000002 < (cos.f64 (/.f64 K 2))

    1. Initial program 84.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 91.7%

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

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

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

Alternative 3: 68.0% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;t_0 \leq -0.82:\\
\;\;\;\;U + J \cdot 0.125\\

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

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


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

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

      \[\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. *-commutative48.6%

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

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

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

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

      \[\leadsto 2 \cdot \color{blue}{\left(0.0026041666666666665 \cdot \left({K}^{4} \cdot \left(\ell \cdot J\right)\right) + \left(-0.125 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right) + \ell \cdot J\right)\right)} + U \]
    6. Step-by-step derivation
      1. associate-+r+0.7%

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

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

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

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

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

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

      \[\leadsto 2 \cdot \color{blue}{\left(\ell \cdot J + \left(\ell \cdot J\right) \cdot \left(0.0026041666666666665 \cdot {K}^{4} + -0.125 \cdot \left(K \cdot K\right)\right)\right)} + U \]
    8. Taylor expanded in K around 0 44.5%

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\ell \cdot J + \color{blue}{\ell \cdot \left(J \cdot \left(-0.125 \cdot \left(K \cdot K\right)\right)\right)}\right) + U \]
      6. distribute-lft-out55.1%

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

        \[\leadsto 2 \cdot \left(\ell \cdot \left(J + \color{blue}{\left(J \cdot -0.125\right) \cdot \left(K \cdot K\right)}\right)\right) + U \]
    10. Simplified55.1%

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

    if -0.890000000000000013 < (cos.f64 (/.f64 K 2)) < -0.819999999999999951

    1. Initial program 89.3%

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

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

      \[\leadsto \color{blue}{0.125 \cdot J} + U \]
    4. Step-by-step derivation
      1. *-commutative67.7%

        \[\leadsto \color{blue}{J \cdot 0.125} + U \]
    5. Simplified67.7%

      \[\leadsto \color{blue}{J \cdot 0.125} + U \]

    if -0.819999999999999951 < (cos.f64 (/.f64 K 2)) < -0.0100000000000000002

    1. Initial program 89.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 47.3%

      \[\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. *-commutative47.3%

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

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

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

      \[\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.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. +-commutative54.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*54.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-out63.5%

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

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

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

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

    if -0.0100000000000000002 < (cos.f64 (/.f64 K 2))

    1. Initial program 84.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 91.7%

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

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

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

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

Alternative 4: 95.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.9 \cdot 10^{+90} \lor \neg \left(\ell \leq -52\right) \land \left(\ell \leq 7.4 \lor \neg \left(\ell \leq 5.8 \cdot 10^{+102}\right)\right):\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot \left(J + J \cdot \left(-0.125 \cdot \left(K \cdot K\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -2.9e+90)
         (and (not (<= l -52.0)) (or (<= l 7.4) (not (<= l 5.8e+102)))))
   (+
    U
    (* (cos (/ K 2.0)) (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
   (+ U (* (- (exp l) (exp (- l))) (+ J (* J (* -0.125 (* K K))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -2.9e+90) || (!(l <= -52.0) && ((l <= 7.4) || !(l <= 5.8e+102)))) {
		tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
	} else {
		tmp = U + ((exp(l) - exp(-l)) * (J + (J * (-0.125 * (K * K)))));
	}
	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.9d+90)) .or. (.not. (l <= (-52.0d0))) .and. (l <= 7.4d0) .or. (.not. (l <= 5.8d+102))) then
        tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
    else
        tmp = u + ((exp(l) - exp(-l)) * (j + (j * ((-0.125d0) * (k * k)))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -2.9e+90) || (!(l <= -52.0) && ((l <= 7.4) || !(l <= 5.8e+102)))) {
		tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
	} else {
		tmp = U + ((Math.exp(l) - Math.exp(-l)) * (J + (J * (-0.125 * (K * K)))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -2.9e+90) or (not (l <= -52.0) and ((l <= 7.4) or not (l <= 5.8e+102))):
		tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))
	else:
		tmp = U + ((math.exp(l) - math.exp(-l)) * (J + (J * (-0.125 * (K * K)))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -2.9e+90) || (!(l <= -52.0) && ((l <= 7.4) || !(l <= 5.8e+102))))
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))));
	else
		tmp = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * Float64(J + Float64(J * Float64(-0.125 * Float64(K * K))))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if ((l <= -2.9e+90) || (~((l <= -52.0)) && ((l <= 7.4) || ~((l <= 5.8e+102)))))
		tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))));
	else
		tmp = U + ((exp(l) - exp(-l)) * (J + (J * (-0.125 * (K * K)))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.9e+90], And[N[Not[LessEqual[l, -52.0]], $MachinePrecision], Or[LessEqual[l, 7.4], N[Not[LessEqual[l, 5.8e+102]], $MachinePrecision]]]], 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], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * N[(J + N[(J * N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.9 \cdot 10^{+90} \lor \neg \left(\ell \leq -52\right) \land \left(\ell \leq 7.4 \lor \neg \left(\ell \leq 5.8 \cdot 10^{+102}\right)\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\

\mathbf{else}:\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot \left(J + J \cdot \left(-0.125 \cdot \left(K \cdot K\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.9000000000000001e90 or -52 < l < 7.4000000000000004 or 5.8000000000000005e102 < l

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

      \[\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 -2.9000000000000001e90 < l < -52 or 7.4000000000000004 < l < 5.8000000000000005e102

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.9 \cdot 10^{+90} \lor \neg \left(\ell \leq -52\right) \land \left(\ell \leq 7.4 \lor \neg \left(\ell \leq 5.8 \cdot 10^{+102}\right)\right):\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot \left(J + J \cdot \left(-0.125 \cdot \left(K \cdot K\right)\right)\right)\\ \end{array} \]

Alternative 5: 88.1% 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 85.3%

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

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

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

Alternative 6: 86.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -165000 \lor \neg \left(\ell \leq 1800\right):\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -165000 or 1800 < 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 K around 0 70.4%

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

    if -165000 < l < 1800

    1. Initial program 68.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 98.2%

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

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

Alternative 7: 80.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+92}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -3850000:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-8}{U} - U\right)\right)\\ \mathbf{elif}\;\ell \leq 2.1 \cdot 10^{-7}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\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 (<= l -4.5e+92)
   (+ U (* 0.3333333333333333 (* J (pow l 3.0))))
   (if (<= l -3850000.0)
     (log1p (expm1 (- (/ -8.0 U) U)))
     (if (<= l 2.1e-7)
       (+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
       (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -4.5e+92) {
		tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
	} else if (l <= -3850000.0) {
		tmp = log1p(expm1(((-8.0 / U) - U)));
	} else if (l <= 2.1e-7) {
		tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
	} else {
		tmp = U + (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 tmp;
	if (l <= -4.5e+92) {
		tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
	} else if (l <= -3850000.0) {
		tmp = Math.log1p(Math.expm1(((-8.0 / U) - U)));
	} else if (l <= 2.1e-7) {
		tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
	} 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 l <= -4.5e+92:
		tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0)))
	elif l <= -3850000.0:
		tmp = math.log1p(math.expm1(((-8.0 / U) - U)))
	elif l <= 2.1e-7:
		tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0)))
	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 (l <= -4.5e+92)
		tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))));
	elseif (l <= -3850000.0)
		tmp = log1p(expm1(Float64(Float64(-8.0 / U) - U)));
	elseif (l <= 2.1e-7)
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0))));
	else
		tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))));
	end
	return tmp
end
code[J_, l_, K_, U_] := If[LessEqual[l, -4.5e+92], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -3850000.0], N[Log[1 + N[(Exp[N[(N[(-8.0 / U), $MachinePrecision] - U), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 2.1e-7], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $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}\;\ell \leq -4.5 \cdot 10^{+92}:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\

\mathbf{elif}\;\ell \leq -3850000:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-8}{U} - U\right)\right)\\

\mathbf{elif}\;\ell \leq 2.1 \cdot 10^{-7}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\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 4 regimes
  2. if l < -4.4999999999999999e92

    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 98.2%

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

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

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

    if -4.4999999999999999e92 < l < -3.85e6

    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-rr4.4%

      \[\leadsto \color{blue}{\frac{-8}{U} - U} \]
    3. Step-by-step derivation
      1. log1p-expm1-u80.0%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-8}{U} - U\right)\right)} \]
    4. Applied egg-rr80.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-8}{U} - U\right)\right)} \]

    if -3.85e6 < l < 2.1e-7

    1. Initial program 68.1%

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

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

    if 2.1e-7 < l

    1. Initial program 99.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 80.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+92}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -3850000:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-8}{U} - U\right)\right)\\ \mathbf{elif}\;\ell \leq 2.1 \cdot 10^{-7}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \end{array} \]

Alternative 8: 78.2% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.16 \cdot 10^{+20} \lor \neg \left(\ell \leq 3.2 \cdot 10^{-7}\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.16e20 or 3.2000000000000001e-7 < 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 81.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 K around 0 60.5%

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

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

    if -1.16e20 < l < 3.2000000000000001e-7

    1. Initial program 68.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 97.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. *-commutative97.4%

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

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

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

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

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

Alternative 9: 78.2% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.5 \cdot 10^{+19} \lor \neg \left(\ell \leq 3.2 \cdot 10^{-7}\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.5e19 or 3.2000000000000001e-7 < 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 81.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 K around 0 60.5%

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

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

    if -4.5e19 < l < 3.2000000000000001e-7

    1. Initial program 68.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 97.4%

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

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

Alternative 10: 58.5% 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)\\ t_1 := \frac{\frac{64}{U \cdot U} - U \cdot U}{U + \frac{-8}{U}}\\ \mathbf{if}\;\ell \leq -1.2 \cdot 10^{+133}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+89}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \mathbf{elif}\;\ell \leq -620:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 660:\\ \;\;\;\;\mathsf{fma}\left(\ell, J \cdot 2, U\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+168}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+232}:\\ \;\;\;\;t_1\\ \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)))))
        (t_1 (/ (- (/ 64.0 (* U U)) (* U U)) (+ U (/ -8.0 U)))))
   (if (<= l -1.2e+133)
     t_0
     (if (<= l -7.8e+89)
       (+ U (* J (+ 0.125 (* (* K K) -0.015625))))
       (if (<= l -620.0)
         t_1
         (if (<= l 660.0)
           (fma l (* J 2.0) U)
           (if (<= l 6e+168)
             t_0
             (if (<= l 1.65e+232) t_1 (+ 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 t_1 = ((64.0 / (U * U)) - (U * U)) / (U + (-8.0 / U));
	double tmp;
	if (l <= -1.2e+133) {
		tmp = t_0;
	} else if (l <= -7.8e+89) {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	} else if (l <= -620.0) {
		tmp = t_1;
	} else if (l <= 660.0) {
		tmp = fma(l, (J * 2.0), U);
	} else if (l <= 6e+168) {
		tmp = t_0;
	} else if (l <= 1.65e+232) {
		tmp = t_1;
	} 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))))
	t_1 = Float64(Float64(Float64(64.0 / Float64(U * U)) - Float64(U * U)) / Float64(U + Float64(-8.0 / U)))
	tmp = 0.0
	if (l <= -1.2e+133)
		tmp = t_0;
	elseif (l <= -7.8e+89)
		tmp = Float64(U + Float64(J * Float64(0.125 + Float64(Float64(K * K) * -0.015625))));
	elseif (l <= -620.0)
		tmp = t_1;
	elseif (l <= 660.0)
		tmp = fma(l, Float64(J * 2.0), U);
	elseif (l <= 6e+168)
		tmp = t_0;
	elseif (l <= 1.65e+232)
		tmp = t_1;
	else
		tmp = Float64(U + Float64(2.0 * Float64(l * J)));
	end
	return 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]}, Block[{t$95$1 = N[(N[(N[(64.0 / N[(U * U), $MachinePrecision]), $MachinePrecision] - N[(U * U), $MachinePrecision]), $MachinePrecision] / N[(U + N[(-8.0 / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.2e+133], t$95$0, If[LessEqual[l, -7.8e+89], N[(U + N[(J * N[(0.125 + N[(N[(K * K), $MachinePrecision] * -0.015625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -620.0], t$95$1, If[LessEqual[l, 660.0], N[(l * N[(J * 2.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 6e+168], t$95$0, If[LessEqual[l, 1.65e+232], t$95$1, 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)\\
t_1 := \frac{\frac{64}{U \cdot U} - U \cdot U}{U + \frac{-8}{U}}\\
\mathbf{if}\;\ell \leq -1.2 \cdot 10^{+133}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+89}:\\
\;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\

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

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

\mathbf{elif}\;\ell \leq 6 \cdot 10^{+168}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+232}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if l < -1.1999999999999999e133 or 660 < l < 5.9999999999999996e168

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

      \[\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. *-commutative29.1%

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

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

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

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

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

        \[\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*24.0%

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

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

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

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

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

    if -1.1999999999999999e133 < l < -7.80000000000000021e89

    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-rr1.5%

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

      \[\leadsto \color{blue}{\left(0.125 \cdot J + -0.015625 \cdot \left({K}^{2} \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*56.8%

        \[\leadsto \left(0.125 \cdot J + \color{blue}{\left(-0.015625 \cdot {K}^{2}\right) \cdot J}\right) + U \]
      2. distribute-rgt-out56.8%

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

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

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

    if -7.80000000000000021e89 < l < -620 or 5.9999999999999996e168 < l < 1.65e232

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

      \[\leadsto \color{blue}{\frac{-8}{U} - U} \]
    3. Step-by-step derivation
      1. flip--44.9%

        \[\leadsto \color{blue}{\frac{\frac{-8}{U} \cdot \frac{-8}{U} - U \cdot U}{\frac{-8}{U} + U}} \]
      2. frac-times44.9%

        \[\leadsto \frac{\color{blue}{\frac{-8 \cdot -8}{U \cdot U}} - U \cdot U}{\frac{-8}{U} + U} \]
      3. metadata-eval44.9%

        \[\leadsto \frac{\frac{\color{blue}{64}}{U \cdot U} - U \cdot U}{\frac{-8}{U} + U} \]
    4. Applied egg-rr44.9%

      \[\leadsto \color{blue}{\frac{\frac{64}{U \cdot U} - U \cdot U}{\frac{-8}{U} + U}} \]

    if -620 < l < 660

    1. Initial program 68.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 99.8%

      \[\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. *-commutative99.8%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\ell \cdot \left(2 \cdot J\right)} + U \]
      4. fma-def83.9%

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

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

    if 1.65e232 < 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 47.3%

      \[\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. *-commutative47.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.2 \cdot 10^{+133}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+89}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \mathbf{elif}\;\ell \leq -620:\\ \;\;\;\;\frac{\frac{64}{U \cdot U} - U \cdot U}{U + \frac{-8}{U}}\\ \mathbf{elif}\;\ell \leq 660:\\ \;\;\;\;\mathsf{fma}\left(\ell, J \cdot 2, U\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+168}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+232}:\\ \;\;\;\;\frac{\frac{64}{U \cdot U} - U \cdot U}{U + \frac{-8}{U}}\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \end{array} \]

Alternative 11: 58.6% accurate, 11.4× 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)\\ t_1 := U + 2 \cdot \left(\ell \cdot J\right)\\ t_2 := \frac{\frac{64}{U \cdot U} - U \cdot U}{U + \frac{-8}{U}}\\ \mathbf{if}\;\ell \leq -3.3 \cdot 10^{+132}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -4.7 \cdot 10^{+89}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \mathbf{elif}\;\ell \leq -1050:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\ell \leq 270:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+167}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+232}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ U (* (* l J) (+ 2.0 (* (* K K) -0.25)))))
        (t_1 (+ U (* 2.0 (* l J))))
        (t_2 (/ (- (/ 64.0 (* U U)) (* U U)) (+ U (/ -8.0 U)))))
   (if (<= l -3.3e+132)
     t_0
     (if (<= l -4.7e+89)
       (+ U (* J (+ 0.125 (* (* K K) -0.015625))))
       (if (<= l -1050.0)
         t_2
         (if (<= l 270.0)
           t_1
           (if (<= l 5e+167) t_0 (if (<= l 1.55e+232) t_2 t_1))))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	double t_1 = U + (2.0 * (l * J));
	double t_2 = ((64.0 / (U * U)) - (U * U)) / (U + (-8.0 / U));
	double tmp;
	if (l <= -3.3e+132) {
		tmp = t_0;
	} else if (l <= -4.7e+89) {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	} else if (l <= -1050.0) {
		tmp = t_2;
	} else if (l <= 270.0) {
		tmp = t_1;
	} else if (l <= 5e+167) {
		tmp = t_0;
	} else if (l <= 1.55e+232) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	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 = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
    t_1 = u + (2.0d0 * (l * j))
    t_2 = ((64.0d0 / (u * u)) - (u * u)) / (u + ((-8.0d0) / u))
    if (l <= (-3.3d+132)) then
        tmp = t_0
    else if (l <= (-4.7d+89)) then
        tmp = u + (j * (0.125d0 + ((k * k) * (-0.015625d0))))
    else if (l <= (-1050.0d0)) then
        tmp = t_2
    else if (l <= 270.0d0) then
        tmp = t_1
    else if (l <= 5d+167) then
        tmp = t_0
    else if (l <= 1.55d+232) then
        tmp = t_2
    else
        tmp = t_1
    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 t_1 = U + (2.0 * (l * J));
	double t_2 = ((64.0 / (U * U)) - (U * U)) / (U + (-8.0 / U));
	double tmp;
	if (l <= -3.3e+132) {
		tmp = t_0;
	} else if (l <= -4.7e+89) {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	} else if (l <= -1050.0) {
		tmp = t_2;
	} else if (l <= 270.0) {
		tmp = t_1;
	} else if (l <= 5e+167) {
		tmp = t_0;
	} else if (l <= 1.55e+232) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + ((l * J) * (2.0 + ((K * K) * -0.25)))
	t_1 = U + (2.0 * (l * J))
	t_2 = ((64.0 / (U * U)) - (U * U)) / (U + (-8.0 / U))
	tmp = 0
	if l <= -3.3e+132:
		tmp = t_0
	elif l <= -4.7e+89:
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)))
	elif l <= -1050.0:
		tmp = t_2
	elif l <= 270.0:
		tmp = t_1
	elif l <= 5e+167:
		tmp = t_0
	elif l <= 1.55e+232:
		tmp = t_2
	else:
		tmp = t_1
	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))))
	t_1 = Float64(U + Float64(2.0 * Float64(l * J)))
	t_2 = Float64(Float64(Float64(64.0 / Float64(U * U)) - Float64(U * U)) / Float64(U + Float64(-8.0 / U)))
	tmp = 0.0
	if (l <= -3.3e+132)
		tmp = t_0;
	elseif (l <= -4.7e+89)
		tmp = Float64(U + Float64(J * Float64(0.125 + Float64(Float64(K * K) * -0.015625))));
	elseif (l <= -1050.0)
		tmp = t_2;
	elseif (l <= 270.0)
		tmp = t_1;
	elseif (l <= 5e+167)
		tmp = t_0;
	elseif (l <= 1.55e+232)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	t_1 = U + (2.0 * (l * J));
	t_2 = ((64.0 / (U * U)) - (U * U)) / (U + (-8.0 / U));
	tmp = 0.0;
	if (l <= -3.3e+132)
		tmp = t_0;
	elseif (l <= -4.7e+89)
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	elseif (l <= -1050.0)
		tmp = t_2;
	elseif (l <= 270.0)
		tmp = t_1;
	elseif (l <= 5e+167)
		tmp = t_0;
	elseif (l <= 1.55e+232)
		tmp = t_2;
	else
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(64.0 / N[(U * U), $MachinePrecision]), $MachinePrecision] - N[(U * U), $MachinePrecision]), $MachinePrecision] / N[(U + N[(-8.0 / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.3e+132], t$95$0, If[LessEqual[l, -4.7e+89], N[(U + N[(J * N[(0.125 + N[(N[(K * K), $MachinePrecision] * -0.015625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1050.0], t$95$2, If[LessEqual[l, 270.0], t$95$1, If[LessEqual[l, 5e+167], t$95$0, If[LessEqual[l, 1.55e+232], t$95$2, t$95$1]]]]]]]]]
\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)\\
t_1 := U + 2 \cdot \left(\ell \cdot J\right)\\
t_2 := \frac{\frac{64}{U \cdot U} - U \cdot U}{U + \frac{-8}{U}}\\
\mathbf{if}\;\ell \leq -3.3 \cdot 10^{+132}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -4.7 \cdot 10^{+89}:\\
\;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\

\mathbf{elif}\;\ell \leq -1050:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\ell \leq 270:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\ell \leq 5 \cdot 10^{+167}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+232}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -3.3000000000000003e132 or 270 < l < 4.9999999999999997e167

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

      \[\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. *-commutative29.1%

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

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

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

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

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

        \[\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*24.0%

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

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

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

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

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

    if -3.3000000000000003e132 < l < -4.70000000000000022e89

    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-rr1.5%

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

      \[\leadsto \color{blue}{\left(0.125 \cdot J + -0.015625 \cdot \left({K}^{2} \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*56.8%

        \[\leadsto \left(0.125 \cdot J + \color{blue}{\left(-0.015625 \cdot {K}^{2}\right) \cdot J}\right) + U \]
      2. distribute-rgt-out56.8%

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

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

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

    if -4.70000000000000022e89 < l < -1050 or 4.9999999999999997e167 < l < 1.54999999999999992e232

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

      \[\leadsto \color{blue}{\frac{-8}{U} - U} \]
    3. Step-by-step derivation
      1. flip--44.9%

        \[\leadsto \color{blue}{\frac{\frac{-8}{U} \cdot \frac{-8}{U} - U \cdot U}{\frac{-8}{U} + U}} \]
      2. frac-times44.9%

        \[\leadsto \frac{\color{blue}{\frac{-8 \cdot -8}{U \cdot U}} - U \cdot U}{\frac{-8}{U} + U} \]
      3. metadata-eval44.9%

        \[\leadsto \frac{\frac{\color{blue}{64}}{U \cdot U} - U \cdot U}{\frac{-8}{U} + U} \]
    4. Applied egg-rr44.9%

      \[\leadsto \color{blue}{\frac{\frac{64}{U \cdot U} - U \cdot U}{\frac{-8}{U} + U}} \]

    if -1050 < l < 270 or 1.54999999999999992e232 < l

    1. Initial program 72.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.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. *-commutative92.9%

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

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

        \[\leadsto 2 \cdot \left(\ell \cdot \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot J\right)}\right) + U \]
    4. Simplified92.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 79.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.3 \cdot 10^{+132}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq -4.7 \cdot 10^{+89}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \mathbf{elif}\;\ell \leq -1050:\\ \;\;\;\;\frac{\frac{64}{U \cdot U} - U \cdot U}{U + \frac{-8}{U}}\\ \mathbf{elif}\;\ell \leq 270:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+167}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+232}:\\ \;\;\;\;\frac{\frac{64}{U \cdot U} - U \cdot U}{U + \frac{-8}{U}}\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \end{array} \]

Alternative 12: 56.9% accurate, 13.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{64}{U \cdot U} - U \cdot U\\ t_1 := t_0 \cdot \left(U \cdot -0.125\right)\\ t_2 := t_0 \cdot \frac{1}{U}\\ \mathbf{if}\;\ell \leq -1.7 \cdot 10^{+295}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\ell \leq -3.35 \cdot 10^{+193}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq -2.05 \cdot 10^{+73}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\ell \leq -850:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 2.8 \cdot 10^{+32} \lor \neg \left(\ell \leq 4.8 \cdot 10^{+132}\right):\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (- (/ 64.0 (* U U)) (* U U)))
        (t_1 (* t_0 (* U -0.125)))
        (t_2 (* t_0 (/ 1.0 U))))
   (if (<= l -1.7e+295)
     t_2
     (if (<= l -3.35e+193)
       t_1
       (if (<= l -2.05e+73)
         t_2
         (if (<= l -850.0)
           t_1
           (if (or (<= l 2.8e+32) (not (<= l 4.8e+132)))
             (+ U (* 2.0 (* l J)))
             (+ U (* J (+ 0.125 (* (* K K) -0.015625)))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = (64.0 / (U * U)) - (U * U);
	double t_1 = t_0 * (U * -0.125);
	double t_2 = t_0 * (1.0 / U);
	double tmp;
	if (l <= -1.7e+295) {
		tmp = t_2;
	} else if (l <= -3.35e+193) {
		tmp = t_1;
	} else if (l <= -2.05e+73) {
		tmp = t_2;
	} else if (l <= -850.0) {
		tmp = t_1;
	} else if ((l <= 2.8e+32) || !(l <= 4.8e+132)) {
		tmp = U + (2.0 * (l * J));
	} else {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	}
	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 = (64.0d0 / (u * u)) - (u * u)
    t_1 = t_0 * (u * (-0.125d0))
    t_2 = t_0 * (1.0d0 / u)
    if (l <= (-1.7d+295)) then
        tmp = t_2
    else if (l <= (-3.35d+193)) then
        tmp = t_1
    else if (l <= (-2.05d+73)) then
        tmp = t_2
    else if (l <= (-850.0d0)) then
        tmp = t_1
    else if ((l <= 2.8d+32) .or. (.not. (l <= 4.8d+132))) then
        tmp = u + (2.0d0 * (l * j))
    else
        tmp = u + (j * (0.125d0 + ((k * k) * (-0.015625d0))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = (64.0 / (U * U)) - (U * U);
	double t_1 = t_0 * (U * -0.125);
	double t_2 = t_0 * (1.0 / U);
	double tmp;
	if (l <= -1.7e+295) {
		tmp = t_2;
	} else if (l <= -3.35e+193) {
		tmp = t_1;
	} else if (l <= -2.05e+73) {
		tmp = t_2;
	} else if (l <= -850.0) {
		tmp = t_1;
	} else if ((l <= 2.8e+32) || !(l <= 4.8e+132)) {
		tmp = U + (2.0 * (l * J));
	} else {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = (64.0 / (U * U)) - (U * U)
	t_1 = t_0 * (U * -0.125)
	t_2 = t_0 * (1.0 / U)
	tmp = 0
	if l <= -1.7e+295:
		tmp = t_2
	elif l <= -3.35e+193:
		tmp = t_1
	elif l <= -2.05e+73:
		tmp = t_2
	elif l <= -850.0:
		tmp = t_1
	elif (l <= 2.8e+32) or not (l <= 4.8e+132):
		tmp = U + (2.0 * (l * J))
	else:
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(Float64(64.0 / Float64(U * U)) - Float64(U * U))
	t_1 = Float64(t_0 * Float64(U * -0.125))
	t_2 = Float64(t_0 * Float64(1.0 / U))
	tmp = 0.0
	if (l <= -1.7e+295)
		tmp = t_2;
	elseif (l <= -3.35e+193)
		tmp = t_1;
	elseif (l <= -2.05e+73)
		tmp = t_2;
	elseif (l <= -850.0)
		tmp = t_1;
	elseif ((l <= 2.8e+32) || !(l <= 4.8e+132))
		tmp = Float64(U + Float64(2.0 * Float64(l * J)));
	else
		tmp = Float64(U + Float64(J * Float64(0.125 + Float64(Float64(K * K) * -0.015625))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = (64.0 / (U * U)) - (U * U);
	t_1 = t_0 * (U * -0.125);
	t_2 = t_0 * (1.0 / U);
	tmp = 0.0;
	if (l <= -1.7e+295)
		tmp = t_2;
	elseif (l <= -3.35e+193)
		tmp = t_1;
	elseif (l <= -2.05e+73)
		tmp = t_2;
	elseif (l <= -850.0)
		tmp = t_1;
	elseif ((l <= 2.8e+32) || ~((l <= 4.8e+132)))
		tmp = U + (2.0 * (l * J));
	else
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(64.0 / N[(U * U), $MachinePrecision]), $MachinePrecision] - N[(U * U), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(U * -0.125), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(1.0 / U), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.7e+295], t$95$2, If[LessEqual[l, -3.35e+193], t$95$1, If[LessEqual[l, -2.05e+73], t$95$2, If[LessEqual[l, -850.0], t$95$1, If[Or[LessEqual[l, 2.8e+32], N[Not[LessEqual[l, 4.8e+132]], $MachinePrecision]], N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(0.125 + N[(N[(K * K), $MachinePrecision] * -0.015625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{64}{U \cdot U} - U \cdot U\\
t_1 := t_0 \cdot \left(U \cdot -0.125\right)\\
t_2 := t_0 \cdot \frac{1}{U}\\
\mathbf{if}\;\ell \leq -1.7 \cdot 10^{+295}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\ell \leq -3.35 \cdot 10^{+193}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\ell \leq -2.05 \cdot 10^{+73}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;\ell \leq 2.8 \cdot 10^{+32} \lor \neg \left(\ell \leq 4.8 \cdot 10^{+132}\right):\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\

\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.70000000000000001e295 or -3.3500000000000001e193 < l < -2.0499999999999999e73

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

      \[\leadsto \color{blue}{\frac{-8}{U} - U} \]
    3. Step-by-step derivation
      1. flip--29.7%

        \[\leadsto \color{blue}{\frac{\frac{-8}{U} \cdot \frac{-8}{U} - U \cdot U}{\frac{-8}{U} + U}} \]
      2. div-inv29.7%

        \[\leadsto \color{blue}{\left(\frac{-8}{U} \cdot \frac{-8}{U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U}} \]
      3. frac-times29.7%

        \[\leadsto \left(\color{blue}{\frac{-8 \cdot -8}{U \cdot U}} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U} \]
      4. metadata-eval29.7%

        \[\leadsto \left(\frac{\color{blue}{64}}{U \cdot U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U} \]
    4. Applied egg-rr29.7%

      \[\leadsto \color{blue}{\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U}} \]
    5. Taylor expanded in U around inf 41.0%

      \[\leadsto \left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \color{blue}{\frac{1}{U}} \]

    if -1.70000000000000001e295 < l < -3.3500000000000001e193 or -2.0499999999999999e73 < l < -850

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

      \[\leadsto \color{blue}{\frac{-8}{U} - U} \]
    3. Step-by-step derivation
      1. flip--36.0%

        \[\leadsto \color{blue}{\frac{\frac{-8}{U} \cdot \frac{-8}{U} - U \cdot U}{\frac{-8}{U} + U}} \]
      2. div-inv36.0%

        \[\leadsto \color{blue}{\left(\frac{-8}{U} \cdot \frac{-8}{U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U}} \]
      3. frac-times36.0%

        \[\leadsto \left(\color{blue}{\frac{-8 \cdot -8}{U \cdot U}} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U} \]
      4. metadata-eval36.0%

        \[\leadsto \left(\frac{\color{blue}{64}}{U \cdot U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U} \]
    4. Applied egg-rr36.0%

      \[\leadsto \color{blue}{\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U}} \]
    5. Taylor expanded in U around 0 48.7%

      \[\leadsto \left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \color{blue}{\left(-0.125 \cdot U\right)} \]
    6. Step-by-step derivation
      1. *-commutative48.7%

        \[\leadsto \left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \color{blue}{\left(U \cdot -0.125\right)} \]
    7. Simplified48.7%

      \[\leadsto \left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \color{blue}{\left(U \cdot -0.125\right)} \]

    if -850 < l < 2.8e32 or 4.8000000000000002e132 < l

    1. Initial program 77.1%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 82.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. *-commutative82.9%

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

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

        \[\leadsto 2 \cdot \left(\ell \cdot \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot J\right)}\right) + U \]
    4. Simplified82.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 70.6%

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

    if 2.8e32 < l < 4.8000000000000002e132

    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-rr4.6%

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

      \[\leadsto \color{blue}{\left(0.125 \cdot J + -0.015625 \cdot \left({K}^{2} \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*45.0%

        \[\leadsto \left(0.125 \cdot J + \color{blue}{\left(-0.015625 \cdot {K}^{2}\right) \cdot J}\right) + U \]
      2. distribute-rgt-out45.0%

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

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

      \[\leadsto \color{blue}{J \cdot \left(0.125 + -0.015625 \cdot \left(K \cdot K\right)\right)} + U \]
  3. Recombined 4 regimes into one program.
  4. Final simplification61.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.7 \cdot 10^{+295}:\\ \;\;\;\;\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \frac{1}{U}\\ \mathbf{elif}\;\ell \leq -3.35 \cdot 10^{+193}:\\ \;\;\;\;\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \left(U \cdot -0.125\right)\\ \mathbf{elif}\;\ell \leq -2.05 \cdot 10^{+73}:\\ \;\;\;\;\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \frac{1}{U}\\ \mathbf{elif}\;\ell \leq -850:\\ \;\;\;\;\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \left(U \cdot -0.125\right)\\ \mathbf{elif}\;\ell \leq 2.8 \cdot 10^{+32} \lor \neg \left(\ell \leq 4.8 \cdot 10^{+132}\right):\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \end{array} \]

Alternative 13: 60.5% accurate, 14.7× 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 -1.4 \cdot 10^{+129}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -2.65 \cdot 10^{+73}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \mathbf{elif}\;\ell \leq -750:\\ \;\;\;\;\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \left(U \cdot -0.125\right)\\ \mathbf{elif}\;\ell \leq 270:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \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 -1.4e+129)
     t_0
     (if (<= l -2.65e+73)
       (+ U (* J (+ 0.125 (* (* K K) -0.015625))))
       (if (<= l -750.0)
         (* (- (/ 64.0 (* U U)) (* U U)) (* U -0.125))
         (if (<= l 270.0) (+ U (* 2.0 (* l J))) t_0))))))
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 <= -1.4e+129) {
		tmp = t_0;
	} else if (l <= -2.65e+73) {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	} else if (l <= -750.0) {
		tmp = ((64.0 / (U * U)) - (U * U)) * (U * -0.125);
	} else if (l <= 270.0) {
		tmp = U + (2.0 * (l * J));
	} 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) :: tmp
    t_0 = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
    if (l <= (-1.4d+129)) then
        tmp = t_0
    else if (l <= (-2.65d+73)) then
        tmp = u + (j * (0.125d0 + ((k * k) * (-0.015625d0))))
    else if (l <= (-750.0d0)) then
        tmp = ((64.0d0 / (u * u)) - (u * u)) * (u * (-0.125d0))
    else if (l <= 270.0d0) then
        tmp = u + (2.0d0 * (l * j))
    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 + ((l * J) * (2.0 + ((K * K) * -0.25)));
	double tmp;
	if (l <= -1.4e+129) {
		tmp = t_0;
	} else if (l <= -2.65e+73) {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	} else if (l <= -750.0) {
		tmp = ((64.0 / (U * U)) - (U * U)) * (U * -0.125);
	} else if (l <= 270.0) {
		tmp = U + (2.0 * (l * J));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + ((l * J) * (2.0 + ((K * K) * -0.25)))
	tmp = 0
	if l <= -1.4e+129:
		tmp = t_0
	elif l <= -2.65e+73:
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)))
	elif l <= -750.0:
		tmp = ((64.0 / (U * U)) - (U * U)) * (U * -0.125)
	elif l <= 270.0:
		tmp = U + (2.0 * (l * J))
	else:
		tmp = t_0
	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 <= -1.4e+129)
		tmp = t_0;
	elseif (l <= -2.65e+73)
		tmp = Float64(U + Float64(J * Float64(0.125 + Float64(Float64(K * K) * -0.015625))));
	elseif (l <= -750.0)
		tmp = Float64(Float64(Float64(64.0 / Float64(U * U)) - Float64(U * U)) * Float64(U * -0.125));
	elseif (l <= 270.0)
		tmp = Float64(U + Float64(2.0 * Float64(l * J)));
	else
		tmp = t_0;
	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 <= -1.4e+129)
		tmp = t_0;
	elseif (l <= -2.65e+73)
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	elseif (l <= -750.0)
		tmp = ((64.0 / (U * U)) - (U * U)) * (U * -0.125);
	elseif (l <= 270.0)
		tmp = U + (2.0 * (l * J));
	else
		tmp = t_0;
	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, -1.4e+129], t$95$0, If[LessEqual[l, -2.65e+73], N[(U + N[(J * N[(0.125 + N[(N[(K * K), $MachinePrecision] * -0.015625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -750.0], N[(N[(N[(64.0 / N[(U * U), $MachinePrecision]), $MachinePrecision] - N[(U * U), $MachinePrecision]), $MachinePrecision] * N[(U * -0.125), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 270.0], N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\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 -1.4 \cdot 10^{+129}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -2.65 \cdot 10^{+73}:\\
\;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\

\mathbf{elif}\;\ell \leq -750:\\
\;\;\;\;\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \left(U \cdot -0.125\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.39999999999999987e129 or 270 < 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 32.5%

      \[\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. *-commutative32.5%

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

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

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

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

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

        \[\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*20.7%

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

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

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

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

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

    if -1.39999999999999987e129 < l < -2.64999999999999998e73

    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-rr1.3%

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

      \[\leadsto \color{blue}{\left(0.125 \cdot J + -0.015625 \cdot \left({K}^{2} \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*36.8%

        \[\leadsto \left(0.125 \cdot J + \color{blue}{\left(-0.015625 \cdot {K}^{2}\right) \cdot J}\right) + U \]
      2. distribute-rgt-out36.8%

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

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

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

    if -2.64999999999999998e73 < l < -750

    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-rr4.3%

      \[\leadsto \color{blue}{\frac{-8}{U} - U} \]
    3. Step-by-step derivation
      1. flip--46.3%

        \[\leadsto \color{blue}{\frac{\frac{-8}{U} \cdot \frac{-8}{U} - U \cdot U}{\frac{-8}{U} + U}} \]
      2. div-inv46.3%

        \[\leadsto \color{blue}{\left(\frac{-8}{U} \cdot \frac{-8}{U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U}} \]
      3. frac-times46.3%

        \[\leadsto \left(\color{blue}{\frac{-8 \cdot -8}{U \cdot U}} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U} \]
      4. metadata-eval46.3%

        \[\leadsto \left(\frac{\color{blue}{64}}{U \cdot U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U} \]
    4. Applied egg-rr46.3%

      \[\leadsto \color{blue}{\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U}} \]
    5. Taylor expanded in U around 0 48.0%

      \[\leadsto \left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \color{blue}{\left(-0.125 \cdot U\right)} \]
    6. Step-by-step derivation
      1. *-commutative48.0%

        \[\leadsto \left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \color{blue}{\left(U \cdot -0.125\right)} \]
    7. Simplified48.0%

      \[\leadsto \left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \color{blue}{\left(U \cdot -0.125\right)} \]

    if -750 < l < 270

    1. Initial program 68.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 99.8%

      \[\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. *-commutative99.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.4 \cdot 10^{+129}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq -2.65 \cdot 10^{+73}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \mathbf{elif}\;\ell \leq -750:\\ \;\;\;\;\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \left(U \cdot -0.125\right)\\ \mathbf{elif}\;\ell \leq 270:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \end{array} \]

Alternative 14: 52.3% accurate, 16.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5.7 \cdot 10^{+134}:\\ \;\;\;\;U \cdot \left(U - -8\right)\\ \mathbf{elif}\;\ell \leq -3.2 \cdot 10^{-30} \lor \neg \left(\ell \leq 5.8 \cdot 10^{+31}\right) \land \ell \leq 4 \cdot 10^{+132}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -5.7e+134)
   (* U (- U -8.0))
   (if (or (<= l -3.2e-30) (and (not (<= l 5.8e+31)) (<= l 4e+132)))
     (+ U (* J (+ 0.125 (* (* K K) -0.015625))))
     (+ U (* 2.0 (* l J))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -5.7e+134) {
		tmp = U * (U - -8.0);
	} else if ((l <= -3.2e-30) || (!(l <= 5.8e+31) && (l <= 4e+132))) {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	} 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 <= (-5.7d+134)) then
        tmp = u * (u - (-8.0d0))
    else if ((l <= (-3.2d-30)) .or. (.not. (l <= 5.8d+31)) .and. (l <= 4d+132)) then
        tmp = u + (j * (0.125d0 + ((k * k) * (-0.015625d0))))
    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 <= -5.7e+134) {
		tmp = U * (U - -8.0);
	} else if ((l <= -3.2e-30) || (!(l <= 5.8e+31) && (l <= 4e+132))) {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	} else {
		tmp = U + (2.0 * (l * J));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -5.7e+134:
		tmp = U * (U - -8.0)
	elif (l <= -3.2e-30) or (not (l <= 5.8e+31) and (l <= 4e+132)):
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)))
	else:
		tmp = U + (2.0 * (l * J))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -5.7e+134)
		tmp = Float64(U * Float64(U - -8.0));
	elseif ((l <= -3.2e-30) || (!(l <= 5.8e+31) && (l <= 4e+132)))
		tmp = Float64(U + Float64(J * Float64(0.125 + Float64(Float64(K * K) * -0.015625))));
	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 <= -5.7e+134)
		tmp = U * (U - -8.0);
	elseif ((l <= -3.2e-30) || (~((l <= 5.8e+31)) && (l <= 4e+132)))
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	else
		tmp = U + (2.0 * (l * J));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -5.7e+134], N[(U * N[(U - -8.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, -3.2e-30], And[N[Not[LessEqual[l, 5.8e+31]], $MachinePrecision], LessEqual[l, 4e+132]]], N[(U + N[(J * N[(0.125 + N[(N[(K * K), $MachinePrecision] * -0.015625), $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 -5.7 \cdot 10^{+134}:\\
\;\;\;\;U \cdot \left(U - -8\right)\\

\mathbf{elif}\;\ell \leq -3.2 \cdot 10^{-30} \lor \neg \left(\ell \leq 5.8 \cdot 10^{+31}\right) \land \ell \leq 4 \cdot 10^{+132}:\\
\;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\

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


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

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

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

    if -5.70000000000000038e134 < l < -3.2e-30 or 5.8000000000000001e31 < l < 3.99999999999999996e132

    1. Initial program 98.7%

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

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

      \[\leadsto \color{blue}{\left(0.125 \cdot J + -0.015625 \cdot \left({K}^{2} \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*35.4%

        \[\leadsto \left(0.125 \cdot J + \color{blue}{\left(-0.015625 \cdot {K}^{2}\right) \cdot J}\right) + U \]
      2. distribute-rgt-out35.4%

        \[\leadsto \color{blue}{J \cdot \left(0.125 + -0.015625 \cdot {K}^{2}\right)} + U \]
      3. unpow235.4%

        \[\leadsto J \cdot \left(0.125 + -0.015625 \cdot \color{blue}{\left(K \cdot K\right)}\right) + U \]
    5. Simplified35.4%

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

    if -3.2e-30 < l < 5.8000000000000001e31 or 3.99999999999999996e132 < l

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.7 \cdot 10^{+134}:\\ \;\;\;\;U \cdot \left(U - -8\right)\\ \mathbf{elif}\;\ell \leq -3.2 \cdot 10^{-30} \lor \neg \left(\ell \leq 5.8 \cdot 10^{+31}\right) \land \ell \leq 4 \cdot 10^{+132}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \end{array} \]

Alternative 15: 57.1% accurate, 16.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{if}\;\ell \leq -3.05 \cdot 10^{+293}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -1050:\\ \;\;\;\;\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \left(U \cdot -0.125\right)\\ \mathbf{elif}\;\ell \leq 2.3 \cdot 10^{+31} \lor \neg \left(\ell \leq 2.55 \cdot 10^{+132}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ U (* 2.0 (* l J)))))
   (if (<= l -3.05e+293)
     t_0
     (if (<= l -1050.0)
       (* (- (/ 64.0 (* U U)) (* U U)) (* U -0.125))
       (if (or (<= l 2.3e+31) (not (<= l 2.55e+132)))
         t_0
         (+ U (* J (+ 0.125 (* (* K K) -0.015625)))))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (2.0 * (l * J));
	double tmp;
	if (l <= -3.05e+293) {
		tmp = t_0;
	} else if (l <= -1050.0) {
		tmp = ((64.0 / (U * U)) - (U * U)) * (U * -0.125);
	} else if ((l <= 2.3e+31) || !(l <= 2.55e+132)) {
		tmp = t_0;
	} else {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	}
	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))
    if (l <= (-3.05d+293)) then
        tmp = t_0
    else if (l <= (-1050.0d0)) then
        tmp = ((64.0d0 / (u * u)) - (u * u)) * (u * (-0.125d0))
    else if ((l <= 2.3d+31) .or. (.not. (l <= 2.55d+132))) then
        tmp = t_0
    else
        tmp = u + (j * (0.125d0 + ((k * k) * (-0.015625d0))))
    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));
	double tmp;
	if (l <= -3.05e+293) {
		tmp = t_0;
	} else if (l <= -1050.0) {
		tmp = ((64.0 / (U * U)) - (U * U)) * (U * -0.125);
	} else if ((l <= 2.3e+31) || !(l <= 2.55e+132)) {
		tmp = t_0;
	} else {
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (2.0 * (l * J))
	tmp = 0
	if l <= -3.05e+293:
		tmp = t_0
	elif l <= -1050.0:
		tmp = ((64.0 / (U * U)) - (U * U)) * (U * -0.125)
	elif (l <= 2.3e+31) or not (l <= 2.55e+132):
		tmp = t_0
	else:
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(2.0 * Float64(l * J)))
	tmp = 0.0
	if (l <= -3.05e+293)
		tmp = t_0;
	elseif (l <= -1050.0)
		tmp = Float64(Float64(Float64(64.0 / Float64(U * U)) - Float64(U * U)) * Float64(U * -0.125));
	elseif ((l <= 2.3e+31) || !(l <= 2.55e+132))
		tmp = t_0;
	else
		tmp = Float64(U + Float64(J * Float64(0.125 + Float64(Float64(K * K) * -0.015625))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + (2.0 * (l * J));
	tmp = 0.0;
	if (l <= -3.05e+293)
		tmp = t_0;
	elseif (l <= -1050.0)
		tmp = ((64.0 / (U * U)) - (U * U)) * (U * -0.125);
	elseif ((l <= 2.3e+31) || ~((l <= 2.55e+132)))
		tmp = t_0;
	else
		tmp = U + (J * (0.125 + ((K * K) * -0.015625)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.05e+293], t$95$0, If[LessEqual[l, -1050.0], N[(N[(N[(64.0 / N[(U * U), $MachinePrecision]), $MachinePrecision] - N[(U * U), $MachinePrecision]), $MachinePrecision] * N[(U * -0.125), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 2.3e+31], N[Not[LessEqual[l, 2.55e+132]], $MachinePrecision]], t$95$0, N[(U + N[(J * N[(0.125 + N[(N[(K * K), $MachinePrecision] * -0.015625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -1050:\\
\;\;\;\;\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \left(U \cdot -0.125\right)\\

\mathbf{elif}\;\ell \leq 2.3 \cdot 10^{+31} \lor \neg \left(\ell \leq 2.55 \cdot 10^{+132}\right):\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.0499999999999998e293 or -1050 < l < 2.3e31 or 2.55e132 < l

    1. Initial program 77.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 82.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. *-commutative82.4%

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

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

        \[\leadsto 2 \cdot \left(\ell \cdot \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot J\right)}\right) + U \]
    4. Simplified82.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 70.5%

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

    if -3.0499999999999998e293 < l < -1050

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

      \[\leadsto \color{blue}{\frac{-8}{U} - U} \]
    3. Step-by-step derivation
      1. flip--31.1%

        \[\leadsto \color{blue}{\frac{\frac{-8}{U} \cdot \frac{-8}{U} - U \cdot U}{\frac{-8}{U} + U}} \]
      2. div-inv31.1%

        \[\leadsto \color{blue}{\left(\frac{-8}{U} \cdot \frac{-8}{U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U}} \]
      3. frac-times31.1%

        \[\leadsto \left(\color{blue}{\frac{-8 \cdot -8}{U \cdot U}} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U} \]
      4. metadata-eval31.1%

        \[\leadsto \left(\frac{\color{blue}{64}}{U \cdot U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U} \]
    4. Applied egg-rr31.1%

      \[\leadsto \color{blue}{\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \frac{1}{\frac{-8}{U} + U}} \]
    5. Taylor expanded in U around 0 33.3%

      \[\leadsto \left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \color{blue}{\left(-0.125 \cdot U\right)} \]
    6. Step-by-step derivation
      1. *-commutative33.3%

        \[\leadsto \left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \color{blue}{\left(U \cdot -0.125\right)} \]
    7. Simplified33.3%

      \[\leadsto \left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \color{blue}{\left(U \cdot -0.125\right)} \]

    if 2.3e31 < l < 2.55e132

    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-rr4.6%

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

      \[\leadsto \color{blue}{\left(0.125 \cdot J + -0.015625 \cdot \left({K}^{2} \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*45.0%

        \[\leadsto \left(0.125 \cdot J + \color{blue}{\left(-0.015625 \cdot {K}^{2}\right) \cdot J}\right) + U \]
      2. distribute-rgt-out45.0%

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

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

      \[\leadsto \color{blue}{J \cdot \left(0.125 + -0.015625 \cdot \left(K \cdot K\right)\right)} + U \]
  3. Recombined 3 regimes into one program.
  4. Final simplification59.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.05 \cdot 10^{+293}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{elif}\;\ell \leq -1050:\\ \;\;\;\;\left(\frac{64}{U \cdot U} - U \cdot U\right) \cdot \left(U \cdot -0.125\right)\\ \mathbf{elif}\;\ell \leq 2.3 \cdot 10^{+31} \lor \neg \left(\ell \leq 2.55 \cdot 10^{+132}\right):\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.125 + \left(K \cdot K\right) \cdot -0.015625\right)\\ \end{array} \]

Alternative 16: 39.1% accurate, 44.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.28 \cdot 10^{+33}:\\
\;\;\;\;U \cdot \left(U - -8\right)\\

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


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

    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-rr20.0%

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

    if -1.28e33 < l

    1. Initial program 80.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.28 \cdot 10^{+33}:\\ \;\;\;\;U \cdot \left(U - -8\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 17: 54.6% 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 85.3%

    \[\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 61.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. *-commutative61.4%

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

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

      \[\leadsto 2 \cdot \left(\ell \cdot \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot J\right)}\right) + U \]
  4. Simplified61.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 51.3%

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

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

Alternative 18: 39.1% accurate, 61.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.28 \cdot 10^{+33}:\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \end{array} \]
(FPCore (J l K U) :precision binary64 (if (<= l -1.28e+33) (* U U) U))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -1.28e+33) {
		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 <= (-1.28d+33)) 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 <= -1.28e+33) {
		tmp = U * U;
	} else {
		tmp = U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -1.28e+33:
		tmp = U * U
	else:
		tmp = U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -1.28e+33)
		tmp = Float64(U * U);
	else
		tmp = U;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -1.28e+33)
		tmp = U * U;
	else
		tmp = U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.28e+33], N[(U * U), $MachinePrecision], U]
\begin{array}{l}

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

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


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

    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-rr20.0%

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

    if -1.28e33 < l

    1. Initial program 80.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.28 \cdot 10^{+33}:\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 19: 2.4% accurate, 312.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 85.3%

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

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

    \[\leadsto \color{blue}{U - U} \]
  4. Step-by-step derivation
    1. +-inverses2.3%

      \[\leadsto \color{blue}{0} \]
  5. Simplified2.3%

    \[\leadsto \color{blue}{0} \]
  6. Final simplification2.3%

    \[\leadsto 0 \]

Alternative 20: 2.7% 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 85.3%

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

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

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

    \[\leadsto \color{blue}{1} \]
  5. Final simplification2.6%

    \[\leadsto 1 \]

Alternative 21: 36.8% 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 85.3%

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

    \[\leadsto \color{blue}{U} \]
  3. Final simplification32.3%

    \[\leadsto U \]

Reproduce

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