Maksimov and Kolovsky, Equation (3)

Percentage Accurate: 73.2% → 99.3%
Time: 11.5s
Alternatives: 9
Speedup: 1.3×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}} \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
	double t_0 = cos((K / 2.0));
	return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    t_0 = cos((k / 2.0d0))
    code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U):
	t_0 = math.cos((K / 2.0))
	return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U)
	t_0 = cos(Float64(K / 2.0))
	return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0))))
end
function tmp = code(J, K, U)
	t_0 = cos((K / 2.0));
	tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0)));
end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}
\end{array}
\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 9 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: 73.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}} \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
	double t_0 = cos((K / 2.0));
	return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    t_0 = cos((k / 2.0d0))
    code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U):
	t_0 = math.cos((K / 2.0))
	return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U)
	t_0 = cos(Float64(K / 2.0))
	return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0))))
end
function tmp = code(J, K, U)
	t_0 = cos((K / 2.0));
	tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0)));
end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}
\end{array}
\end{array}

Alternative 1: 99.3% accurate, 0.3× speedup?

\[\begin{array}{l} U_m = \left|U\right| \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := \left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U\_m}{t\_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;-U\_m\\ \mathbf{elif}\;t\_1 \leq 10^{+301}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;U\_m\\ \end{array} \end{array} \]
U_m = (fabs.f64 U)
(FPCore (J K U_m)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0)))
        (t_1
         (*
          (* (* -2.0 J) t_0)
          (sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
   (if (<= t_1 (- INFINITY)) (- U_m) (if (<= t_1 1e+301) t_1 U_m))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
	double t_0 = cos((K / 2.0));
	double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = -U_m;
	} else if (t_1 <= 1e+301) {
		tmp = t_1;
	} else {
		tmp = U_m;
	}
	return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
	double t_0 = Math.cos((K / 2.0));
	double t_1 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U_m / (t_0 * (J * 2.0))), 2.0)));
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = -U_m;
	} else if (t_1 <= 1e+301) {
		tmp = t_1;
	} else {
		tmp = U_m;
	}
	return tmp;
}
U_m = math.fabs(U)
def code(J, K, U_m):
	t_0 = math.cos((K / 2.0))
	t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U_m / (t_0 * (J * 2.0))), 2.0)))
	tmp = 0
	if t_1 <= -math.inf:
		tmp = -U_m
	elif t_1 <= 1e+301:
		tmp = t_1
	else:
		tmp = U_m
	return tmp
U_m = abs(U)
function code(J, K, U_m)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U_m / Float64(t_0 * Float64(J * 2.0))) ^ 2.0))))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(-U_m);
	elseif (t_1 <= 1e+301)
		tmp = t_1;
	else
		tmp = U_m;
	end
	return tmp
end
U_m = abs(U);
function tmp_2 = code(J, K, U_m)
	t_0 = cos((K / 2.0));
	t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U_m / (t_0 * (J * 2.0))) ^ 2.0)));
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = -U_m;
	elseif (t_1 <= 1e+301)
		tmp = t_1;
	else
		tmp = U_m;
	end
	tmp_2 = tmp;
end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U$95$m / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U$95$m), If[LessEqual[t$95$1, 1e+301], t$95$1, U$95$m]]]]
\begin{array}{l}
U_m = \left|U\right|

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U\_m}{t\_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-U\_m\\

\mathbf{elif}\;t\_1 \leq 10^{+301}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < -inf.0

    1. Initial program 6.4%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified54.3%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around 0 46.8%

      \[\leadsto \color{blue}{-1 \cdot U} \]
    5. Step-by-step derivation
      1. neg-mul-146.8%

        \[\leadsto \color{blue}{-U} \]
    6. Simplified46.8%

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

    if -inf.0 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < 1.00000000000000005e301

    1. Initial program 99.8%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Add Preprocessing

    if 1.00000000000000005e301 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64)))))

    1. Initial program 5.9%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified50.5%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in U around -inf 67.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}} \leq -\infty:\\ \;\;\;\;-U\\ \mathbf{elif}\;\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}} \leq 10^{+301}:\\ \;\;\;\;\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 86.1% accurate, 1.3× speedup?

