Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.7% → 99.3%
Time: 14.8s
Alternatives: 16
Speedup: 1.0×

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 16 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.7% 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.3% 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 5 \cdot 10^{-9}\right):\\ \;\;\;\;J \cdot \left(t\_0 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + 2 \cdot J\right)\right) \cdot \cos \left(\frac{K}{2}\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 5e-9)))
     (* J (* t_0 (cos (* K 0.5))))
     (+
      U
      (*
       (* l (+ (* 0.3333333333333333 (* J (pow l 2.0))) (* 2.0 J)))
       (cos (/ K 2.0)))))))
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 <= 5e-9)) {
		tmp = J * (t_0 * cos((K * 0.5)));
	} else {
		tmp = U + ((l * ((0.3333333333333333 * (J * pow(l, 2.0))) + (2.0 * J))) * cos((K / 2.0)));
	}
	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 <= 5e-9)) {
		tmp = J * (t_0 * Math.cos((K * 0.5)));
	} else {
		tmp = U + ((l * ((0.3333333333333333 * (J * Math.pow(l, 2.0))) + (2.0 * J))) * Math.cos((K / 2.0)));
	}
	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 <= 5e-9):
		tmp = J * (t_0 * math.cos((K * 0.5)))
	else:
		tmp = U + ((l * ((0.3333333333333333 * (J * math.pow(l, 2.0))) + (2.0 * J))) * math.cos((K / 2.0)))
	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 <= 5e-9))
		tmp = Float64(J * Float64(t_0 * cos(Float64(K * 0.5))));
	else
		tmp = Float64(U + Float64(Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 2.0))) + Float64(2.0 * J))) * cos(Float64(K / 2.0))));
	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 <= 5e-9)))
		tmp = J * (t_0 * cos((K * 0.5)));
	else
		tmp = U + ((l * ((0.3333333333333333 * (J * (l ^ 2.0))) + (2.0 * J))) * cos((K / 2.0)));
	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, 5e-9]], $MachinePrecision]], N[(J * N[(t$95$0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(l * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $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 5 \cdot 10^{-9}\right):\\
\;\;\;\;J \cdot \left(t\_0 \cdot \cos \left(K \cdot 0.5\right)\right)\\

\mathbf{else}:\\
\;\;\;\;U + \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + 2 \cdot J\right)\right) \cdot \cos \left(\frac{K}{2}\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 5.0000000000000001e-9 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(e^{\ell} - e^{-\ell}\right)\right)} + U \]
    4. Taylor expanded in J around inf 100.0%

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000001e-9

    1. Initial program 73.0%

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

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

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

Alternative 2: 93.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.04:\\ \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 0.04)
     (+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))
     (+ U (* 2.0 (* J (log1p (expm1 l))))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double tmp;
	if (t_0 <= 0.04) {
		tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))));
	} else {
		tmp = U + (2.0 * (J * log1p(expm1(l))));
	}
	return tmp;
}
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.04) {
		tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))));
	} else {
		tmp = U + (2.0 * (J * Math.log1p(Math.expm1(l))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if t_0 <= 0.04:
		tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))))
	else:
		tmp = U + (2.0 * (J * math.log1p(math.expm1(l))))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= 0.04)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0)))))));
	else
		tmp = Float64(U + Float64(2.0 * Float64(J * log1p(expm1(l)))));
	end
	return 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.04], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 85.7%

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

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

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

    1. Initial program 88.1%

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

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

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

        \[\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 \]
    5. Applied egg-rr100.0%

      \[\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 \]
    6. Taylor expanded in K around 0 88.0%

      \[\leadsto 2 \cdot \left(J \cdot \mathsf{log1p}\left(\color{blue}{e^{\ell} - 1}\right)\right) + U \]
    7. Step-by-step derivation
      1. expm1-define96.1%

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

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

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

