Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.1% → 99.4%
Time: 9.1s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 86.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{-15}\right):\\ \;\;\;\;\left(t_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\ \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 (- (exp l) (exp (- l)))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e-15)))
     (+ (* (* t_0 J) (cos (/ K 2.0))) U)
     (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 2e-15)) {
		tmp = ((t_0 * J) * cos((K / 2.0))) + U;
	} else {
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.exp(l) - Math.exp(-l);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 2e-15)) {
		tmp = ((t_0 * J) * Math.cos((K / 2.0))) + U;
	} else {
		tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.exp(l) - math.exp(-l)
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 2e-15):
		tmp = ((t_0 * J) * math.cos((K / 2.0))) + U
	else:
		tmp = U + (2.0 * (J * (l * math.cos((K * 0.5)))))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 2e-15))
		tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U);
	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 = exp(l) - exp(-l);
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 2e-15)))
		tmp = ((t_0 * J) * cos((K / 2.0))) + U;
	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[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 2e-15]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], 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 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{-15}\right):\\
\;\;\;\;\left(t_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\

\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 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 2.0000000000000002e-15 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 2.0000000000000002e-15

    1. Initial program 64.5%

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

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

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

Alternative 2: 93.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := U + t_0 \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{if}\;\ell \leq -2.6 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq -3.8 \cdot 10^{+25}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{-11}:\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left({\ell}^{3} \cdot 0.3333333333333333 + \ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+91}:\\ \;\;\;\;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 (* t_0 (* (pow l 3.0) (* J 0.3333333333333333)))))
        (t_2 (+ (* (- (exp l) (exp (- l))) J) U)))
   (if (<= l -2.6e+73)
     t_1
     (if (<= l -3.8e+25)
       t_2
       (if (<= l 8e-11)
         (+ U (* t_0 (* J (+ (* (pow l 3.0) 0.3333333333333333) (* l 2.0)))))
         (if (<= l 7.8e+91) 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 + (t_0 * (pow(l, 3.0) * (J * 0.3333333333333333)));
	double t_2 = ((exp(l) - exp(-l)) * J) + U;
	double tmp;
	if (l <= -2.6e+73) {
		tmp = t_1;
	} else if (l <= -3.8e+25) {
		tmp = t_2;
	} else if (l <= 8e-11) {
		tmp = U + (t_0 * (J * ((pow(l, 3.0) * 0.3333333333333333) + (l * 2.0))));
	} else if (l <= 7.8e+91) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    t_1 = u + (t_0 * ((l ** 3.0d0) * (j * 0.3333333333333333d0)))
    t_2 = ((exp(l) - exp(-l)) * j) + u
    if (l <= (-2.6d+73)) then
        tmp = t_1
    else if (l <= (-3.8d+25)) then
        tmp = t_2
    else if (l <= 8d-11) then
        tmp = u + (t_0 * (j * (((l ** 3.0d0) * 0.3333333333333333d0) + (l * 2.0d0))))
    else if (l <= 7.8d+91) then
        tmp = t_2
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	double t_1 = U + (t_0 * (Math.pow(l, 3.0) * (J * 0.3333333333333333)));
	double t_2 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
	double tmp;
	if (l <= -2.6e+73) {
		tmp = t_1;
	} else if (l <= -3.8e+25) {
		tmp = t_2;
	} else if (l <= 8e-11) {
		tmp = U + (t_0 * (J * ((Math.pow(l, 3.0) * 0.3333333333333333) + (l * 2.0))));
	} else if (l <= 7.8e+91) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = U + (t_0 * (math.pow(l, 3.0) * (J * 0.3333333333333333)))
	t_2 = ((math.exp(l) - math.exp(-l)) * J) + U
	tmp = 0
	if l <= -2.6e+73:
		tmp = t_1
	elif l <= -3.8e+25:
		tmp = t_2
	elif l <= 8e-11:
		tmp = U + (t_0 * (J * ((math.pow(l, 3.0) * 0.3333333333333333) + (l * 2.0))))
	elif l <= 7.8e+91:
		tmp = 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(t_0 * Float64((l ^ 3.0) * Float64(J * 0.3333333333333333))))
	t_2 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U)
	tmp = 0.0
	if (l <= -2.6e+73)
		tmp = t_1;
	elseif (l <= -3.8e+25)
		tmp = t_2;
	elseif (l <= 8e-11)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64((l ^ 3.0) * 0.3333333333333333) + Float64(l * 2.0)))));
	elseif (l <= 7.8e+91)
		tmp = 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 + (t_0 * ((l ^ 3.0) * (J * 0.3333333333333333)));
	t_2 = ((exp(l) - exp(-l)) * J) + U;
	tmp = 0.0;
	if (l <= -2.6e+73)
		tmp = t_1;
	elseif (l <= -3.8e+25)
		tmp = t_2;
	elseif (l <= 8e-11)
		tmp = U + (t_0 * (J * (((l ^ 3.0) * 0.3333333333333333) + (l * 2.0))));
	elseif (l <= 7.8e+91)
		tmp = 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[(t$95$0 * N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -2.6e+73], t$95$1, If[LessEqual[l, -3.8e+25], t$95$2, If[LessEqual[l, 8e-11], N[(U + N[(t$95$0 * N[(J * N[(N[(N[Power[l, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7.8e+91], t$95$2, t$95$1]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -3.8 \cdot 10^{+25}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+91}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.6000000000000001e73 or 7.79999999999999935e91 < 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 98.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 l around inf 98.1%

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

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

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

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

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

    if -2.6000000000000001e73 < l < -3.8e25 or 7.99999999999999952e-11 < l < 7.79999999999999935e91

    1. Initial program 100.0%

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

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

    if -3.8e25 < l < 7.99999999999999952e-11

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.6 \cdot 10^{+73}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq -3.8 \cdot 10^{+25}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{-11}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left({\ell}^{3} \cdot 0.3333333333333333 + \ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+91}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \end{array} \]

Alternative 3: 93.3% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\ell \leq -3.8 \cdot 10^{+25}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\ell \leq 8 \cdot 10^{-11}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\

\mathbf{elif}\;\ell \leq 4.9 \cdot 10^{+98}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.6000000000000001e73 or 4.89999999999999979e98 < 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 98.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 l around inf 98.1%

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

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

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

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

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

    if -2.6000000000000001e73 < l < -3.8e25 or 7.99999999999999952e-11 < l < 4.89999999999999979e98

    1. Initial program 100.0%

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

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

    if -3.8e25 < l < 7.99999999999999952e-11

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.6 \cdot 10^{+73}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq -3.8 \cdot 10^{+25}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{-11}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 4.9 \cdot 10^{+98}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \end{array} \]

Alternative 4: 78.8% accurate, 1.4× speedup?

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

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

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


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

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

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

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

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

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

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

      \[\leadsto \left(J \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 83.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 simplification77.5%

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

Alternative 5: 86.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -3.8 \cdot 10^{+25} \lor \neg \left(\ell \leq 8 \cdot 10^{-11}\right):\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \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
 (if (or (<= l -3.8e+25) (not (<= l 8e-11)))
   (+ (* (- (exp l) (exp (- l))) J) U)
   (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -3.8e+25) || !(l <= 8e-11)) {
		tmp = ((exp(l) - exp(-l)) * J) + U;
	} 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) :: tmp
    if ((l <= (-3.8d+25)) .or. (.not. (l <= 8d-11))) then
        tmp = ((exp(l) - exp(-l)) * j) + u
    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 tmp;
	if ((l <= -3.8e+25) || !(l <= 8e-11)) {
		tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
	} else {
		tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -3.8e+25) or not (l <= 8e-11):
		tmp = ((math.exp(l) - math.exp(-l)) * J) + U
	else:
		tmp = U + (2.0 * (J * (l * math.cos((K * 0.5)))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -3.8e+25) || !(l <= 8e-11))
		tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U);
	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)
	tmp = 0.0;
	if ((l <= -3.8e+25) || ~((l <= 8e-11)))
		tmp = ((exp(l) - exp(-l)) * J) + U;
	else
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -3.8e+25], N[Not[LessEqual[l, 8e-11]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], 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}
\mathbf{if}\;\ell \leq -3.8 \cdot 10^{+25} \lor \neg \left(\ell \leq 8 \cdot 10^{-11}\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\

\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 2 regimes
  2. if l < -3.8e25 or 7.99999999999999952e-11 < l

    1. Initial program 100.0%

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

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

    if -3.8e25 < l < 7.99999999999999952e-11

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.8 \cdot 10^{+25} \lor \neg \left(\ell \leq 8 \cdot 10^{-11}\right):\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \end{array} \]

Alternative 6: 78.4% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.05 \cdot 10^{+80} \lor \neg \left(\ell \leq 52000000000000\right):\\ \;\;\;\;U + 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} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -1.05e+80) (not (<= l 52000000000000.0)))
   (+ U (* 0.3333333333333333 (* J (pow l 3.0))))
   (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -1.05e+80) || !(l <= 52000000000000.0)) {
		tmp = U + (0.3333333333333333 * (J * pow(l, 3.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) :: tmp
    if ((l <= (-1.05d+80)) .or. (.not. (l <= 52000000000000.0d0))) then
        tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
    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 tmp;
	if ((l <= -1.05e+80) || !(l <= 52000000000000.0)) {
		tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
	} else {
		tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -1.05e+80) or not (l <= 52000000000000.0):
		tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0)))
	else:
		tmp = U + (2.0 * (J * (l * math.cos((K * 0.5)))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -1.05e+80) || !(l <= 52000000000000.0))
		tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.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)
	tmp = 0.0;
	if ((l <= -1.05e+80) || ~((l <= 52000000000000.0)))
		tmp = U + (0.3333333333333333 * (J * (l ^ 3.0)));
	else
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.05e+80], N[Not[LessEqual[l, 52000000000000.0]], $MachinePrecision]], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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}
\mathbf{if}\;\ell \leq -1.05 \cdot 10^{+80} \lor \neg \left(\ell \leq 52000000000000\right):\\
\;\;\;\;U + 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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.05000000000000001e80 or 5.2e13 < 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 88.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 l around inf 88.7%

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

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

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

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

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

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

    if -1.05000000000000001e80 < l < 5.2e13

    1. Initial program 70.5%

      \[\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. Recombined 2 regimes into one program.
  4. Final simplification78.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.05 \cdot 10^{+80} \lor \neg \left(\ell \leq 52000000000000\right):\\ \;\;\;\;U + 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 7: 72.1% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{if}\;\ell \leq -7.8 \cdot 10^{+63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -7.4 \cdot 10^{+24}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 2.45:\\ \;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))
   (if (<= l -7.8e+63)
     t_0
     (if (<= l -7.4e+24)
       (* U (- U -4.0))
       (if (<= l 2.45) (+ U (* l (* J 2.0))) t_0)))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (0.3333333333333333 * (J * pow(l, 3.0)));
	double tmp;
	if (l <= -7.8e+63) {
		tmp = t_0;
	} else if (l <= -7.4e+24) {
		tmp = U * (U - -4.0);
	} else if (l <= 2.45) {
		tmp = U + (l * (J * 2.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: tmp
    t_0 = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
    if (l <= (-7.8d+63)) then
        tmp = t_0
    else if (l <= (-7.4d+24)) then
        tmp = u * (u - (-4.0d0))
    else if (l <= 2.45d0) then
        tmp = u + (l * (j * 2.0d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
	double tmp;
	if (l <= -7.8e+63) {
		tmp = t_0;
	} else if (l <= -7.4e+24) {
		tmp = U * (U - -4.0);
	} else if (l <= 2.45) {
		tmp = U + (l * (J * 2.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (0.3333333333333333 * (J * math.pow(l, 3.0)))
	tmp = 0
	if l <= -7.8e+63:
		tmp = t_0
	elif l <= -7.4e+24:
		tmp = U * (U - -4.0)
	elif l <= 2.45:
		tmp = U + (l * (J * 2.0))
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))))
	tmp = 0.0
	if (l <= -7.8e+63)
		tmp = t_0;
	elseif (l <= -7.4e+24)
		tmp = Float64(U * Float64(U - -4.0));
	elseif (l <= 2.45)
		tmp = Float64(U + Float64(l * Float64(J * 2.0)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + (0.3333333333333333 * (J * (l ^ 3.0)));
	tmp = 0.0;
	if (l <= -7.8e+63)
		tmp = t_0;
	elseif (l <= -7.4e+24)
		tmp = U * (U - -4.0);
	elseif (l <= 2.45)
		tmp = U + (l * (J * 2.0));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -7.8e+63], t$95$0, If[LessEqual[l, -7.4e+24], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.45], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -7.8e63 or 2.4500000000000002 < 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.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 86.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. *-commutative86.0%

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

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

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

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

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

    if -7.8e63 < l < -7.39999999999999998e24

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

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

    if -7.39999999999999998e24 < l < 2.4500000000000002

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.8 \cdot 10^{+63}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -7.4 \cdot 10^{+24}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 2.45:\\ \;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \end{array} \]

Alternative 8: 42.4% accurate, 34.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -6 \cdot 10^{+19} \lor \neg \left(\ell \leq 1.2\right):\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -6e+19) (not (<= l 1.2))) (* U (- U -4.0)) U))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -6e+19) || !(l <= 1.2)) {
		tmp = U * (U - -4.0);
	} else {
		tmp = U;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if ((l <= (-6d+19)) .or. (.not. (l <= 1.2d0))) then
        tmp = u * (u - (-4.0d0))
    else
        tmp = u
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -6e+19) || !(l <= 1.2)) {
		tmp = U * (U - -4.0);
	} else {
		tmp = U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -6e+19) or not (l <= 1.2):
		tmp = U * (U - -4.0)
	else:
		tmp = U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -6e+19) || !(l <= 1.2))
		tmp = Float64(U * Float64(U - -4.0));
	else
		tmp = U;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if ((l <= -6e+19) || ~((l <= 1.2)))
		tmp = U * (U - -4.0);
	else
		tmp = U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -6e+19], N[Not[LessEqual[l, 1.2]], $MachinePrecision]], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6 \cdot 10^{+19} \lor \neg \left(\ell \leq 1.2\right):\\