\[\begin{array}{l} U_m = \left|U\right| \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;U\_m \leq 4.9 \cdot 10^{+225}:\\ \;\;\;\;\left(J \cdot \left(-2 \cdot t\_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{J \cdot 2}}{t\_0}\right)\\ \mathbf{else}:\\ \;\;\;\;-U\_m\\ \end{array} \end{array} \]
U_m = (fabs.f64 U)
(FPCore (J K U_m)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= U_m 4.9e+225)
     (* (* J (* -2.0 t_0)) (hypot 1.0 (/ (/ U_m (* J 2.0)) t_0)))
     (- U_m))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
	double t_0 = cos((K / 2.0));
	double tmp;
	if (U_m <= 4.9e+225) {
		tmp = (J * (-2.0 * t_0)) * hypot(1.0, ((U_m / (J * 2.0)) / t_0));
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
	double t_0 = Math.cos((K / 2.0));
	double tmp;
	if (U_m <= 4.9e+225) {
		tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, ((U_m / (J * 2.0)) / t_0));
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = math.fabs(U)
def code(J, K, U_m):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if U_m <= 4.9e+225:
		tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, ((U_m / (J * 2.0)) / t_0))
	else:
		tmp = -U_m
	return tmp
U_m = abs(U)
function code(J, K, U_m)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (U_m <= 4.9e+225)
		tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(Float64(U_m / Float64(J * 2.0)) / t_0)));
	else
		tmp = Float64(-U_m);
	end
	return tmp
end
U_m = abs(U);
function tmp_2 = code(J, K, U_m)
	t_0 = cos((K / 2.0));
	tmp = 0.0;
	if (U_m <= 4.9e+225)
		tmp = (J * (-2.0 * t_0)) * hypot(1.0, ((U_m / (J * 2.0)) / t_0));
	else
		tmp = -U_m;
	end
	tmp_2 = tmp;