Alternative 3: 89.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 85.7%

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

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

      \[\leadsto \color{blue}{U \cdot \left(1 + 2 \cdot \frac{J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)}{U}\right)} \]
    5. Step-by-step derivation
      1. associate-/l*77.2%

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

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

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

    1. Initial program 88.1%

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

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

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

        \[\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 \]
    5. Applied egg-rr100.0%

      \[\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 \]
    6. Taylor expanded in K around 0 88.0%

      \[\leadsto 2 \cdot \left(J \cdot \mathsf{log1p}\left(\color{blue}{e^{\ell} - 1}\right)\right) + U \]
    7. Step-by-step derivation
      1. expm1-define96.1%

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

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

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

Alternative 4: 99.5% 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 87.6%

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

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

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

      \[\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 \]
  5. Applied egg-rr99.7%

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

    \[\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 \]
  7. Add Preprocessing

Alternative 5: 81.3% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 85.7%

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

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

      \[\leadsto \color{blue}{U \cdot \left(1 + 2 \cdot \frac{J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)}{U}\right)} \]
    5. Step-by-step derivation
      1. associate-/l*77.2%

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

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

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

    1. Initial program 88.1%

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

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

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

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

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

Alternative 6: 81.1% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 85.7%

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

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

      \[\leadsto \color{blue}{U \cdot \left(1 + 2 \cdot \frac{J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)}{U}\right)} \]
    5. Step-by-step derivation
      1. associate-/l*77.2%

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

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

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

    1. Initial program 88.1%

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

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

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

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

Alternative 7: 79.0% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 85.7%

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

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

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

    1. Initial program 88.1%

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

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

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

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