\;\;\;\;U \cdot \left(U - -4\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -6e19 or 1.19999999999999996 < 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-rr16.9%

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

    if -6e19 < l < 1.19999999999999996

    1. Initial program 65.6%

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

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

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

Alternative 9: 42.4% accurate, 43.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8.2 \cdot 10^{+18} \lor \neg \left(\ell \leq 1.05 \cdot 10^{+14}\right):\\
\;\;\;\;U \cdot U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -8.2e18 or 1.05e14 < 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-rr17.1%

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

    if -8.2e18 < l < 1.05e14

    1. Initial program 66.7%

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

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

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

Alternative 10: 54.4% accurate, 44.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 2.7% accurate, 312.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (J l K U) :precision binary64 1.0)
double code(double J, double l, double K, double U) {
	return 1.0;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = 1.0d0
end function
public static double code(double J, double l, double K, double U) {
	return 1.0;
}
def code(J, l, K, U):
	return 1.0
function code(J, l, K, U)
	return 1.0
end
function tmp = code(J, l, K, U)
	tmp = 1.0;
end
code[J_, l_, K_, U_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 83.2%

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

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

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

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

    \[\leadsto 1 \]

Alternative 12: 37.4% 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 83.2%

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

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

    \[\leadsto U \]

Reproduce

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