end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[U$95$m, 4.9e+225], N[(N[(J * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], (-U$95$m)]]
\begin{array}{l}
U_m = \left|U\right|

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U\_m \leq 4.9 \cdot 10^{+225}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot t\_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{J \cdot 2}}{t\_0}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if U < 4.90000000000000032e225

    1. Initial program 76.0%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Step-by-step derivation
      1. *-commutative76.0%

        \[\leadsto \left(\color{blue}{\left(J \cdot -2\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
      2. associate-*l*76.0%

        \[\leadsto \color{blue}{\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right)} \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
      3. unpow276.0%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \sqrt{1 + \color{blue}{\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)} \cdot \frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}}} \]
      4. hypot-1-def88.6%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \color{blue}{\mathsf{hypot}\left(1, \frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)} \]
      5. associate-/r*88.5%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \color{blue}{\frac{\frac{U}{2 \cdot J}}{\cos \left(\frac{K}{2}\right)}}\right) \]
      6. cos-neg88.5%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2 \cdot J}}{\color{blue}{\cos \left(-\frac{K}{2}\right)}}\right) \]
      7. distribute-frac-neg88.5%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2 \cdot J}}{\cos \color{blue}{\left(\frac{-K}{2}\right)}}\right) \]
      8. associate-/r*88.6%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \color{blue}{\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{-K}{2}\right)}}\right) \]
      9. associate-/r*88.5%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \color{blue}{\frac{\frac{U}{2 \cdot J}}{\cos \left(\frac{-K}{2}\right)}}\right) \]
      10. *-commutative88.5%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{\color{blue}{J \cdot 2}}}{\cos \left(\frac{-K}{2}\right)}\right) \]
      11. distribute-frac-neg88.5%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{\cos \color{blue}{\left(-\frac{K}{2}\right)}}\right) \]
      12. cos-neg88.5%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{\color{blue}{\cos \left(\frac{K}{2}\right)}}\right) \]
    3. Simplified88.5%

      \[\leadsto \color{blue}{\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{\cos \left(\frac{K}{2}\right)}\right)} \]
    4. Add Preprocessing

    if 4.90000000000000032e225 < U

    1. Initial program 27.9%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified55.7%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around 0 56.6%

      \[\leadsto \color{blue}{-1 \cdot U} \]
    5. Step-by-step derivation
      1. neg-mul-156.6%

        \[\leadsto \color{blue}{-U} \]
    6. Simplified56.6%

      \[\leadsto \color{blue}{-U} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 86.1% accurate, 1.3× speedup?

\[\begin{array}{l} U_m = \left|U\right| \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;U\_m \leq 5 \cdot 10^{+225}:\\ \;\;\;\;J \cdot \left(\left(-2 \cdot t\_0\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J \cdot t\_0}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-U\_m\\ \end{array} \end{array} \]
U_m = (fabs.f64 U)
(FPCore (J K U_m)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= U_m 5e+225)
     (* J (* (* -2.0 t_0) (hypot 1.0 (/ (/ U_m 2.0) (* J t_0)))))
     (- U_m))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
	double t_0 = cos((K / 2.0));
	double tmp;
	if (U_m <= 5e+225) {
		tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J * t_0))));
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
	double t_0 = Math.cos((K / 2.0));
	double tmp;
	if (U_m <= 5e+225) {
		tmp = J * ((-2.0 * t_0) * Math.hypot(1.0, ((U_m / 2.0) / (J * t_0))));
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = math.fabs(U)
def code(J, K, U_m):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if U_m <= 5e+225:
		tmp = J * ((-2.0 * t_0) * math.hypot(1.0, ((U_m / 2.0) / (J * t_0))))
	else:
		tmp = -U_m
	return tmp
U_m = abs(U)
function code(J, K, U_m)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (U_m <= 5e+225)
		tmp = Float64(J * Float64(Float64(-2.0 * t_0) * hypot(1.0, Float64(Float64(U_m / 2.0) / Float64(J * t_0)))));
	else
		tmp = Float64(-U_m);
	end
	return tmp
end
U_m = abs(U);
function tmp_2 = code(J, K, U_m)
	t_0 = cos((K / 2.0));
	tmp = 0.0;
	if (U_m <= 5e+225)
		tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J * t_0))));
	else
		tmp = -U_m;
	end
	tmp_2 = tmp;
end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[U$95$m, 5e+225], N[(J * N[(N[(-2.0 * t$95$0), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / N[(J * t$95$0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]]
\begin{array}{l}
U_m = \left|U\right|

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U\_m \leq 5 \cdot 10^{+225}:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot t\_0\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J \cdot t\_0}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if U < 4.99999999999999981e225

    1. Initial program 76.0%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified88.5%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing

    if 4.99999999999999981e225 < U

    1. Initial program 27.9%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified55.7%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around 0 56.6%

      \[\leadsto \color{blue}{-1 \cdot U} \]
    5. Step-by-step derivation
      1. neg-mul-156.6%

        \[\leadsto \color{blue}{-U} \]
    6. Simplified56.6%

      \[\leadsto \color{blue}{-U} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 70.5% accurate, 1.9× speedup?

\[\begin{array}{l} U_m = \left|U\right| \\ \begin{array}{l} \mathbf{if}\;U\_m \leq 2.7 \cdot 10^{+98}:\\ \;\;\;\;J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-U\_m\\ \end{array} \end{array} \]
U_m = (fabs.f64 U)
(FPCore (J K U_m)
 :precision binary64
 (if (<= U_m 2.7e+98)
   (* J (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J))))
   (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
	double tmp;
	if (U_m <= 2.7e+98) {
		tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J)));
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
	double tmp;
	if (U_m <= 2.7e+98) {
		tmp = J * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 2.0) / J)));
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = math.fabs(U)
def code(J, K, U_m):
	tmp = 0
	if U_m <= 2.7e+98:
		tmp = J * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 2.0) / J)))
	else:
		tmp = -U_m
	return tmp