Alternative 8: 77.0% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{if}\;\ell \leq -3.9 \cdot 10^{+129}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq -1.45 \cdot 10^{+112}:\\ \;\;\;\;U + J \cdot \left(-0.5 + {K}^{2} \cdot 0.0625\right)\\ \mathbf{elif}\;\ell \leq -920000000 \lor \neg \left(\ell \leq 2.9 \cdot 10^{+30}\right):\\ \;\;\;\;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 (* (pow l 3.0) (* J 0.3333333333333333))))
   (if (<= l -3.9e+129)
     t_0
     (if (<= l -1.45e+112)
       (+ U (* J (+ -0.5 (* (pow K 2.0) 0.0625))))
       (if (or (<= l -920000000.0) (not (<= l 2.9e+30)))
         t_0
         (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = pow(l, 3.0) * (J * 0.3333333333333333);
	double tmp;
	if (l <= -3.9e+129) {
		tmp = t_0;
	} else if (l <= -1.45e+112) {
		tmp = U + (J * (-0.5 + (pow(K, 2.0) * 0.0625)));
	} else if ((l <= -920000000.0) || !(l <= 2.9e+30)) {
		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 = (l ** 3.0d0) * (j * 0.3333333333333333d0)
    if (l <= (-3.9d+129)) then
        tmp = t_0
    else if (l <= (-1.45d+112)) then
        tmp = u + (j * ((-0.5d0) + ((k ** 2.0d0) * 0.0625d0)))
    else if ((l <= (-920000000.0d0)) .or. (.not. (l <= 2.9d+30))) 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 = Math.pow(l, 3.0) * (J * 0.3333333333333333);
	double tmp;
	if (l <= -3.9e+129) {
		tmp = t_0;
	} else if (l <= -1.45e+112) {
		tmp = U + (J * (-0.5 + (Math.pow(K, 2.0) * 0.0625)));
	} else if ((l <= -920000000.0) || !(l <= 2.9e+30)) {
		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 = math.pow(l, 3.0) * (J * 0.3333333333333333)
	tmp = 0
	if l <= -3.9e+129:
		tmp = t_0
	elif l <= -1.45e+112:
		tmp = U + (J * (-0.5 + (math.pow(K, 2.0) * 0.0625)))
	elif (l <= -920000000.0) or not (l <= 2.9e+30):
		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((l ^ 3.0) * Float64(J * 0.3333333333333333))
	tmp = 0.0
	if (l <= -3.9e+129)
		tmp = t_0;
	elseif (l <= -1.45e+112)
		tmp = Float64(U + Float64(J * Float64(-0.5 + Float64((K ^ 2.0) * 0.0625))));
	elseif ((l <= -920000000.0) || !(l <= 2.9e+30))
		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 = (l ^ 3.0) * (J * 0.3333333333333333);
	tmp = 0.0;
	if (l <= -3.9e+129)
		tmp = t_0;
	elseif (l <= -1.45e+112)
		tmp = U + (J * (-0.5 + ((K ^ 2.0) * 0.0625)));
	elseif ((l <= -920000000.0) || ~((l <= 2.9e+30)))
		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[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.9e+129], t$95$0, If[LessEqual[l, -1.45e+112], N[(U + N[(J * N[(-0.5 + N[(N[Power[K, 2.0], $MachinePrecision] * 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, -920000000.0], N[Not[LessEqual[l, 2.9e+30]], $MachinePrecision]], 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 := {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{if}\;\ell \leq -3.9 \cdot 10^{+129}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq -1.45 \cdot 10^{+112}:\\
\;\;\;\;U + J \cdot \left(-0.5 + {K}^{2} \cdot 0.0625\right)\\

\mathbf{elif}\;\ell \leq -920000000 \lor \neg \left(\ell \leq 2.9 \cdot 10^{+30}\right):\\
\;\;\;\;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 3 regimes
  2. if l < -3.8999999999999997e129 or -1.4500000000000001e112 < l < -9.2e8 or 2.8999999999999998e30 < l

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto \color{blue}{\left(J \cdot {\ell}^{3}\right) \cdot 0.3333333333333333} \]
      2. *-commutative69.6%

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

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

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

    if -3.8999999999999997e129 < l < -1.4500000000000001e112

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{\left(-0.5 \cdot J + 0.0625 \cdot \left(J \cdot {K}^{2}\right)\right)} + U \]
    5. Step-by-step derivation
      1. *-commutative80.5%

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

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

        \[\leadsto \left(J \cdot -0.5 + \color{blue}{J \cdot \left({K}^{2} \cdot 0.0625\right)}\right) + U \]
      4. distribute-lft-out80.5%

        \[\leadsto \color{blue}{J \cdot \left(-0.5 + {K}^{2} \cdot 0.0625\right)} + U \]
    6. Simplified80.5%

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

    if -9.2e8 < l < 2.8999999999999998e30

    1. Initial program 74.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.9 \cdot 10^{+129}:\\ \;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;\ell \leq -1.45 \cdot 10^{+112}:\\ \;\;\;\;U + J \cdot \left(-0.5 + {K}^{2} \cdot 0.0625\right)\\ \mathbf{elif}\;\ell \leq -920000000 \lor \neg \left(\ell \leq 2.9 \cdot 10^{+30}\right):\\ \;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 70.0% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{if}\;\ell \leq -3.9 \cdot 10^{+129}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq -1.45 \cdot 10^{+112}:\\ \;\;\;\;U + J \cdot \left(-0.5 + {K}^{2} \cdot 0.0625\right)\\ \mathbf{elif}\;\ell \leq -8.6 \cdot 10^{+42} \lor \neg \left(\ell \leq 1.9 \cdot 10^{+92}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* (pow l 3.0) (* J 0.3333333333333333))))
   (if (<= l -3.9e+129)
     t_0
     (if (<= l -1.45e+112)
       (+ U (* J (+ -0.5 (* (pow K 2.0) 0.0625))))
       (if (or (<= l -8.6e+42) (not (<= l 1.9e+92)))
         t_0
         (* U (+ 1.0 (* 2.0 (* J (/ l U))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = pow(l, 3.0) * (J * 0.3333333333333333);
	double tmp;
	if (l <= -3.9e+129) {
		tmp = t_0;
	} else if (l <= -1.45e+112) {
		tmp = U + (J * (-0.5 + (pow(K, 2.0) * 0.0625)));
	} else if ((l <= -8.6e+42) || !(l <= 1.9e+92)) {
		tmp = t_0;
	} else {
		tmp = U * (1.0 + (2.0 * (J * (l / 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) :: t_0
    real(8) :: tmp
    t_0 = (l ** 3.0d0) * (j * 0.3333333333333333d0)
    if (l <= (-3.9d+129)) then
        tmp = t_0
    else if (l <= (-1.45d+112)) then
        tmp = u + (j * ((-0.5d0) + ((k ** 2.0d0) * 0.0625d0)))
    else if ((l <= (-8.6d+42)) .or. (.not. (l <= 1.9d+92))) then
        tmp = t_0
    else
        tmp = u * (1.0d0 + (2.0d0 * (j * (l / u))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.pow(l, 3.0) * (J * 0.3333333333333333);
	double tmp;
	if (l <= -3.9e+129) {
		tmp = t_0;
	} else if (l <= -1.45e+112) {
		tmp = U + (J * (-0.5 + (Math.pow(K, 2.0) * 0.0625)));
	} else if ((l <= -8.6e+42) || !(l <= 1.9e+92)) {
		tmp = t_0;
	} else {
		tmp = U * (1.0 + (2.0 * (J * (l / U))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.pow(l, 3.0) * (J * 0.3333333333333333)
	tmp = 0
	if l <= -3.9e+129:
		tmp = t_0
	elif l <= -1.45e+112:
		tmp = U + (J * (-0.5 + (math.pow(K, 2.0) * 0.0625)))
	elif (l <= -8.6e+42) or not (l <= 1.9e+92):
		tmp = t_0
	else:
		tmp = U * (1.0 + (2.0 * (J * (l / U))))
	return tmp
function code(J, l, K, U)
	t_0 = Float64((l ^ 3.0) * Float64(J * 0.3333333333333333))
	tmp = 0.0
	if (l <= -3.9e+129)
		tmp = t_0;
	elseif (l <= -1.45e+112)
		tmp = Float64(U + Float64(J * Float64(-0.5 + Float64((K ^ 2.0) * 0.0625))));
	elseif ((l <= -8.6e+42) || !(l <= 1.9e+92))
		tmp = t_0;
	else
		tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U)))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = (l ^ 3.0) * (J * 0.3333333333333333);
	tmp = 0.0;
	if (l <= -3.9e+129)
		tmp = t_0;
	elseif (l <= -1.45e+112)
		tmp = U + (J * (-0.5 + ((K ^ 2.0) * 0.0625)));
	elseif ((l <= -8.6e+42) || ~((l <= 1.9e+92)))
		tmp = t_0;
	else
		tmp = U * (1.0 + (2.0 * (J * (l / U))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.9e+129], t$95$0, If[LessEqual[l, -1.45e+112], N[(U + N[(J * N[(-0.5 + N[(N[Power[K, 2.0], $MachinePrecision] * 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, -8.6e+42], N[Not[LessEqual[l, 1.9e+92]], $MachinePrecision]], t$95$0, N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -1.45 \cdot 10^{+112}:\\
\;\;\;\;U + J \cdot \left(-0.5 + {K}^{2} \cdot 0.0625\right)\\

\mathbf{elif}\;\ell \leq -8.6 \cdot 10^{+42} \lor \neg \left(\ell \leq 1.9 \cdot 10^{+92}\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.8999999999999997e129 or -1.4500000000000001e112 < l < -8.5999999999999996e42 or 1.9e92 < l

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto \color{blue}{\left(J \cdot {\ell}^{3}\right) \cdot 0.3333333333333333} \]
      2. *-commutative75.9%

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

        \[\leadsto \color{blue}{{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)} \]
    7. Simplified75.9%

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

    if -3.8999999999999997e129 < l < -1.4500000000000001e112

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{\left(-0.5 \cdot J + 0.0625 \cdot \left(J \cdot {K}^{2}\right)\right)} + U \]
    5. Step-by-step derivation
      1. *-commutative80.5%

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

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

        \[\leadsto \left(J \cdot -0.5 + \color{blue}{J \cdot \left({K}^{2} \cdot 0.0625\right)}\right) + U \]
      4. distribute-lft-out80.5%

        \[\leadsto \color{blue}{J \cdot \left(-0.5 + {K}^{2} \cdot 0.0625\right)} + U \]
    6. Simplified80.5%

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

    if -8.5999999999999996e42 < l < 1.9e92

    1. Initial program 78.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{U \cdot \left(1 + 2 \cdot \frac{J \cdot \ell}{U}\right)} \]
    8. Step-by-step derivation
      1. associate-/l*76.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.9 \cdot 10^{+129}:\\ \;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;\ell \leq -1.45 \cdot 10^{+112}:\\ \;\;\;\;U + J \cdot \left(-0.5 + {K}^{2} \cdot 0.0625\right)\\ \mathbf{elif}\;\ell \leq -8.6 \cdot 10^{+42} \lor \neg \left(\ell \leq 1.9 \cdot 10^{+92}\right):\\ \;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 70.9% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.5 \cdot 10^{+43} \lor \neg \left(\ell \leq 1.7 \cdot 10^{+92}\right):\\
\;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.50000000000000008e43 or 1.6999999999999999e92 < l

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto \color{blue}{\left(J \cdot {\ell}^{3}\right) \cdot 0.3333333333333333} \]
      2. *-commutative72.5%

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

        \[\leadsto \color{blue}{{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)} \]
    7. Simplified72.5%

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

    if -1.50000000000000008e43 < l < 1.6999999999999999e92

    1. Initial program 78.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{U \cdot \left(1 + 2 \cdot \frac{J \cdot \ell}{U}\right)} \]
    8. Step-by-step derivation
      1. associate-/l*76.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.5 \cdot 10^{+43} \lor \neg \left(\ell \leq 1.7 \cdot 10^{+92}\right):\\ \;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 45.6% accurate, 20.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1000 \lor \neg \left(\ell \leq 6.4 \cdot 10^{-28}\right):\\
\;\;\;\;\ell \cdot \left(2 \cdot J\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1e3 or 6.39999999999999964e-28 < l

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\ell \cdot \left(2 \cdot J\right)} \]
    9. Simplified23.9%

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

    if -1e3 < l < 6.39999999999999964e-28

    1. Initial program 74.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1000 \lor \neg \left(\ell \leq 6.4 \cdot 10^{-28}\right):\\ \;\;\;\;\ell \cdot \left(2 \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 41.6% accurate, 23.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.4 \cdot 10^{+43} \lor \neg \left(\ell \leq 1.7 \cdot 10^{-9}\right):\\
\;\;\;\;U \cdot U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.40000000000000023e43 or 1.6999999999999999e-9 < l

    1. Initial program 99.3%

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

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

    if -2.40000000000000023e43 < l < 1.6999999999999999e-9

    1. Initial program 75.2%

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

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

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

Alternative 13: 60.4% accurate, 28.4× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{U \cdot \left(1 + 2 \cdot \frac{J \cdot \ell}{U}\right)} \]
  8. Step-by-step derivation
    1. associate-/l*61.5%

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

    \[\leadsto \color{blue}{U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)} \]
  10. Final simplification61.5%

    \[\leadsto U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right) \]
  11. Add Preprocessing

Alternative 14: 54.2% accurate, 44.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 2.8% accurate, 312.0× speedup?

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

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

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

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

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

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

    \[\leadsto 1 \]
  7. Add Preprocessing

Alternative 16: 36.7% 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 87.6%

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

    \[\leadsto \color{blue}{U} \]
  4. Final simplification33.8%

    \[\leadsto U \]
  5. Add Preprocessing

Reproduce

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