Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.6% → 99.4%
Time: 14.6s
Alternatives: 19
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 19 alternatives:

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

Initial Program: 86.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ (* 2.0 (* J (log1p (expm1 (* l (cos (* K 0.5))))))) U))
double code(double J, double l, double K, double U) {
	return (2.0 * (J * log1p(expm1((l * cos((K * 0.5))))))) + U;
}
public static double code(double J, double l, double K, double U) {
	return (2.0 * (J * Math.log1p(Math.expm1((l * Math.cos((K * 0.5))))))) + U;
}
def code(J, l, K, U):
	return (2.0 * (J * math.log1p(math.expm1((l * math.cos((K * 0.5))))))) + U
function code(J, l, K, U)
	return Float64(Float64(2.0 * Float64(J * log1p(expm1(Float64(l * cos(Float64(K * 0.5))))))) + U)
end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * N[Log[1 + N[(Exp[N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U
\end{array}
Derivation
  1. Initial program 85.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 71.1%

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

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

      \[\leadsto 2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \cos \color{blue}{\left(K \cdot 0.5\right)}\right)\right)\right) + U \]
  4. Applied egg-rr99.6%

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

    \[\leadsto 2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U \]

Alternative 2: 94.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \mathbf{if}\;\ell \leq -1.9 \cdot 10^{+123}:\\ \;\;\;\;U + \left(\left(J \cdot 0.3333333333333333\right) \cdot {\ell}^{3}\right) \cdot t_0\\ \mathbf{elif}\;\ell \leq -110:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 0.00069 \lor \neg \left(\ell \leq 2.9 \cdot 10^{+84}\right):\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + t_1\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))) (t_1 (* J (- (exp l) (exp (- l))))))
   (if (<= l -1.9e+123)
     (+ U (* (* (* J 0.3333333333333333) (pow l 3.0)) t_0))
     (if (<= l -110.0)
       t_1
       (if (or (<= l 0.00069) (not (<= l 2.9e+84)))
         (+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* 2.0 l)))))
         (+ U t_1))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = J * (exp(l) - exp(-l));
	double tmp;
	if (l <= -1.9e+123) {
		tmp = U + (((J * 0.3333333333333333) * pow(l, 3.0)) * t_0);
	} else if (l <= -110.0) {
		tmp = t_1;
	} else if ((l <= 0.00069) || !(l <= 2.9e+84)) {
		tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (2.0 * l))));
	} else {
		tmp = U + 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) :: tmp
    t_0 = cos((k / 2.0d0))
    t_1 = j * (exp(l) - exp(-l))
    if (l <= (-1.9d+123)) then
        tmp = u + (((j * 0.3333333333333333d0) * (l ** 3.0d0)) * t_0)
    else if (l <= (-110.0d0)) then
        tmp = t_1
    else if ((l <= 0.00069d0) .or. (.not. (l <= 2.9d+84))) then
        tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (2.0d0 * l))))
    else
        tmp = u + t_1
    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 = J * (Math.exp(l) - Math.exp(-l));
	double tmp;
	if (l <= -1.9e+123) {
		tmp = U + (((J * 0.3333333333333333) * Math.pow(l, 3.0)) * t_0);
	} else if (l <= -110.0) {
		tmp = t_1;
	} else if ((l <= 0.00069) || !(l <= 2.9e+84)) {
		tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (2.0 * l))));
	} else {
		tmp = U + t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = J * (math.exp(l) - math.exp(-l))
	tmp = 0
	if l <= -1.9e+123:
		tmp = U + (((J * 0.3333333333333333) * math.pow(l, 3.0)) * t_0)
	elif l <= -110.0:
		tmp = t_1
	elif (l <= 0.00069) or not (l <= 2.9e+84):
		tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (2.0 * l))))
	else:
		tmp = U + t_1
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(J * Float64(exp(l) - exp(Float64(-l))))
	tmp = 0.0
	if (l <= -1.9e+123)
		tmp = Float64(U + Float64(Float64(Float64(J * 0.3333333333333333) * (l ^ 3.0)) * t_0));
	elseif (l <= -110.0)
		tmp = t_1;
	elseif ((l <= 0.00069) || !(l <= 2.9e+84))
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(2.0 * l)))));
	else
		tmp = Float64(U + t_1);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K / 2.0));
	t_1 = J * (exp(l) - exp(-l));
	tmp = 0.0;
	if (l <= -1.9e+123)
		tmp = U + (((J * 0.3333333333333333) * (l ^ 3.0)) * t_0);
	elseif (l <= -110.0)
		tmp = t_1;
	elseif ((l <= 0.00069) || ~((l <= 2.9e+84)))
		tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (2.0 * l))));
	else
		tmp = U + t_1;
	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[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.9e+123], N[(U + N[(N[(N[(J * 0.3333333333333333), $MachinePrecision] * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -110.0], t$95$1, If[Or[LessEqual[l, 0.00069], N[Not[LessEqual[l, 2.9e+84]], $MachinePrecision]], N[(U + N[(t$95$0 * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 0.00069 \lor \neg \left(\ell \leq 2.9 \cdot 10^{+84}\right):\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

    if -1.89999999999999997e123 < l < -110

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

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

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

    if -110 < l < 6.89999999999999967e-4 or 2.89999999999999989e84 < l

    1. Initial program 79.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 98.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 \]

    if 6.89999999999999967e-4 < l < 2.89999999999999989e84

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.9 \cdot 10^{+123}:\\ \;\;\;\;U + \left(\left(J \cdot 0.3333333333333333\right) \cdot {\ell}^{3}\right) \cdot \cos \left(\frac{K}{2}\right)\\ \mathbf{elif}\;\ell \leq -110:\\ \;\;\;\;J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \mathbf{elif}\;\ell \leq 0.00069 \lor \neg \left(\ell \leq 2.9 \cdot 10^{+84}\right):\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \end{array} \]

Alternative 3: 93.3% accurate, 1.4× speedup?

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

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

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

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

\mathbf{elif}\;\ell \leq 2.9 \cdot 10^{+84}:\\
\;\;\;\;U + t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.89999999999999997e123 or 2.89999999999999989e84 < 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 97.6%

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

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

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

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

    if -1.89999999999999997e123 < l < -3.49999999999999996e-4

    1. Initial program 99.4%

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

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

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

    if -3.49999999999999996e-4 < l < 4.40000000000000037e-47

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

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

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

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

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

    if 4.40000000000000037e-47 < l < 2.89999999999999989e84

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.9 \cdot 10^{+123}:\\ \;\;\;\;U + \left(\left(J \cdot 0.3333333333333333\right) \cdot {\ell}^{3}\right) \cdot \cos \left(\frac{K}{2}\right)\\ \mathbf{elif}\;\ell \leq -0.00035:\\ \;\;\;\;J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \mathbf{elif}\;\ell \leq 4.4 \cdot 10^{-47}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\ \mathbf{elif}\;\ell \leq 2.9 \cdot 10^{+84}:\\ \;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(\left(J \cdot 0.3333333333333333\right) \cdot {\ell}^{3}\right) \cdot \cos \left(\frac{K}{2}\right)\\ \end{array} \]

Alternative 4: 78.2% accurate, 1.4× speedup?

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

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

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


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

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

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

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

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

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

    if 0.52200000000000002 < (cos.f64 (/.f64 K 2))

    1. Initial program 88.2%

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

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

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

Alternative 5: 80.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \mathbf{if}\;\ell \leq -0.00035:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 220:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+89}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot {K}^{2}\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* J (- (exp l) (exp (- l))))))
   (if (<= l -0.00035)
     t_0
     (if (<= l 220.0)
       (+ U (* (cos (/ K 2.0)) (* l (* 2.0 J))))
       (if (<= l 2.4e+89)
         t_0
         (+ U (* 2.0 (* J (+ l (* -0.125 (* l (pow K 2.0))))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = J * (exp(l) - exp(-l));
	double tmp;
	if (l <= -0.00035) {
		tmp = t_0;
	} else if (l <= 220.0) {
		tmp = U + (cos((K / 2.0)) * (l * (2.0 * J)));
	} else if (l <= 2.4e+89) {
		tmp = t_0;
	} else {
		tmp = U + (2.0 * (J * (l + (-0.125 * (l * pow(K, 2.0))))));
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: tmp
    t_0 = j * (exp(l) - exp(-l))
    if (l <= (-0.00035d0)) then
        tmp = t_0
    else if (l <= 220.0d0) then
        tmp = u + (cos((k / 2.0d0)) * (l * (2.0d0 * j)))
    else if (l <= 2.4d+89) then
        tmp = t_0
    else
        tmp = u + (2.0d0 * (j * (l + ((-0.125d0) * (l * (k ** 2.0d0))))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = J * (Math.exp(l) - Math.exp(-l));
	double tmp;
	if (l <= -0.00035) {
		tmp = t_0;
	} else if (l <= 220.0) {
		tmp = U + (Math.cos((K / 2.0)) * (l * (2.0 * J)));
	} else if (l <= 2.4e+89) {
		tmp = t_0;
	} else {
		tmp = U + (2.0 * (J * (l + (-0.125 * (l * Math.pow(K, 2.0))))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = J * (math.exp(l) - math.exp(-l))
	tmp = 0
	if l <= -0.00035:
		tmp = t_0
	elif l <= 220.0:
		tmp = U + (math.cos((K / 2.0)) * (l * (2.0 * J)))
	elif l <= 2.4e+89:
		tmp = t_0
	else:
		tmp = U + (2.0 * (J * (l + (-0.125 * (l * math.pow(K, 2.0))))))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(J * Float64(exp(l) - exp(Float64(-l))))
	tmp = 0.0
	if (l <= -0.00035)
		tmp = t_0;
	elseif (l <= 220.0)
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(2.0 * J))));
	elseif (l <= 2.4e+89)
		tmp = t_0;
	else
		tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l + Float64(-0.125 * Float64(l * (K ^ 2.0)))))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = J * (exp(l) - exp(-l));
	tmp = 0.0;
	if (l <= -0.00035)
		tmp = t_0;
	elseif (l <= 220.0)
		tmp = U + (cos((K / 2.0)) * (l * (2.0 * J)));
	elseif (l <= 2.4e+89)
		tmp = t_0;
	else
		tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K ^ 2.0))))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -0.00035], t$95$0, If[LessEqual[l, 220.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.4e+89], t$95$0, N[(U + N[(2.0 * N[(J * N[(l + N[(-0.125 * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;\ell \leq -0.00035:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+89}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.49999999999999996e-4 or 220 < l < 2.40000000000000004e89

    1. Initial program 99.8%

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

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

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

    if -3.49999999999999996e-4 < l < 220

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

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

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

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

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

    if 2.40000000000000004e89 < 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 48.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -0.00035:\\ \;\;\;\;J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \mathbf{elif}\;\ell \leq 220:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+89}:\\ \;\;\;\;J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot {K}^{2}\right)\right)\right)\\ \end{array} \]

Alternative 6: 82.1% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.6 \cdot 10^{+80} \lor \neg \left(J \leq 5.8 \cdot 10^{+43}\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if J < -2.59999999999999982e80 or 5.8000000000000004e43 < J

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

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

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

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

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

    if -2.59999999999999982e80 < J < 5.8000000000000004e43

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

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

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

Alternative 7: 75.8% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -4150000000000:\\ \;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\ \mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107} \lor \neg \left(\ell \leq 1.5 \cdot 10^{+261}\right):\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* 0.3333333333333333 (* J (pow l 3.0)))))
   (if (<= l -4e+91)
     t_0
     (if (<= l -4150000000000.0)
       (fabs (* U (+ U 4.0)))
       (if (or (<= l 1.2e+107) (not (<= l 1.5e+261)))
         (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
         t_0)))))
double code(double J, double l, double K, double U) {
	double t_0 = 0.3333333333333333 * (J * pow(l, 3.0));
	double tmp;
	if (l <= -4e+91) {
		tmp = t_0;
	} else if (l <= -4150000000000.0) {
		tmp = fabs((U * (U + 4.0)));
	} else if ((l <= 1.2e+107) || !(l <= 1.5e+261)) {
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	} 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 = 0.3333333333333333d0 * (j * (l ** 3.0d0))
    if (l <= (-4d+91)) then
        tmp = t_0
    else if (l <= (-4150000000000.0d0)) then
        tmp = abs((u * (u + 4.0d0)))
    else if ((l <= 1.2d+107) .or. (.not. (l <= 1.5d+261))) then
        tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
    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 = 0.3333333333333333 * (J * Math.pow(l, 3.0));
	double tmp;
	if (l <= -4e+91) {
		tmp = t_0;
	} else if (l <= -4150000000000.0) {
		tmp = Math.abs((U * (U + 4.0)));
	} else if ((l <= 1.2e+107) || !(l <= 1.5e+261)) {
		tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = 0.3333333333333333 * (J * math.pow(l, 3.0))
	tmp = 0
	if l <= -4e+91:
		tmp = t_0
	elif l <= -4150000000000.0:
		tmp = math.fabs((U * (U + 4.0)))
	elif (l <= 1.2e+107) or not (l <= 1.5e+261):
		tmp = U + (2.0 * (J * (l * math.cos((K * 0.5)))))
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))
	tmp = 0.0
	if (l <= -4e+91)
		tmp = t_0;
	elseif (l <= -4150000000000.0)
		tmp = abs(Float64(U * Float64(U + 4.0)));
	elseif ((l <= 1.2e+107) || !(l <= 1.5e+261))
		tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5))))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = 0.3333333333333333 * (J * (l ^ 3.0));
	tmp = 0.0;
	if (l <= -4e+91)
		tmp = t_0;
	elseif (l <= -4150000000000.0)
		tmp = abs((U * (U + 4.0)));
	elseif ((l <= 1.2e+107) || ~((l <= 1.5e+261)))
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4e+91], t$95$0, If[LessEqual[l, -4150000000000.0], N[Abs[N[(U * N[(U + 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[l, 1.2e+107], N[Not[LessEqual[l, 1.5e+261]], $MachinePrecision]], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -4150000000000:\\
\;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\

\mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107} \lor \neg \left(\ell \leq 1.5 \cdot 10^{+261}\right):\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.00000000000000032e91 or 1.2e107 < l < 1.49999999999999989e261

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

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)} \]
    5. Step-by-step derivation
      1. *-commutative74.0%

        \[\leadsto 0.3333333333333333 \cdot \color{blue}{\left({\ell}^{3} \cdot J\right)} \]
    6. Simplified74.0%

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

    if -4.00000000000000032e91 < l < -4.15e12

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

      \[\leadsto \color{blue}{U \cdot \left(U - -4\right)} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt39.2%

        \[\leadsto \color{blue}{\sqrt{U \cdot \left(U - -4\right)} \cdot \sqrt{U \cdot \left(U - -4\right)}} \]
      2. sqrt-unprod39.3%

        \[\leadsto \color{blue}{\sqrt{\left(U \cdot \left(U - -4\right)\right) \cdot \left(U \cdot \left(U - -4\right)\right)}} \]
      3. pow239.3%

        \[\leadsto \sqrt{\color{blue}{{\left(U \cdot \left(U - -4\right)\right)}^{2}}} \]
      4. *-un-lft-identity39.3%

        \[\leadsto \sqrt{{\left(U \cdot \color{blue}{\left(1 \cdot \left(U - -4\right)\right)}\right)}^{2}} \]
      5. sub-neg39.3%

        \[\leadsto \sqrt{{\left(U \cdot \left(1 \cdot \color{blue}{\left(U + \left(--4\right)\right)}\right)\right)}^{2}} \]
      6. *-un-lft-identity39.3%

        \[\leadsto \sqrt{{\left(U \cdot \color{blue}{\left(U + \left(--4\right)\right)}\right)}^{2}} \]
      7. metadata-eval39.3%

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

      \[\leadsto \color{blue}{\sqrt{{\left(U \cdot \left(U + 4\right)\right)}^{2}}} \]
    5. Step-by-step derivation
      1. unpow239.3%

        \[\leadsto \sqrt{\color{blue}{\left(U \cdot \left(U + 4\right)\right) \cdot \left(U \cdot \left(U + 4\right)\right)}} \]
      2. rem-sqrt-square39.4%

        \[\leadsto \color{blue}{\left|U \cdot \left(U + 4\right)\right|} \]
      3. +-commutative39.4%

        \[\leadsto \left|U \cdot \color{blue}{\left(4 + U\right)}\right| \]
    6. Simplified39.4%

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

    if -4.15e12 < l < 1.2e107 or 1.49999999999999989e261 < l

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\ \;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -4150000000000:\\ \;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\ \mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107} \lor \neg \left(\ell \leq 1.5 \cdot 10^{+261}\right):\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \end{array} \]

Alternative 8: 75.8% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ t_1 := \cos \left(K \cdot 0.5\right)\\ \mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -14600000000000:\\ \;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\ \mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107}:\\ \;\;\;\;U + \ell \cdot \left(\left(2 \cdot J\right) \cdot t_1\right)\\ \mathbf{elif}\;\ell \leq 1.5 \cdot 10^{+261}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t_1\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* 0.3333333333333333 (* J (pow l 3.0)))) (t_1 (cos (* K 0.5))))
   (if (<= l -4e+91)
     t_0
     (if (<= l -14600000000000.0)
       (fabs (* U (+ U 4.0)))
       (if (<= l 1.2e+107)
         (+ U (* l (* (* 2.0 J) t_1)))
         (if (<= l 1.5e+261) t_0 (+ U (* 2.0 (* J (* l t_1))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = 0.3333333333333333 * (J * pow(l, 3.0));
	double t_1 = cos((K * 0.5));
	double tmp;
	if (l <= -4e+91) {
		tmp = t_0;
	} else if (l <= -14600000000000.0) {
		tmp = fabs((U * (U + 4.0)));
	} else if (l <= 1.2e+107) {
		tmp = U + (l * ((2.0 * J) * t_1));
	} else if (l <= 1.5e+261) {
		tmp = t_0;
	} else {
		tmp = U + (2.0 * (J * (l * 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) :: tmp
    t_0 = 0.3333333333333333d0 * (j * (l ** 3.0d0))
    t_1 = cos((k * 0.5d0))
    if (l <= (-4d+91)) then
        tmp = t_0
    else if (l <= (-14600000000000.0d0)) then
        tmp = abs((u * (u + 4.0d0)))
    else if (l <= 1.2d+107) then
        tmp = u + (l * ((2.0d0 * j) * t_1))
    else if (l <= 1.5d+261) then
        tmp = t_0
    else
        tmp = u + (2.0d0 * (j * (l * t_1)))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = 0.3333333333333333 * (J * Math.pow(l, 3.0));
	double t_1 = Math.cos((K * 0.5));
	double tmp;
	if (l <= -4e+91) {
		tmp = t_0;
	} else if (l <= -14600000000000.0) {
		tmp = Math.abs((U * (U + 4.0)));
	} else if (l <= 1.2e+107) {
		tmp = U + (l * ((2.0 * J) * t_1));
	} else if (l <= 1.5e+261) {
		tmp = t_0;
	} else {
		tmp = U + (2.0 * (J * (l * t_1)));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = 0.3333333333333333 * (J * math.pow(l, 3.0))
	t_1 = math.cos((K * 0.5))
	tmp = 0
	if l <= -4e+91:
		tmp = t_0
	elif l <= -14600000000000.0:
		tmp = math.fabs((U * (U + 4.0)))
	elif l <= 1.2e+107:
		tmp = U + (l * ((2.0 * J) * t_1))
	elif l <= 1.5e+261:
		tmp = t_0
	else:
		tmp = U + (2.0 * (J * (l * t_1)))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))
	t_1 = cos(Float64(K * 0.5))
	tmp = 0.0
	if (l <= -4e+91)
		tmp = t_0;
	elseif (l <= -14600000000000.0)
		tmp = abs(Float64(U * Float64(U + 4.0)));
	elseif (l <= 1.2e+107)
		tmp = Float64(U + Float64(l * Float64(Float64(2.0 * J) * t_1)));
	elseif (l <= 1.5e+261)
		tmp = t_0;
	else
		tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_1))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = 0.3333333333333333 * (J * (l ^ 3.0));
	t_1 = cos((K * 0.5));
	tmp = 0.0;
	if (l <= -4e+91)
		tmp = t_0;
	elseif (l <= -14600000000000.0)
		tmp = abs((U * (U + 4.0)));
	elseif (l <= 1.2e+107)
		tmp = U + (l * ((2.0 * J) * t_1));
	elseif (l <= 1.5e+261)
		tmp = t_0;
	else
		tmp = U + (2.0 * (J * (l * t_1)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -4e+91], t$95$0, If[LessEqual[l, -14600000000000.0], N[Abs[N[(U * N[(U + 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 1.2e+107], N[(U + N[(l * N[(N[(2.0 * J), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.5e+261], t$95$0, N[(U + N[(2.0 * N[(J * N[(l * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
t_1 := \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -14600000000000:\\
\;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\

\mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107}:\\
\;\;\;\;U + \ell \cdot \left(\left(2 \cdot J\right) \cdot t_1\right)\\

\mathbf{elif}\;\ell \leq 1.5 \cdot 10^{+261}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -4.00000000000000032e91 or 1.2e107 < l < 1.49999999999999989e261

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

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)} \]
    5. Step-by-step derivation
      1. *-commutative74.0%

        \[\leadsto 0.3333333333333333 \cdot \color{blue}{\left({\ell}^{3} \cdot J\right)} \]
    6. Simplified74.0%

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

    if -4.00000000000000032e91 < l < -1.46e13

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

      \[\leadsto \color{blue}{U \cdot \left(U - -4\right)} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt39.2%

        \[\leadsto \color{blue}{\sqrt{U \cdot \left(U - -4\right)} \cdot \sqrt{U \cdot \left(U - -4\right)}} \]
      2. sqrt-unprod39.3%

        \[\leadsto \color{blue}{\sqrt{\left(U \cdot \left(U - -4\right)\right) \cdot \left(U \cdot \left(U - -4\right)\right)}} \]
      3. pow239.3%

        \[\leadsto \sqrt{\color{blue}{{\left(U \cdot \left(U - -4\right)\right)}^{2}}} \]
      4. *-un-lft-identity39.3%

        \[\leadsto \sqrt{{\left(U \cdot \color{blue}{\left(1 \cdot \left(U - -4\right)\right)}\right)}^{2}} \]
      5. sub-neg39.3%

        \[\leadsto \sqrt{{\left(U \cdot \left(1 \cdot \color{blue}{\left(U + \left(--4\right)\right)}\right)\right)}^{2}} \]
      6. *-un-lft-identity39.3%

        \[\leadsto \sqrt{{\left(U \cdot \color{blue}{\left(U + \left(--4\right)\right)}\right)}^{2}} \]
      7. metadata-eval39.3%

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

      \[\leadsto \color{blue}{\sqrt{{\left(U \cdot \left(U + 4\right)\right)}^{2}}} \]
    5. Step-by-step derivation
      1. unpow239.3%

        \[\leadsto \sqrt{\color{blue}{\left(U \cdot \left(U + 4\right)\right) \cdot \left(U \cdot \left(U + 4\right)\right)}} \]
      2. rem-sqrt-square39.4%

        \[\leadsto \color{blue}{\left|U \cdot \left(U + 4\right)\right|} \]
      3. +-commutative39.4%

        \[\leadsto \left|U \cdot \color{blue}{\left(4 + U\right)}\right| \]
    6. Simplified39.4%

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

    if -1.46e13 < l < 1.2e107

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

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

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

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

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

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

    if 1.49999999999999989e261 < 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 73.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\ \;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -14600000000000:\\ \;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\ \mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107}:\\ \;\;\;\;U + \ell \cdot \left(\left(2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;\ell \leq 1.5 \cdot 10^{+261}:\\ \;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \end{array} \]

Alternative 9: 75.8% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -8.4 \cdot 10^{+14}:\\ \;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\ \mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\ \mathbf{elif}\;\ell \leq 1.35 \cdot 10^{+261}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* 0.3333333333333333 (* J (pow l 3.0)))))
   (if (<= l -4e+91)
     t_0
     (if (<= l -8.4e+14)
       (fabs (* U (+ U 4.0)))
       (if (<= l 1.2e+107)
         (+ U (* (cos (/ K 2.0)) (* l (* 2.0 J))))
         (if (<= l 1.35e+261)
           t_0
           (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = 0.3333333333333333 * (J * pow(l, 3.0));
	double tmp;
	if (l <= -4e+91) {
		tmp = t_0;
	} else if (l <= -8.4e+14) {
		tmp = fabs((U * (U + 4.0)));
	} else if (l <= 1.2e+107) {
		tmp = U + (cos((K / 2.0)) * (l * (2.0 * J)));
	} else if (l <= 1.35e+261) {
		tmp = t_0;
	} else {
		tmp = U + (2.0 * (J * (l * 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) :: t_0
    real(8) :: tmp
    t_0 = 0.3333333333333333d0 * (j * (l ** 3.0d0))
    if (l <= (-4d+91)) then
        tmp = t_0
    else if (l <= (-8.4d+14)) then
        tmp = abs((u * (u + 4.0d0)))
    else if (l <= 1.2d+107) then
        tmp = u + (cos((k / 2.0d0)) * (l * (2.0d0 * j)))
    else if (l <= 1.35d+261) then
        tmp = t_0
    else
        tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = 0.3333333333333333 * (J * Math.pow(l, 3.0));
	double tmp;
	if (l <= -4e+91) {
		tmp = t_0;
	} else if (l <= -8.4e+14) {
		tmp = Math.abs((U * (U + 4.0)));
	} else if (l <= 1.2e+107) {
		tmp = U + (Math.cos((K / 2.0)) * (l * (2.0 * J)));
	} else if (l <= 1.35e+261) {
		tmp = t_0;
	} else {
		tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = 0.3333333333333333 * (J * math.pow(l, 3.0))
	tmp = 0
	if l <= -4e+91:
		tmp = t_0
	elif l <= -8.4e+14:
		tmp = math.fabs((U * (U + 4.0)))
	elif l <= 1.2e+107:
		tmp = U + (math.cos((K / 2.0)) * (l * (2.0 * J)))
	elif l <= 1.35e+261:
		tmp = t_0
	else:
		tmp = U + (2.0 * (J * (l * math.cos((K * 0.5)))))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))
	tmp = 0.0
	if (l <= -4e+91)
		tmp = t_0;
	elseif (l <= -8.4e+14)
		tmp = abs(Float64(U * Float64(U + 4.0)));
	elseif (l <= 1.2e+107)
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(2.0 * J))));
	elseif (l <= 1.35e+261)
		tmp = t_0;
	else
		tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5))))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = 0.3333333333333333 * (J * (l ^ 3.0));
	tmp = 0.0;
	if (l <= -4e+91)
		tmp = t_0;
	elseif (l <= -8.4e+14)
		tmp = abs((U * (U + 4.0)));
	elseif (l <= 1.2e+107)
		tmp = U + (cos((K / 2.0)) * (l * (2.0 * J)));
	elseif (l <= 1.35e+261)
		tmp = t_0;
	else
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4e+91], t$95$0, If[LessEqual[l, -8.4e+14], N[Abs[N[(U * N[(U + 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 1.2e+107], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.35e+261], t$95$0, N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -8.4 \cdot 10^{+14}:\\
\;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\

\mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\

\mathbf{elif}\;\ell \leq 1.35 \cdot 10^{+261}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -4.00000000000000032e91 or 1.2e107 < l < 1.35000000000000001e261

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

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)} \]
    5. Step-by-step derivation
      1. *-commutative74.0%

        \[\leadsto 0.3333333333333333 \cdot \color{blue}{\left({\ell}^{3} \cdot J\right)} \]
    6. Simplified74.0%

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

    if -4.00000000000000032e91 < l < -8.4e14

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

      \[\leadsto \color{blue}{U \cdot \left(U - -4\right)} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt39.2%

        \[\leadsto \color{blue}{\sqrt{U \cdot \left(U - -4\right)} \cdot \sqrt{U \cdot \left(U - -4\right)}} \]
      2. sqrt-unprod39.3%

        \[\leadsto \color{blue}{\sqrt{\left(U \cdot \left(U - -4\right)\right) \cdot \left(U \cdot \left(U - -4\right)\right)}} \]
      3. pow239.3%

        \[\leadsto \sqrt{\color{blue}{{\left(U \cdot \left(U - -4\right)\right)}^{2}}} \]
      4. *-un-lft-identity39.3%

        \[\leadsto \sqrt{{\left(U \cdot \color{blue}{\left(1 \cdot \left(U - -4\right)\right)}\right)}^{2}} \]
      5. sub-neg39.3%

        \[\leadsto \sqrt{{\left(U \cdot \left(1 \cdot \color{blue}{\left(U + \left(--4\right)\right)}\right)\right)}^{2}} \]
      6. *-un-lft-identity39.3%

        \[\leadsto \sqrt{{\left(U \cdot \color{blue}{\left(U + \left(--4\right)\right)}\right)}^{2}} \]
      7. metadata-eval39.3%

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

      \[\leadsto \color{blue}{\sqrt{{\left(U \cdot \left(U + 4\right)\right)}^{2}}} \]
    5. Step-by-step derivation
      1. unpow239.3%

        \[\leadsto \sqrt{\color{blue}{\left(U \cdot \left(U + 4\right)\right) \cdot \left(U \cdot \left(U + 4\right)\right)}} \]
      2. rem-sqrt-square39.4%

        \[\leadsto \color{blue}{\left|U \cdot \left(U + 4\right)\right|} \]
      3. +-commutative39.4%

        \[\leadsto \left|U \cdot \color{blue}{\left(4 + U\right)}\right| \]
    6. Simplified39.4%

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

    if -8.4e14 < l < 1.2e107

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

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

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

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

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

    if 1.35000000000000001e261 < 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 73.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\ \;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -8.4 \cdot 10^{+14}:\\ \;\;\;\;\left|U \cdot \left(U + 4\right)\right|\\ \mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+107}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\ \mathbf{elif}\;\ell \leq 1.35 \cdot 10^{+261}:\\ \;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \end{array} \]

Alternative 10: 71.4% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -170000:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 7600000:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* 0.3333333333333333 (* J (pow l 3.0)))))
   (if (<= l -4e+91)
     t_0
     (if (<= l -170000.0)
       (* U (- U -4.0))
       (if (<= l 7600000.0) (fma (* 2.0 J) l U) t_0)))))
double code(double J, double l, double K, double U) {
	double t_0 = 0.3333333333333333 * (J * pow(l, 3.0));
	double tmp;
	if (l <= -4e+91) {
		tmp = t_0;
	} else if (l <= -170000.0) {
		tmp = U * (U - -4.0);
	} else if (l <= 7600000.0) {
		tmp = fma((2.0 * J), l, U);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))
	tmp = 0.0
	if (l <= -4e+91)
		tmp = t_0;
	elseif (l <= -170000.0)
		tmp = Float64(U * Float64(U - -4.0));
	elseif (l <= 7600000.0)
		tmp = fma(Float64(2.0 * J), l, U);
	else
		tmp = t_0;
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4e+91], t$95$0, If[LessEqual[l, -170000.0], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7600000.0], N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -170000:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.00000000000000032e91 or 7.6e6 < 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 86.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 59.1%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)} \]
    5. Step-by-step derivation
      1. *-commutative59.1%

        \[\leadsto 0.3333333333333333 \cdot \color{blue}{\left({\ell}^{3} \cdot J\right)} \]
    6. Simplified59.1%

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

    if -4.00000000000000032e91 < l < -1.7e5

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

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

    if -1.7e5 < l < 7.6e6

    1. Initial program 73.7%

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

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

      \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) + U \]
    4. Taylor expanded in J around 0 84.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4 \cdot 10^{+91}:\\ \;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -170000:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 7600000:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \end{array} \]

Alternative 11: 53.6% accurate, 3.0× speedup?

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

\\
\mathsf{fma}\left(2 \cdot J, \ell, U\right)
\end{array}
Derivation
  1. Initial program 85.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 71.1%

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

    \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) + U \]
  4. Taylor expanded in J around 0 57.7%

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

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

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

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

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

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

Alternative 12: 42.2% accurate, 27.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.4 \cdot 10^{+110}:\\
\;\;\;\;U \cdot \left(16 - U\right)\\

\mathbf{elif}\;\ell \leq -132000:\\
\;\;\;\;U \cdot U\\

\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+70}:\\
\;\;\;\;U\\

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


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

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

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

      \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) + U \]
    4. Applied egg-rr22.3%

      \[\leadsto \color{blue}{U \cdot \left(-\left(U + -16\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative22.3%

        \[\leadsto U \cdot \left(-\color{blue}{\left(-16 + U\right)}\right) \]
      2. distribute-neg-in22.3%

        \[\leadsto U \cdot \color{blue}{\left(\left(--16\right) + \left(-U\right)\right)} \]
      3. metadata-eval22.3%

        \[\leadsto U \cdot \left(\color{blue}{16} + \left(-U\right)\right) \]
      4. sub-neg22.3%

        \[\leadsto U \cdot \color{blue}{\left(16 - U\right)} \]
    6. Simplified22.3%

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

    if -3.4000000000000001e110 < l < -132000

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

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

    if -132000 < l < 1.39999999999999995e70

    1. Initial program 75.8%

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

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

    if 1.39999999999999995e70 < 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 48.0%

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

      \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) + U \]
    4. Applied egg-rr15.5%

      \[\leadsto \color{blue}{\left(U + -16\right) \cdot U} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification47.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.4 \cdot 10^{+110}:\\ \;\;\;\;U \cdot \left(16 - U\right)\\ \mathbf{elif}\;\ell \leq -132000:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+70}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U + -16\right)\\ \end{array} \]

Alternative 13: 42.2% accurate, 27.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -3.7 \cdot 10^{+110}:\\ \;\;\;\;U \cdot \frac{U}{-3}\\ \mathbf{elif}\;\ell \leq -132000:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq 5.7 \cdot 10^{+66}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U + -16\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -3.7e+110)
   (* U (/ U -3.0))
   (if (<= l -132000.0) (* U U) (if (<= l 5.7e+66) U (* U (+ U -16.0))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -3.7e+110) {
		tmp = U * (U / -3.0);
	} else if (l <= -132000.0) {
		tmp = U * U;
	} else if (l <= 5.7e+66) {
		tmp = U;
	} else {
		tmp = U * (U + -16.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 <= (-3.7d+110)) then
        tmp = u * (u / (-3.0d0))
    else if (l <= (-132000.0d0)) then
        tmp = u * u
    else if (l <= 5.7d+66) then
        tmp = u
    else
        tmp = u * (u + (-16.0d0))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -3.7e+110) {
		tmp = U * (U / -3.0);
	} else if (l <= -132000.0) {
		tmp = U * U;
	} else if (l <= 5.7e+66) {
		tmp = U;
	} else {
		tmp = U * (U + -16.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -3.7e+110:
		tmp = U * (U / -3.0)
	elif l <= -132000.0:
		tmp = U * U
	elif l <= 5.7e+66:
		tmp = U
	else:
		tmp = U * (U + -16.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -3.7e+110)
		tmp = Float64(U * Float64(U / -3.0));
	elseif (l <= -132000.0)
		tmp = Float64(U * U);
	elseif (l <= 5.7e+66)
		tmp = U;
	else
		tmp = Float64(U * Float64(U + -16.0));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -3.7e+110)
		tmp = U * (U / -3.0);
	elseif (l <= -132000.0)
		tmp = U * U;
	elseif (l <= 5.7e+66)
		tmp = U;
	else
		tmp = U * (U + -16.0);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -3.7e+110], N[(U * N[(U / -3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -132000.0], N[(U * U), $MachinePrecision], If[LessEqual[l, 5.7e+66], U, N[(U * N[(U + -16.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.7 \cdot 10^{+110}:\\
\;\;\;\;U \cdot \frac{U}{-3}\\

\mathbf{elif}\;\ell \leq -132000:\\
\;\;\;\;U \cdot U\\

\mathbf{elif}\;\ell \leq 5.7 \cdot 10^{+66}:\\
\;\;\;\;U\\

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


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

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

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

      \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) + U \]
    4. Applied egg-rr22.5%

      \[\leadsto \color{blue}{\frac{U}{-3} \cdot U} \]

    if -3.70000000000000012e110 < l < -132000

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

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

    if -132000 < l < 5.7000000000000003e66

    1. Initial program 75.8%

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

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

    if 5.7000000000000003e66 < 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 48.0%

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

      \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) + U \]
    4. Applied egg-rr15.5%

      \[\leadsto \color{blue}{\left(U + -16\right) \cdot U} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification47.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.7 \cdot 10^{+110}:\\ \;\;\;\;U \cdot \frac{U}{-3}\\ \mathbf{elif}\;\ell \leq -132000:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq 5.7 \cdot 10^{+66}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U + -16\right)\\ \end{array} \]

Alternative 14: 42.2% accurate, 33.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.3 \cdot 10^{+110}:\\
\;\;\;\;U \cdot \left(16 - U\right)\\

\mathbf{elif}\;\ell \leq -132000 \lor \neg \left(\ell \leq 3.1 \cdot 10^{+66}\right):\\
\;\;\;\;U \cdot U\\

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


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

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

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

      \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) + U \]
    4. Applied egg-rr22.3%

      \[\leadsto \color{blue}{U \cdot \left(-\left(U + -16\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative22.3%

        \[\leadsto U \cdot \left(-\color{blue}{\left(-16 + U\right)}\right) \]
      2. distribute-neg-in22.3%

        \[\leadsto U \cdot \color{blue}{\left(\left(--16\right) + \left(-U\right)\right)} \]
      3. metadata-eval22.3%

        \[\leadsto U \cdot \left(\color{blue}{16} + \left(-U\right)\right) \]
      4. sub-neg22.3%

        \[\leadsto U \cdot \color{blue}{\left(16 - U\right)} \]
    6. Simplified22.3%

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

    if -4.30000000000000007e110 < l < -132000 or 3.10000000000000019e66 < 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. Applied egg-rr20.5%

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

    if -132000 < l < 3.10000000000000019e66

    1. Initial program 75.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.3 \cdot 10^{+110}:\\ \;\;\;\;U \cdot \left(16 - U\right)\\ \mathbf{elif}\;\ell \leq -132000 \lor \neg \left(\ell \leq 3.1 \cdot 10^{+66}\right):\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 15: 42.0% accurate, 43.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -155000 or 3.10000000000000019e66 < 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. Applied egg-rr14.7%

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

    if -155000 < l < 3.10000000000000019e66

    1. Initial program 75.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -155000 \lor \neg \left(\ell \leq 3.1 \cdot 10^{+66}\right):\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 16: 53.6% accurate, 44.6× speedup?

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

\\
U + 2 \cdot \left(J \cdot \ell\right)
\end{array}
Derivation
  1. Initial program 85.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 71.1%

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

    \[\leadsto 2 \cdot \left(J \cdot \color{blue}{\ell}\right) + U \]
  4. Final simplification57.7%

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

Alternative 17: 2.7% accurate, 312.0× speedup?

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

\\
-15
\end{array}
Derivation
  1. Initial program 85.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 71.1%

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

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

    \[\leadsto \color{blue}{\frac{-3}{U + -64} \cdot \left(\left(U + 16\right) - U \cdot -4\right)} \]
  5. Step-by-step derivation
    1. associate-*l/2.9%

      \[\leadsto \color{blue}{\frac{-3 \cdot \left(\left(U + 16\right) - U \cdot -4\right)}{U + -64}} \]
    2. +-commutative2.9%

      \[\leadsto \frac{-3 \cdot \left(\color{blue}{\left(16 + U\right)} - U \cdot -4\right)}{U + -64} \]
    3. associate-+r-2.9%

      \[\leadsto \frac{-3 \cdot \color{blue}{\left(16 + \left(U - U \cdot -4\right)\right)}}{U + -64} \]
    4. distribute-lft-in2.9%

      \[\leadsto \frac{\color{blue}{-3 \cdot 16 + -3 \cdot \left(U - U \cdot -4\right)}}{U + -64} \]
    5. metadata-eval2.9%

      \[\leadsto \frac{\color{blue}{-48} + -3 \cdot \left(U - U \cdot -4\right)}{U + -64} \]
    6. *-commutative2.9%

      \[\leadsto \frac{-48 + -3 \cdot \left(U - \color{blue}{-4 \cdot U}\right)}{U + -64} \]
    7. cancel-sign-sub-inv2.9%

      \[\leadsto \frac{-48 + -3 \cdot \color{blue}{\left(U + \left(--4\right) \cdot U\right)}}{U + -64} \]
    8. metadata-eval2.9%

      \[\leadsto \frac{-48 + -3 \cdot \left(U + \color{blue}{4} \cdot U\right)}{U + -64} \]
    9. distribute-lft-in2.9%

      \[\leadsto \frac{-48 + \color{blue}{\left(-3 \cdot U + -3 \cdot \left(4 \cdot U\right)\right)}}{U + -64} \]
    10. associate-*r*2.9%

      \[\leadsto \frac{-48 + \left(-3 \cdot U + \color{blue}{\left(-3 \cdot 4\right) \cdot U}\right)}{U + -64} \]
    11. distribute-rgt-out2.9%

      \[\leadsto \frac{-48 + \color{blue}{U \cdot \left(-3 + -3 \cdot 4\right)}}{U + -64} \]
    12. metadata-eval2.9%

      \[\leadsto \frac{-48 + U \cdot \left(-3 + \color{blue}{-12}\right)}{U + -64} \]
    13. metadata-eval2.9%

      \[\leadsto \frac{-48 + U \cdot \color{blue}{-15}}{U + -64} \]
  6. Simplified2.9%

    \[\leadsto \color{blue}{\frac{-48 + U \cdot -15}{U + -64}} \]
  7. Taylor expanded in U around inf 2.9%

    \[\leadsto \color{blue}{-15} \]
  8. Final simplification2.9%

    \[\leadsto -15 \]

Alternative 18: 2.7% accurate, 312.0× speedup?

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

\\
-0.3333333333333333
\end{array}
Derivation
  1. Initial program 85.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 71.1%

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

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

    \[\leadsto \color{blue}{\frac{\frac{U}{-3}}{U}} \]
  5. Step-by-step derivation
    1. associate-/l/2.9%

      \[\leadsto \color{blue}{\frac{U}{U \cdot -3}} \]
    2. associate-/r*2.9%

      \[\leadsto \color{blue}{\frac{\frac{U}{U}}{-3}} \]
    3. *-inverses2.9%

      \[\leadsto \frac{\color{blue}{1}}{-3} \]
    4. metadata-eval2.9%

      \[\leadsto \color{blue}{-0.3333333333333333} \]
  6. Simplified2.9%

    \[\leadsto \color{blue}{-0.3333333333333333} \]
  7. Final simplification2.9%

    \[\leadsto -0.3333333333333333 \]

Alternative 19: 36.9% 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.9%

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

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

    \[\leadsto U \]

Reproduce

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