U_m = abs(U)
function code(J, K, U_m)
	tmp = 0.0
	if (U_m <= 2.7e+98)
		tmp = Float64(J * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J))));
	else
		tmp = Float64(-U_m);
	end
	return tmp
end
U_m = abs(U);
function tmp_2 = code(J, K, U_m)
	tmp = 0.0;
	if (U_m <= 2.7e+98)
		tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J)));
	else
		tmp = -U_m;
	end
	tmp_2 = tmp;
end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 2.7e+98], N[(J * N[(N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|

\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 2.7 \cdot 10^{+98}:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if U < 2.7e98

    1. Initial program 81.1%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified91.6%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in K around 0 75.1%

      \[\leadsto J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{\color{blue}{J}}\right)\right) \]

    if 2.7e98 < U

    1. Initial program 33.8%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified61.2%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around 0 45.8%

      \[\leadsto \color{blue}{-1 \cdot U} \]
    5. Step-by-step derivation
      1. neg-mul-145.8%

        \[\leadsto \color{blue}{-U} \]
    6. Simplified45.8%

      \[\leadsto \color{blue}{-U} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 62.5% accurate, 3.5× speedup?

\[\begin{array}{l} U_m = \left|U\right| \\ \begin{array}{l} \mathbf{if}\;U\_m \leq 8.5 \cdot 10^{-20}:\\ \;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\ \mathbf{elif}\;U\_m \leq 4.5 \cdot 10^{+97}:\\ \;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U\_m}{J}\right)\\ \mathbf{else}:\\ \;\;\;\;-U\_m\\ \end{array} \end{array} \]
U_m = (fabs.f64 U)
(FPCore (J K U_m)
 :precision binary64
 (if (<= U_m 8.5e-20)
   (* (* -2.0 J) (cos (* K 0.5)))
   (if (<= U_m 4.5e+97) (* (* -2.0 J) (hypot 1.0 (* 0.5 (/ U_m J)))) (- U_m))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
	double tmp;
	if (U_m <= 8.5e-20) {
		tmp = (-2.0 * J) * cos((K * 0.5));
	} else if (U_m <= 4.5e+97) {
		tmp = (-2.0 * J) * hypot(1.0, (0.5 * (U_m / J)));
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
	double tmp;
	if (U_m <= 8.5e-20) {
		tmp = (-2.0 * J) * Math.cos((K * 0.5));
	} else if (U_m <= 4.5e+97) {
		tmp = (-2.0 * J) * Math.hypot(1.0, (0.5 * (U_m / J)));
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = math.fabs(U)
def code(J, K, U_m):
	tmp = 0
	if U_m <= 8.5e-20:
		tmp = (-2.0 * J) * math.cos((K * 0.5))
	elif U_m <= 4.5e+97:
		tmp = (-2.0 * J) * math.hypot(1.0, (0.5 * (U_m / J)))
	else:
		tmp = -U_m
	return tmp
U_m = abs(U)
function code(J, K, U_m)
	tmp = 0.0
	if (U_m <= 8.5e-20)
		tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5)));
	elseif (U_m <= 4.5e+97)
		tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(0.5 * Float64(U_m / J))));
	else
		tmp = Float64(-U_m);
	end
	return tmp
end
U_m = abs(U);
function tmp_2 = code(J, K, U_m)
	tmp = 0.0;
	if (U_m <= 8.5e-20)
		tmp = (-2.0 * J) * cos((K * 0.5));
	elseif (U_m <= 4.5e+97)
		tmp = (-2.0 * J) * hypot(1.0, (0.5 * (U_m / J)));
	else
		tmp = -U_m;
	end
	tmp_2 = tmp;
end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 8.5e-20], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 4.5e+97], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], (-U$95$m)]]
\begin{array}{l}
U_m = \left|U\right|

\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 8.5 \cdot 10^{-20}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\

\mathbf{elif}\;U\_m \leq 4.5 \cdot 10^{+97}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U\_m}{J}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if U < 8.5000000000000005e-20

    1. Initial program 81.6%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified90.4%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around inf 61.3%

      \[\leadsto \color{blue}{-2 \cdot \left(J \cdot \cos \left(0.5 \cdot K\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative61.3%

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

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

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

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

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

        \[\leadsto \cos \left(0.5 \cdot K\right) \cdot \color{blue}{\left(-2 \cdot J\right)} \]
    6. Simplified61.3%

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

    if 8.5000000000000005e-20 < U < 4.49999999999999976e97

    1. Initial program 77.7%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Step-by-step derivation
      1. *-commutative77.7%

        \[\leadsto \left(\color{blue}{\left(J \cdot -2\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
      2. associate-*l*77.7%

        \[\leadsto \color{blue}{\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right)} \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
      3. unpow277.7%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \sqrt{1 + \color{blue}{\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)} \cdot \frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}}} \]
      4. hypot-1-def99.8%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \color{blue}{\mathsf{hypot}\left(1, \frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)} \]
      5. associate-/r*99.8%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \color{blue}{\frac{\frac{U}{2 \cdot J}}{\cos \left(\frac{K}{2}\right)}}\right) \]
      6. cos-neg99.8%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2 \cdot J}}{\color{blue}{\cos \left(-\frac{K}{2}\right)}}\right) \]
      7. distribute-frac-neg99.8%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2 \cdot J}}{\cos \color{blue}{\left(\frac{-K}{2}\right)}}\right) \]
      8. associate-/r*99.8%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \color{blue}{\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{-K}{2}\right)}}\right) \]
      9. associate-/r*99.8%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \color{blue}{\frac{\frac{U}{2 \cdot J}}{\cos \left(\frac{-K}{2}\right)}}\right) \]
      10. *-commutative99.8%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{\color{blue}{J \cdot 2}}}{\cos \left(\frac{-K}{2}\right)}\right) \]
      11. distribute-frac-neg99.8%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{\cos \color{blue}{\left(-\frac{K}{2}\right)}}\right) \]
      12. cos-neg99.8%

        \[\leadsto \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{\color{blue}{\cos \left(\frac{K}{2}\right)}}\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{\cos \left(\frac{K}{2}\right)}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. log1p-expm1-u99.8%

        \[\leadsto \left(J \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right)}\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{\cos \left(\frac{K}{2}\right)}\right) \]
      2. div-inv99.8%

        \[\leadsto \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(-2 \cdot \cos \color{blue}{\left(K \cdot \frac{1}{2}\right)}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{\cos \left(\frac{K}{2}\right)}\right) \]
      3. metadata-eval99.8%

        \[\leadsto \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(-2 \cdot \cos \left(K \cdot \color{blue}{0.5}\right)\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{\cos \left(\frac{K}{2}\right)}\right) \]
    6. Applied egg-rr99.8%

      \[\leadsto \left(J \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)}\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{\cos \left(\frac{K}{2}\right)}\right) \]
    7. Taylor expanded in K around 0 47.8%

      \[\leadsto \color{blue}{-2 \cdot \left(J \cdot \sqrt{1 + 0.25 \cdot \frac{{U}^{2}}{{J}^{2}}}\right)} \]
    8. Step-by-step derivation
      1. associate-*r*47.8%

        \[\leadsto \color{blue}{\left(-2 \cdot J\right) \cdot \sqrt{1 + 0.25 \cdot \frac{{U}^{2}}{{J}^{2}}}} \]
      2. metadata-eval47.8%

        \[\leadsto \left(-2 \cdot J\right) \cdot \sqrt{\color{blue}{1 \cdot 1} + 0.25 \cdot \frac{{U}^{2}}{{J}^{2}}} \]
      3. metadata-eval47.8%

        \[\leadsto \left(-2 \cdot J\right) \cdot \sqrt{1 \cdot 1 + \color{blue}{\left(0.5 \cdot 0.5\right)} \cdot \frac{{U}^{2}}{{J}^{2}}} \]
      4. unpow247.8%

        \[\leadsto \left(-2 \cdot J\right) \cdot \sqrt{1 \cdot 1 + \left(0.5 \cdot 0.5\right) \cdot \frac{\color{blue}{U \cdot U}}{{J}^{2}}} \]
      5. unpow247.8%

        \[\leadsto \left(-2 \cdot J\right) \cdot \sqrt{1 \cdot 1 + \left(0.5 \cdot 0.5\right) \cdot \frac{U \cdot U}{\color{blue}{J \cdot J}}} \]
      6. times-frac47.9%

        \[\leadsto \left(-2 \cdot J\right) \cdot \sqrt{1 \cdot 1 + \left(0.5 \cdot 0.5\right) \cdot \color{blue}{\left(\frac{U}{J} \cdot \frac{U}{J}\right)}} \]
      7. swap-sqr47.9%

        \[\leadsto \left(-2 \cdot J\right) \cdot \sqrt{1 \cdot 1 + \color{blue}{\left(0.5 \cdot \frac{U}{J}\right) \cdot \left(0.5 \cdot \frac{U}{J}\right)}} \]
      8. hypot-undefine55.3%

        \[\leadsto \left(-2 \cdot J\right) \cdot \color{blue}{\mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)} \]
    9. Simplified55.3%

      \[\leadsto \color{blue}{\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)} \]

    if 4.49999999999999976e97 < U

    1. Initial program 33.8%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified61.2%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around 0 45.8%

      \[\leadsto \color{blue}{-1 \cdot U} \]
    5. Step-by-step derivation
      1. neg-mul-145.8%

        \[\leadsto \color{blue}{-U} \]
    6. Simplified45.8%

      \[\leadsto \color{blue}{-U} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification57.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq 8.5 \cdot 10^{-20}:\\ \;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\ \mathbf{elif}\;U \leq 4.5 \cdot 10^{+97}:\\ \;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 57.8% accurate, 3.7× speedup?

\[\begin{array}{l} U_m = \left|U\right| \\ \begin{array}{l} \mathbf{if}\;U\_m \leq 0.205:\\ \;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-U\_m\\ \end{array} \end{array} \]
U_m = (fabs.f64 U)
(FPCore (J K U_m)
 :precision binary64
 (if (<= U_m 0.205) (* (* -2.0 J) (cos (* K 0.5))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
	double tmp;
	if (U_m <= 0.205) {
		tmp = (-2.0 * J) * cos((K * 0.5));
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
    real(8), intent (in) :: j
    real(8), intent (in) :: k
    real(8), intent (in) :: u_m
    real(8) :: tmp
    if (u_m <= 0.205d0) then
        tmp = ((-2.0d0) * j) * cos((k * 0.5d0))
    else
        tmp = -u_m
    end if
    code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
	double tmp;
	if (U_m <= 0.205) {
		tmp = (-2.0 * J) * Math.cos((K * 0.5));
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = math.fabs(U)
def code(J, K, U_m):
	tmp = 0
	if U_m <= 0.205:
		tmp = (-2.0 * J) * math.cos((K * 0.5))
	else:
		tmp = -U_m
	return tmp
U_m = abs(U)
function code(J, K, U_m)
	tmp = 0.0
	if (U_m <= 0.205)
		tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5)));
	else
		tmp = Float64(-U_m);
	end
	return tmp
end
U_m = abs(U);
function tmp_2 = code(J, K, U_m)
	tmp = 0.0;
	if (U_m <= 0.205)
		tmp = (-2.0 * J) * cos((K * 0.5));
	else
		tmp = -U_m;
	end
	tmp_2 = tmp;
end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 0.205], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|

\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 0.205:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if U < 0.204999999999999988

    1. Initial program 81.5%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified90.7%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around inf 60.4%

      \[\leadsto \color{blue}{-2 \cdot \left(J \cdot \cos \left(0.5 \cdot K\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative60.4%

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

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

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

        \[\leadsto \color{blue}{\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot -2\right)} \]
      5. *-commutative60.4%

        \[\leadsto \cos \color{blue}{\left(0.5 \cdot K\right)} \cdot \left(J \cdot -2\right) \]
      6. *-commutative60.4%

        \[\leadsto \cos \left(0.5 \cdot K\right) \cdot \color{blue}{\left(-2 \cdot J\right)} \]
    6. Simplified60.4%

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

    if 0.204999999999999988 < U

    1. Initial program 46.4%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified72.5%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around 0 41.4%

      \[\leadsto \color{blue}{-1 \cdot U} \]
    5. Step-by-step derivation
      1. neg-mul-141.4%

        \[\leadsto \color{blue}{-U} \]
    6. Simplified41.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq 0.205:\\ \;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 40.9% accurate, 52.4× speedup?

\[\begin{array}{l} U_m = \left|U\right| \\ \begin{array}{l} \mathbf{if}\;U\_m \leq 8.8 \cdot 10^{-13}:\\ \;\;\;\;-2 \cdot J\\ \mathbf{else}:\\ \;\;\;\;-U\_m\\ \end{array} \end{array} \]
U_m = (fabs.f64 U)
(FPCore (J K U_m) :precision binary64 (if (<= U_m 8.8e-13) (* -2.0 J) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
	double tmp;
	if (U_m <= 8.8e-13) {
		tmp = -2.0 * J;
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
    real(8), intent (in) :: j
    real(8), intent (in) :: k
    real(8), intent (in) :: u_m
    real(8) :: tmp
    if (u_m <= 8.8d-13) then
        tmp = (-2.0d0) * j
    else
        tmp = -u_m
    end if
    code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
	double tmp;
	if (U_m <= 8.8e-13) {
		tmp = -2.0 * J;
	} else {
		tmp = -U_m;
	}
	return tmp;
}
U_m = math.fabs(U)
def code(J, K, U_m):
	tmp = 0
	if U_m <= 8.8e-13:
		tmp = -2.0 * J
	else:
		tmp = -U_m
	return tmp
U_m = abs(U)
function code(J, K, U_m)
	tmp = 0.0
	if (U_m <= 8.8e-13)
		tmp = Float64(-2.0 * J);
	else
		tmp = Float64(-U_m);
	end
	return tmp
end
U_m = abs(U);
function tmp_2 = code(J, K, U_m)
	tmp = 0.0;
	if (U_m <= 8.8e-13)
		tmp = -2.0 * J;
	else
		tmp = -U_m;
	end
	tmp_2 = tmp;
end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 8.8e-13], N[(-2.0 * J), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|

\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 8.8 \cdot 10^{-13}:\\
\;\;\;\;-2 \cdot J\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if U < 8.79999999999999986e-13

    1. Initial program 81.6%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified90.4%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around inf 61.3%

      \[\leadsto \color{blue}{-2 \cdot \left(J \cdot \cos \left(0.5 \cdot K\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative61.3%

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

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

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

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

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

        \[\leadsto \cos \left(0.5 \cdot K\right) \cdot \color{blue}{\left(-2 \cdot J\right)} \]
    6. Simplified61.3%

      \[\leadsto \color{blue}{\cos \left(0.5 \cdot K\right) \cdot \left(-2 \cdot J\right)} \]
    7. Step-by-step derivation
      1. *-commutative61.3%

        \[\leadsto \cos \color{blue}{\left(K \cdot 0.5\right)} \cdot \left(-2 \cdot J\right) \]
      2. expm1-log1p-u61.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(K \cdot 0.5\right)\right)\right)} \cdot \left(-2 \cdot J\right) \]
    8. Applied egg-rr61.2%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(K \cdot 0.5\right)\right)\right)} \cdot \left(-2 \cdot J\right) \]
    9. Taylor expanded in K around 0 36.4%

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

    if 8.79999999999999986e-13 < U

    1. Initial program 48.6%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified74.2%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around 0 41.2%

      \[\leadsto \color{blue}{-1 \cdot U} \]
    5. Step-by-step derivation
      1. neg-mul-141.2%

        \[\leadsto \color{blue}{-U} \]
    6. Simplified41.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq 8.8 \cdot 10^{-13}:\\ \;\;\;\;-2 \cdot J\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 26.9% accurate, 59.9× speedup?

\[\begin{array}{l} U_m = \left|U\right| \\ \begin{array}{l} \mathbf{if}\;K \leq 9.5 \cdot 10^{+138}:\\ \;\;\;\;-U\_m\\ \mathbf{else}:\\ \;\;\;\;U\_m\\ \end{array} \end{array} \]
U_m = (fabs.f64 U)
(FPCore (J K U_m) :precision binary64 (if (<= K 9.5e+138) (- U_m) U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
	double tmp;
	if (K <= 9.5e+138) {
		tmp = -U_m;
	} else {
		tmp = U_m;
	}
	return tmp;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
    real(8), intent (in) :: j
    real(8), intent (in) :: k
    real(8), intent (in) :: u_m
    real(8) :: tmp
    if (k <= 9.5d+138) then
        tmp = -u_m
    else
        tmp = u_m
    end if
    code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
	double tmp;
	if (K <= 9.5e+138) {
		tmp = -U_m;
	} else {
		tmp = U_m;
	}
	return tmp;
}
U_m = math.fabs(U)
def code(J, K, U_m):
	tmp = 0
	if K <= 9.5e+138:
		tmp = -U_m
	else:
		tmp = U_m
	return tmp
U_m = abs(U)
function code(J, K, U_m)
	tmp = 0.0
	if (K <= 9.5e+138)
		tmp = Float64(-U_m);
	else
		tmp = U_m;
	end
	return tmp
end
U_m = abs(U);
function tmp_2 = code(J, K, U_m)
	tmp = 0.0;
	if (K <= 9.5e+138)
		tmp = -U_m;
	else
		tmp = U_m;
	end
	tmp_2 = tmp;
end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := If[LessEqual[K, 9.5e+138], (-U$95$m), U$95$m]
\begin{array}{l}
U_m = \left|U\right|

\\
\begin{array}{l}
\mathbf{if}\;K \leq 9.5 \cdot 10^{+138}:\\
\;\;\;\;-U\_m\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if K < 9.49999999999999998e138

    1. Initial program 71.9%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified84.4%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in J around 0 25.7%

      \[\leadsto \color{blue}{-1 \cdot U} \]
    5. Step-by-step derivation
      1. neg-mul-125.7%

        \[\leadsto \color{blue}{-U} \]
    6. Simplified25.7%

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

    if 9.49999999999999998e138 < K

    1. Initial program 70.1%

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
    2. Simplified92.2%

      \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in U around -inf 33.1%

      \[\leadsto \color{blue}{U} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 25.7% accurate, 420.0× speedup?

\[\begin{array}{l} U_m = \left|U\right| \\ U\_m \end{array} \]
U_m = (fabs.f64 U)
(FPCore (J K U_m) :precision binary64 U_m)
U_m = fabs(U);
double code(double J, double K, double U_m) {
	return U_m;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
    real(8), intent (in) :: j
    real(8), intent (in) :: k
    real(8), intent (in) :: u_m
    code = u_m
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
	return U_m;
}
U_m = math.fabs(U)
def code(J, K, U_m):
	return U_m
U_m = abs(U)
function code(J, K, U_m)
	return U_m
end
U_m = abs(U);
function tmp = code(J, K, U_m)
	tmp = U_m;
end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := U$95$m
\begin{array}{l}
U_m = \left|U\right|

\\
U\_m
\end{array}
Derivation
  1. Initial program 71.7%

    \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}} \]
  2. Simplified85.5%

    \[\leadsto \color{blue}{J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J \cdot \cos \left(\frac{K}{2}\right)}\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in U around -inf 29.8%

    \[\leadsto \color{blue}{U} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2024137 
(FPCore (J K U)
  :name "Maksimov and Kolovsky, Equation (3)"
  :precision binary64
  (* (* (* -2.0 J) (cos (/ K 2.0))) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) (cos (/ K 2.0)))) 2.0)))))