Maksimov and Kolovsky, Equation (3)

Percentage Accurate: 72.6% → 99.1%
Time: 16.7s
Alternatives: 12
Speedup: 1.9×

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 12 alternatives:

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

Initial Program: 72.6% 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.1% accurate, 0.3× speedup?

\[\begin{array}{l} U = |U|\\ \\ \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}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \mathbf{elif}\;t_1 \leq 10^{+300}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\ \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0)))
        (t_1
         (*
          (* (* -2.0 J) t_0)
          (sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
   (if (<= t_1 (- INFINITY))
     (* -2.0 (* U 0.5))
     (if (<= t_1 1e+300) t_1 (* -2.0 (* U -0.5))))))
U = abs(U);
double code(double J, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = -2.0 * (U * 0.5);
	} else if (t_1 <= 1e+300) {
		tmp = t_1;
	} else {
		tmp = -2.0 * (U * -0.5);
	}
	return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	double t_1 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = -2.0 * (U * 0.5);
	} else if (t_1 <= 1e+300) {
		tmp = t_1;
	} else {
		tmp = -2.0 * (U * -0.5);
	}
	return tmp;
}
U = abs(U)
def code(J, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0)))
	tmp = 0
	if t_1 <= -math.inf:
		tmp = -2.0 * (U * 0.5)
	elif t_1 <= 1e+300:
		tmp = t_1
	else:
		tmp = -2.0 * (U * -0.5)
	return tmp
U = abs(U)
function code(J, K, U)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(t_0 * Float64(J * 2.0))) ^ 2.0))))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(-2.0 * Float64(U * 0.5));
	elseif (t_1 <= 1e+300)
		tmp = t_1;
	else
		tmp = Float64(-2.0 * Float64(U * -0.5));
	end
	return tmp
end
U = abs(U)
function tmp_2 = code(J, K, U)
	t_0 = cos((K / 2.0));
	t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0)));
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = -2.0 * (U * 0.5);
	elseif (t_1 <= 1e+300)
		tmp = t_1;
	else
		tmp = -2.0 * (U * -0.5);
	end
	tmp_2 = tmp;
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := 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 / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+300], t$95$1, N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
U = |U|\\
\\
\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}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\

\mathbf{elif}\;t_1 \leq 10^{+300}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\


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

    1. Initial program 6.2%

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

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

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

    if -inf.0 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < 1.0000000000000001e300

    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}} \]

    if 1.0000000000000001e300 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2))))

    1. Initial program 8.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. Simplified68.5%

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

      \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U\right)} \]
    4. Step-by-step derivation
      1. *-commutative53.2%

        \[\leadsto -2 \cdot \color{blue}{\left(U \cdot -0.5\right)} \]
    5. Simplified53.2%

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

    \[\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:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \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^{+300}:\\ \;\;\;\;\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}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\ \end{array} \]

Alternative 2: 78.1% accurate, 1.3× speedup?

\[\begin{array}{l} U = |U|\\ \\ \begin{array}{l} t_0 := -2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\right)\right)\\ \mathbf{if}\;J \leq -9 \cdot 10^{-106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\ \mathbf{elif}\;J \leq 1.2 \cdot 10^{-94}:\\ \;\;\;\;-2 \cdot \mathsf{fma}\left(0.5, U, \frac{{\left(J \cdot \cos \left(K \cdot 0.5\right)\right)}^{2}}{U}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (* -2.0 (* J (* (cos (/ K 2.0)) (hypot 1.0 (* U (/ 0.5 J))))))))
   (if (<= J -9e-106)
     t_0
     (if (<= J -2e-310)
       (* -2.0 (- (* U -0.5) (/ (* J J) U)))
       (if (<= J 1.2e-94)
         (* -2.0 (fma 0.5 U (/ (pow (* J (cos (* K 0.5))) 2.0) U)))
         t_0)))))
U = abs(U);
double code(double J, double K, double U) {
	double t_0 = -2.0 * (J * (cos((K / 2.0)) * hypot(1.0, (U * (0.5 / J)))));
	double tmp;
	if (J <= -9e-106) {
		tmp = t_0;
	} else if (J <= -2e-310) {
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	} else if (J <= 1.2e-94) {
		tmp = -2.0 * fma(0.5, U, (pow((J * cos((K * 0.5))), 2.0) / U));
	} else {
		tmp = t_0;
	}
	return tmp;
}
U = abs(U)
function code(J, K, U)
	t_0 = Float64(-2.0 * Float64(J * Float64(cos(Float64(K / 2.0)) * hypot(1.0, Float64(U * Float64(0.5 / J))))))
	tmp = 0.0
	if (J <= -9e-106)
		tmp = t_0;
	elseif (J <= -2e-310)
		tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(Float64(J * J) / U)));
	elseif (J <= 1.2e-94)
		tmp = Float64(-2.0 * fma(0.5, U, Float64((Float64(J * cos(Float64(K * 0.5))) ^ 2.0) / U)));
	else
		tmp = t_0;
	end
	return tmp
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -9e-106], t$95$0, If[LessEqual[J, -2e-310], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(N[(J * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.2e-94], N[(-2.0 * N[(0.5 * U + N[(N[Power[N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\right)\right)\\
\mathbf{if}\;J \leq -9 \cdot 10^{-106}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\

\mathbf{elif}\;J \leq 1.2 \cdot 10^{-94}:\\
\;\;\;\;-2 \cdot \mathsf{fma}\left(0.5, U, \frac{{\left(J \cdot \cos \left(K \cdot 0.5\right)\right)}^{2}}{U}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if J < -8.99999999999999911e-106 or 1.2e-94 < J

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

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

      \[\leadsto -2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, \color{blue}{0.5 \cdot \frac{U}{J}}\right)\right)\right) \]
    4. Step-by-step derivation
      1. associate-*r/85.1%

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

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

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

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

    if -8.99999999999999911e-106 < J < -1.999999999999994e-310

    1. Initial program 42.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. Simplified68.3%

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

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

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

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

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{J \cdot J}}\right)} \]
    6. Taylor expanded in U around -inf 51.6%

      \[\leadsto -2 \cdot \color{blue}{\left(-1 \cdot \frac{{J}^{2}}{U} + -0.5 \cdot U\right)} \]
    7. Step-by-step derivation
      1. +-commutative51.6%

        \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U + -1 \cdot \frac{{J}^{2}}{U}\right)} \]
      2. mul-1-neg51.6%

        \[\leadsto -2 \cdot \left(-0.5 \cdot U + \color{blue}{\left(-\frac{{J}^{2}}{U}\right)}\right) \]
      3. unsub-neg51.6%

        \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U - \frac{{J}^{2}}{U}\right)} \]
      4. *-commutative51.6%

        \[\leadsto -2 \cdot \left(\color{blue}{U \cdot -0.5} - \frac{{J}^{2}}{U}\right) \]
      5. unpow251.6%

        \[\leadsto -2 \cdot \left(U \cdot -0.5 - \frac{\color{blue}{J \cdot J}}{U}\right) \]
    8. Simplified51.6%

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

    if -1.999999999999994e-310 < J < 1.2e-94

    1. Initial program 41.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. Simplified59.9%

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

      \[\leadsto -2 \cdot \color{blue}{\left(0.5 \cdot U + \frac{{J}^{2} \cdot {\cos \left(0.5 \cdot K\right)}^{2}}{U}\right)} \]
    4. Step-by-step derivation
      1. fma-def46.2%

        \[\leadsto -2 \cdot \color{blue}{\mathsf{fma}\left(0.5, U, \frac{{J}^{2} \cdot {\cos \left(0.5 \cdot K\right)}^{2}}{U}\right)} \]
      2. unpow246.2%

        \[\leadsto -2 \cdot \mathsf{fma}\left(0.5, U, \frac{\color{blue}{\left(J \cdot J\right)} \cdot {\cos \left(0.5 \cdot K\right)}^{2}}{U}\right) \]
      3. *-commutative46.2%

        \[\leadsto -2 \cdot \mathsf{fma}\left(0.5, U, \frac{\left(J \cdot J\right) \cdot {\cos \color{blue}{\left(K \cdot 0.5\right)}}^{2}}{U}\right) \]
      4. unpow246.2%

        \[\leadsto -2 \cdot \mathsf{fma}\left(0.5, U, \frac{\left(J \cdot J\right) \cdot \color{blue}{\left(\cos \left(K \cdot 0.5\right) \cdot \cos \left(K \cdot 0.5\right)\right)}}{U}\right) \]
      5. swap-sqr46.2%

        \[\leadsto -2 \cdot \mathsf{fma}\left(0.5, U, \frac{\color{blue}{\left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)}}{U}\right) \]
      6. unpow246.2%

        \[\leadsto -2 \cdot \mathsf{fma}\left(0.5, U, \frac{\color{blue}{{\left(J \cdot \cos \left(K \cdot 0.5\right)\right)}^{2}}}{U}\right) \]
      7. *-commutative46.2%

        \[\leadsto -2 \cdot \mathsf{fma}\left(0.5, U, \frac{{\left(J \cdot \cos \color{blue}{\left(0.5 \cdot K\right)}\right)}^{2}}{U}\right) \]
    5. Simplified46.2%

      \[\leadsto -2 \cdot \color{blue}{\mathsf{fma}\left(0.5, U, \frac{{\left(J \cdot \cos \left(0.5 \cdot K\right)\right)}^{2}}{U}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification72.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \leq -9 \cdot 10^{-106}:\\ \;\;\;\;-2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\right)\right)\\ \mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\ \mathbf{elif}\;J \leq 1.2 \cdot 10^{-94}:\\ \;\;\;\;-2 \cdot \mathsf{fma}\left(0.5, U, \frac{{\left(J \cdot \cos \left(K \cdot 0.5\right)\right)}^{2}}{U}\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\right)\right)\\ \end{array} \]

Alternative 3: 88.0% accurate, 1.3× speedup?

\[\begin{array}{l} U = |U|\\ \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ -2 \cdot \left(J \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right) \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (* -2.0 (* J (* t_0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
U = abs(U);
double code(double J, double K, double U) {
	double t_0 = cos((K / 2.0));
	return -2.0 * (J * (t_0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = Math.abs(U);
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.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = abs(U)
def code(J, K, U):
	t_0 = math.cos((K / 2.0))
	return -2.0 * (J * (t_0 * math.hypot(1.0, (U / (J * (2.0 * t_0))))))
U = abs(U)
function code(J, K, U)
	t_0 = cos(Float64(K / 2.0))
	return Float64(-2.0 * Float64(J * Float64(t_0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0)))))))
end
U = abs(U)
function tmp = code(J, K, U)
	t_0 = cos((K / 2.0));
	tmp = -2.0 * (J * (t_0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(-2.0 * N[(J * N[(t$95$0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(J \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 71.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. Simplified86.3%

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

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

Alternative 4: 88.0% accurate, 1.3× speedup?

\[\begin{array}{l} U = |U|\\ \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ -2 \cdot \left(t_0 \cdot \left(J \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J \cdot t_0}\right)\right)\right) \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (* -2.0 (* t_0 (* J (hypot 1.0 (* 0.5 (/ U (* J t_0)))))))))
U = abs(U);
double code(double J, double K, double U) {
	double t_0 = cos((K / 2.0));
	return -2.0 * (t_0 * (J * hypot(1.0, (0.5 * (U / (J * t_0))))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	return -2.0 * (t_0 * (J * Math.hypot(1.0, (0.5 * (U / (J * t_0))))));
}
U = abs(U)
def code(J, K, U):
	t_0 = math.cos((K / 2.0))
	return -2.0 * (t_0 * (J * math.hypot(1.0, (0.5 * (U / (J * t_0))))))
U = abs(U)
function code(J, K, U)
	t_0 = cos(Float64(K / 2.0))
	return Float64(-2.0 * Float64(t_0 * Float64(J * hypot(1.0, Float64(0.5 * Float64(U / Float64(J * t_0)))))))
end
U = abs(U)
function tmp = code(J, K, U)
	t_0 = cos((K / 2.0));
	tmp = -2.0 * (t_0 * (J * hypot(1.0, (0.5 * (U / (J * t_0))))));
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(-2.0 * N[(t$95$0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / N[(J * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(t_0 \cdot \left(J \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J \cdot t_0}\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 71.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. Step-by-step derivation
    1. associate-*l*71.5%

      \[\leadsto \color{blue}{\left(-2 \cdot \left(J \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}} \]
    2. associate-*l*71.5%

      \[\leadsto \color{blue}{-2 \cdot \left(\left(J \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}}\right)} \]
    3. *-commutative71.5%

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

      \[\leadsto -2 \cdot \left(\left(\cos \left(\frac{K}{2}\right) \cdot J\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)}}}\right) \]
    5. sqr-neg71.5%

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

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

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

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

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

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

Alternative 5: 88.1% accurate, 1.3× speedup?

\[\begin{array}{l} U = |U|\\ \\ \begin{array}{l} t_0 := J \cdot \cos \left(\frac{K}{2}\right)\\ -2 \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{U}{2 \cdot t_0}\right)\right) \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (* J (cos (/ K 2.0)))))
   (* -2.0 (* t_0 (hypot 1.0 (/ U (* 2.0 t_0)))))))
U = abs(U);
double code(double J, double K, double U) {
	double t_0 = J * cos((K / 2.0));
	return -2.0 * (t_0 * hypot(1.0, (U / (2.0 * t_0))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
	double t_0 = J * Math.cos((K / 2.0));
	return -2.0 * (t_0 * Math.hypot(1.0, (U / (2.0 * t_0))));
}
U = abs(U)
def code(J, K, U):
	t_0 = J * math.cos((K / 2.0))
	return -2.0 * (t_0 * math.hypot(1.0, (U / (2.0 * t_0))))
U = abs(U)
function code(J, K, U)
	t_0 = Float64(J * cos(Float64(K / 2.0)))
	return Float64(-2.0 * Float64(t_0 * hypot(1.0, Float64(U / Float64(2.0 * t_0)))))
end
U = abs(U)
function tmp = code(J, K, U)
	t_0 = J * cos((K / 2.0));
	tmp = -2.0 * (t_0 * hypot(1.0, (U / (2.0 * t_0))));
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(-2.0 * N[(t$95$0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{U}{2 \cdot t_0}\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 71.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. Step-by-step derivation
    1. associate-*l*71.5%

      \[\leadsto \color{blue}{\left(-2 \cdot \left(J \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}} \]
    2. associate-*l*71.5%

      \[\leadsto \color{blue}{-2 \cdot \left(\left(J \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}}\right)} \]
    3. unpow271.5%

      \[\leadsto -2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\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)}}}\right) \]
    4. sqr-neg71.5%

      \[\leadsto -2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + \color{blue}{\left(-\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right) \cdot \left(-\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}}\right) \]
    5. distribute-frac-neg71.5%

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

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

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

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

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

Alternative 6: 78.2% accurate, 1.9× speedup?

\[\begin{array}{l} U = |U|\\ \\ \begin{array}{l} t_0 := -2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\right)\right)\\ \mathbf{if}\;J \leq -6.5 \cdot 10^{-104}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\ \mathbf{elif}\;J \leq 2.6 \cdot 10^{-97}:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (* -2.0 (* J (* (cos (/ K 2.0)) (hypot 1.0 (* U (/ 0.5 J))))))))
   (if (<= J -6.5e-104)
     t_0
     (if (<= J -2e-310)
       (* -2.0 (- (* U -0.5) (/ (* J J) U)))
       (if (<= J 2.6e-97) (* -2.0 (* U 0.5)) t_0)))))
U = abs(U);
double code(double J, double K, double U) {
	double t_0 = -2.0 * (J * (cos((K / 2.0)) * hypot(1.0, (U * (0.5 / J)))));
	double tmp;
	if (J <= -6.5e-104) {
		tmp = t_0;
	} else if (J <= -2e-310) {
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	} else if (J <= 2.6e-97) {
		tmp = -2.0 * (U * 0.5);
	} else {
		tmp = t_0;
	}
	return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
	double t_0 = -2.0 * (J * (Math.cos((K / 2.0)) * Math.hypot(1.0, (U * (0.5 / J)))));
	double tmp;
	if (J <= -6.5e-104) {
		tmp = t_0;
	} else if (J <= -2e-310) {
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	} else if (J <= 2.6e-97) {
		tmp = -2.0 * (U * 0.5);
	} else {
		tmp = t_0;
	}
	return tmp;
}
U = abs(U)
def code(J, K, U):
	t_0 = -2.0 * (J * (math.cos((K / 2.0)) * math.hypot(1.0, (U * (0.5 / J)))))
	tmp = 0
	if J <= -6.5e-104:
		tmp = t_0
	elif J <= -2e-310:
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U))
	elif J <= 2.6e-97:
		tmp = -2.0 * (U * 0.5)
	else:
		tmp = t_0
	return tmp
U = abs(U)
function code(J, K, U)
	t_0 = Float64(-2.0 * Float64(J * Float64(cos(Float64(K / 2.0)) * hypot(1.0, Float64(U * Float64(0.5 / J))))))
	tmp = 0.0
	if (J <= -6.5e-104)
		tmp = t_0;
	elseif (J <= -2e-310)
		tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(Float64(J * J) / U)));
	elseif (J <= 2.6e-97)
		tmp = Float64(-2.0 * Float64(U * 0.5));
	else
		tmp = t_0;
	end
	return tmp
end
U = abs(U)
function tmp_2 = code(J, K, U)
	t_0 = -2.0 * (J * (cos((K / 2.0)) * hypot(1.0, (U * (0.5 / J)))));
	tmp = 0.0;
	if (J <= -6.5e-104)
		tmp = t_0;
	elseif (J <= -2e-310)
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	elseif (J <= 2.6e-97)
		tmp = -2.0 * (U * 0.5);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -6.5e-104], t$95$0, If[LessEqual[J, -2e-310], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(N[(J * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 2.6e-97], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\right)\right)\\
\mathbf{if}\;J \leq -6.5 \cdot 10^{-104}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\

\mathbf{elif}\;J \leq 2.6 \cdot 10^{-97}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if J < -6.49999999999999991e-104 or 2.60000000000000007e-97 < J

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

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

      \[\leadsto -2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, \color{blue}{0.5 \cdot \frac{U}{J}}\right)\right)\right) \]
    4. Step-by-step derivation
      1. associate-*r/85.1%

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

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

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

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

    if -6.49999999999999991e-104 < J < -1.999999999999994e-310

    1. Initial program 42.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. Simplified68.3%

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

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

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

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

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{J \cdot J}}\right)} \]
    6. Taylor expanded in U around -inf 51.6%

      \[\leadsto -2 \cdot \color{blue}{\left(-1 \cdot \frac{{J}^{2}}{U} + -0.5 \cdot U\right)} \]
    7. Step-by-step derivation
      1. +-commutative51.6%

        \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U + -1 \cdot \frac{{J}^{2}}{U}\right)} \]
      2. mul-1-neg51.6%

        \[\leadsto -2 \cdot \left(-0.5 \cdot U + \color{blue}{\left(-\frac{{J}^{2}}{U}\right)}\right) \]
      3. unsub-neg51.6%

        \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U - \frac{{J}^{2}}{U}\right)} \]
      4. *-commutative51.6%

        \[\leadsto -2 \cdot \left(\color{blue}{U \cdot -0.5} - \frac{{J}^{2}}{U}\right) \]
      5. unpow251.6%

        \[\leadsto -2 \cdot \left(U \cdot -0.5 - \frac{\color{blue}{J \cdot J}}{U}\right) \]
    8. Simplified51.6%

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

    if -1.999999999999994e-310 < J < 2.60000000000000007e-97

    1. Initial program 41.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. Simplified59.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \leq -6.5 \cdot 10^{-104}:\\ \;\;\;\;-2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\right)\right)\\ \mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\ \mathbf{elif}\;J \leq 2.6 \cdot 10^{-97}:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\right)\right)\\ \end{array} \]

Alternative 7: 61.5% accurate, 3.5× speedup?

\[\begin{array}{l} U = |U|\\ \\ \begin{array}{l} \mathbf{if}\;\frac{K}{2} \leq 5 \cdot 10^{+27}:\\ \;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{U \cdot 0.5}{J}\right)\right)\\ \mathbf{elif}\;\frac{K}{2} \leq 5 \cdot 10^{+222} \lor \neg \left(\frac{K}{2} \leq 5 \cdot 10^{+241}\right):\\ \;\;\;\;-2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\ \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (if (<= (/ K 2.0) 5e+27)
   (* -2.0 (* J (hypot 1.0 (/ (* U 0.5) J))))
   (if (or (<= (/ K 2.0) 5e+222) (not (<= (/ K 2.0) 5e+241)))
     (* -2.0 (* J (cos (/ K 2.0))))
     (* -2.0 (- (* U -0.5) (/ (* J J) U))))))
U = abs(U);
double code(double J, double K, double U) {
	double tmp;
	if ((K / 2.0) <= 5e+27) {
		tmp = -2.0 * (J * hypot(1.0, ((U * 0.5) / J)));
	} else if (((K / 2.0) <= 5e+222) || !((K / 2.0) <= 5e+241)) {
		tmp = -2.0 * (J * cos((K / 2.0)));
	} else {
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	}
	return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
	double tmp;
	if ((K / 2.0) <= 5e+27) {
		tmp = -2.0 * (J * Math.hypot(1.0, ((U * 0.5) / J)));
	} else if (((K / 2.0) <= 5e+222) || !((K / 2.0) <= 5e+241)) {
		tmp = -2.0 * (J * Math.cos((K / 2.0)));
	} else {
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	}
	return tmp;
}
U = abs(U)
def code(J, K, U):
	tmp = 0
	if (K / 2.0) <= 5e+27:
		tmp = -2.0 * (J * math.hypot(1.0, ((U * 0.5) / J)))
	elif ((K / 2.0) <= 5e+222) or not ((K / 2.0) <= 5e+241):
		tmp = -2.0 * (J * math.cos((K / 2.0)))
	else:
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U))
	return tmp
U = abs(U)
function code(J, K, U)
	tmp = 0.0
	if (Float64(K / 2.0) <= 5e+27)
		tmp = Float64(-2.0 * Float64(J * hypot(1.0, Float64(Float64(U * 0.5) / J))));
	elseif ((Float64(K / 2.0) <= 5e+222) || !(Float64(K / 2.0) <= 5e+241))
		tmp = Float64(-2.0 * Float64(J * cos(Float64(K / 2.0))));
	else
		tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(Float64(J * J) / U)));
	end
	return tmp
end
U = abs(U)
function tmp_2 = code(J, K, U)
	tmp = 0.0;
	if ((K / 2.0) <= 5e+27)
		tmp = -2.0 * (J * hypot(1.0, ((U * 0.5) / J)));
	elseif (((K / 2.0) <= 5e+222) || ~(((K / 2.0) <= 5e+241)))
		tmp = -2.0 * (J * cos((K / 2.0)));
	else
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	end
	tmp_2 = tmp;
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 5e+27], N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(K / 2.0), $MachinePrecision], 5e+222], N[Not[LessEqual[N[(K / 2.0), $MachinePrecision], 5e+241]], $MachinePrecision]], N[(-2.0 * N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(N[(J * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 5 \cdot 10^{+27}:\\
\;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{U \cdot 0.5}{J}\right)\right)\\

\mathbf{elif}\;\frac{K}{2} \leq 5 \cdot 10^{+222} \lor \neg \left(\frac{K}{2} \leq 5 \cdot 10^{+241}\right):\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\


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

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

      \[\leadsto \color{blue}{-2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}\right)\right)\right)} \]
    3. Step-by-step derivation
      1. add-cube-cbrt85.8%

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

        \[\leadsto -2 \cdot \left(J \cdot \color{blue}{{\left(\sqrt[3]{\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}\right)}\right)}^{3}}\right) \]
    4. Applied egg-rr85.9%

      \[\leadsto -2 \cdot \left(J \cdot \color{blue}{{\left(\sqrt[3]{\cos \left(K \cdot 0.5\right) \cdot \mathsf{hypot}\left(1, \frac{0.5 \cdot \frac{U}{J}}{\cos \left(K \cdot 0.5\right)}\right)}\right)}^{3}}\right) \]
    5. Taylor expanded in K around 0 40.5%

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{{U}^{2}}{{J}^{2}}}\right)} \]
    6. Step-by-step derivation
      1. metadata-eval40.5%

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

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

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

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

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

        \[\leadsto -2 \cdot \left(J \cdot \sqrt{1 + \color{blue}{{\left(0.5 \cdot \frac{U}{J}\right)}^{2}}}\right) \]
      7. associate-*r/52.4%

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

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

        \[\leadsto -2 \cdot \left(J \cdot \sqrt{1 + {\left(\frac{\color{blue}{0.5 \cdot U}}{J}\right)}^{2}}\right) \]
      10. associate-*r/52.4%

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

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

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

        \[\leadsto -2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \color{blue}{\frac{0.5 \cdot U}{J}}\right)\right) \]
      14. *-commutative64.7%

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

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

    if 4.99999999999999979e27 < (/.f64 K 2) < 5.00000000000000023e222 or 5.00000000000000025e241 < (/.f64 K 2)

    1. Initial program 67.2%

      \[\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. associate-*l*67.2%

        \[\leadsto \color{blue}{\left(-2 \cdot \left(J \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}} \]
      2. associate-*l*67.2%

        \[\leadsto \color{blue}{-2 \cdot \left(\left(J \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}}\right)} \]
      3. *-commutative67.2%

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

        \[\leadsto -2 \cdot \left(\left(\cos \left(\frac{K}{2}\right) \cdot J\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)}}}\right) \]
      5. sqr-neg67.2%

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

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

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

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

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

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

    if 5.00000000000000023e222 < (/.f64 K 2) < 5.00000000000000025e241

    1. Initial program 6.3%

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

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

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

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

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

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{J \cdot J}}\right)} \]
    6. Taylor expanded in U around -inf 50.0%

      \[\leadsto -2 \cdot \color{blue}{\left(-1 \cdot \frac{{J}^{2}}{U} + -0.5 \cdot U\right)} \]
    7. Step-by-step derivation
      1. +-commutative50.0%

        \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U + -1 \cdot \frac{{J}^{2}}{U}\right)} \]
      2. mul-1-neg50.0%

        \[\leadsto -2 \cdot \left(-0.5 \cdot U + \color{blue}{\left(-\frac{{J}^{2}}{U}\right)}\right) \]
      3. unsub-neg50.0%

        \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U - \frac{{J}^{2}}{U}\right)} \]
      4. *-commutative50.0%

        \[\leadsto -2 \cdot \left(\color{blue}{U \cdot -0.5} - \frac{{J}^{2}}{U}\right) \]
      5. unpow250.0%

        \[\leadsto -2 \cdot \left(U \cdot -0.5 - \frac{\color{blue}{J \cdot J}}{U}\right) \]
    8. Simplified50.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{K}{2} \leq 5 \cdot 10^{+27}:\\ \;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{U \cdot 0.5}{J}\right)\right)\\ \mathbf{elif}\;\frac{K}{2} \leq 5 \cdot 10^{+222} \lor \neg \left(\frac{K}{2} \leq 5 \cdot 10^{+241}\right):\\ \;\;\;\;-2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\ \end{array} \]

Alternative 8: 67.0% accurate, 3.7× speedup?

\[\begin{array}{l} U = |U|\\ \\ \begin{array}{l} t_0 := -2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\ \mathbf{if}\;J \leq -4.4 \cdot 10^{+42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\ \mathbf{elif}\;J \leq 2.25 \cdot 10^{-38}:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (* -2.0 (* J (cos (/ K 2.0))))))
   (if (<= J -4.4e+42)
     t_0
     (if (<= J -2e-310)
       (* -2.0 (- (* U -0.5) (/ (* J J) U)))
       (if (<= J 2.25e-38) (* -2.0 (* U 0.5)) t_0)))))
U = abs(U);
double code(double J, double K, double U) {
	double t_0 = -2.0 * (J * cos((K / 2.0)));
	double tmp;
	if (J <= -4.4e+42) {
		tmp = t_0;
	} else if (J <= -2e-310) {
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	} else if (J <= 2.25e-38) {
		tmp = -2.0 * (U * 0.5);
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: U should be positive before calling this function
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
    real(8) :: tmp
    t_0 = (-2.0d0) * (j * cos((k / 2.0d0)))
    if (j <= (-4.4d+42)) then
        tmp = t_0
    else if (j <= (-2d-310)) then
        tmp = (-2.0d0) * ((u * (-0.5d0)) - ((j * j) / u))
    else if (j <= 2.25d-38) then
        tmp = (-2.0d0) * (u * 0.5d0)
    else
        tmp = t_0
    end if
    code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
	double t_0 = -2.0 * (J * Math.cos((K / 2.0)));
	double tmp;
	if (J <= -4.4e+42) {
		tmp = t_0;
	} else if (J <= -2e-310) {
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	} else if (J <= 2.25e-38) {
		tmp = -2.0 * (U * 0.5);
	} else {
		tmp = t_0;
	}
	return tmp;
}
U = abs(U)
def code(J, K, U):
	t_0 = -2.0 * (J * math.cos((K / 2.0)))
	tmp = 0
	if J <= -4.4e+42:
		tmp = t_0
	elif J <= -2e-310:
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U))
	elif J <= 2.25e-38:
		tmp = -2.0 * (U * 0.5)
	else:
		tmp = t_0
	return tmp
U = abs(U)
function code(J, K, U)
	t_0 = Float64(-2.0 * Float64(J * cos(Float64(K / 2.0))))
	tmp = 0.0
	if (J <= -4.4e+42)
		tmp = t_0;
	elseif (J <= -2e-310)
		tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(Float64(J * J) / U)));
	elseif (J <= 2.25e-38)
		tmp = Float64(-2.0 * Float64(U * 0.5));
	else
		tmp = t_0;
	end
	return tmp
end
U = abs(U)
function tmp_2 = code(J, K, U)
	t_0 = -2.0 * (J * cos((K / 2.0)));
	tmp = 0.0;
	if (J <= -4.4e+42)
		tmp = t_0;
	elseif (J <= -2e-310)
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	elseif (J <= 2.25e-38)
		tmp = -2.0 * (U * 0.5);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -4.4e+42], t$95$0, If[LessEqual[J, -2e-310], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(N[(J * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 2.25e-38], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\
\mathbf{if}\;J \leq -4.4 \cdot 10^{+42}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\

\mathbf{elif}\;J \leq 2.25 \cdot 10^{-38}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if J < -4.4000000000000003e42 or 2.25000000000000004e-38 < J

    1. Initial program 94.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. Step-by-step derivation
      1. associate-*l*94.5%

        \[\leadsto \color{blue}{\left(-2 \cdot \left(J \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}} \]
      2. associate-*l*94.5%

        \[\leadsto \color{blue}{-2 \cdot \left(\left(J \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}}\right)} \]
      3. *-commutative94.5%

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

        \[\leadsto -2 \cdot \left(\left(\cos \left(\frac{K}{2}\right) \cdot J\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)}}}\right) \]
      5. sqr-neg94.5%

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

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

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

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

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

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

    if -4.4000000000000003e42 < J < -1.999999999999994e-310

    1. Initial program 54.2%

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

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

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{{U}^{2}}{{J}^{2}}}\right)} \]
    4. Step-by-step derivation
      1. unpow226.0%

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

        \[\leadsto -2 \cdot \left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{\color{blue}{J \cdot J}}}\right) \]
    5. Simplified26.0%

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{J \cdot J}}\right)} \]
    6. Taylor expanded in U around -inf 44.0%

      \[\leadsto -2 \cdot \color{blue}{\left(-1 \cdot \frac{{J}^{2}}{U} + -0.5 \cdot U\right)} \]
    7. Step-by-step derivation
      1. +-commutative44.0%

        \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U + -1 \cdot \frac{{J}^{2}}{U}\right)} \]
      2. mul-1-neg44.0%

        \[\leadsto -2 \cdot \left(-0.5 \cdot U + \color{blue}{\left(-\frac{{J}^{2}}{U}\right)}\right) \]
      3. unsub-neg44.0%

        \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U - \frac{{J}^{2}}{U}\right)} \]
      4. *-commutative44.0%

        \[\leadsto -2 \cdot \left(\color{blue}{U \cdot -0.5} - \frac{{J}^{2}}{U}\right) \]
      5. unpow244.0%

        \[\leadsto -2 \cdot \left(U \cdot -0.5 - \frac{\color{blue}{J \cdot J}}{U}\right) \]
    8. Simplified44.0%

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

    if -1.999999999999994e-310 < J < 2.25000000000000004e-38

    1. Initial program 47.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. Simplified64.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \leq -4.4 \cdot 10^{+42}:\\ \;\;\;\;-2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\ \mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\ \mathbf{elif}\;J \leq 2.25 \cdot 10^{-38}:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\ \end{array} \]

Alternative 9: 50.0% accurate, 27.8× speedup?

\[\begin{array}{l} U = |U|\\ \\ \begin{array}{l} \mathbf{if}\;J \leq -7 \cdot 10^{+41}:\\ \;\;\;\;-2 \cdot J\\ \mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\ \mathbf{elif}\;J \leq 1.4 \cdot 10^{-37}:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot J\\ \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (if (<= J -7e+41)
   (* -2.0 J)
   (if (<= J -2e-310)
     (* -2.0 (- (* U -0.5) (/ (* J J) U)))
     (if (<= J 1.4e-37) (* -2.0 (* U 0.5)) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
	double tmp;
	if (J <= -7e+41) {
		tmp = -2.0 * J;
	} else if (J <= -2e-310) {
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	} else if (J <= 1.4e-37) {
		tmp = -2.0 * (U * 0.5);
	} else {
		tmp = -2.0 * J;
	}
	return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (j <= (-7d+41)) then
        tmp = (-2.0d0) * j
    else if (j <= (-2d-310)) then
        tmp = (-2.0d0) * ((u * (-0.5d0)) - ((j * j) / u))
    else if (j <= 1.4d-37) then
        tmp = (-2.0d0) * (u * 0.5d0)
    else
        tmp = (-2.0d0) * j
    end if
    code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
	double tmp;
	if (J <= -7e+41) {
		tmp = -2.0 * J;
	} else if (J <= -2e-310) {
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	} else if (J <= 1.4e-37) {
		tmp = -2.0 * (U * 0.5);
	} else {
		tmp = -2.0 * J;
	}
	return tmp;
}
U = abs(U)
def code(J, K, U):
	tmp = 0
	if J <= -7e+41:
		tmp = -2.0 * J
	elif J <= -2e-310:
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U))
	elif J <= 1.4e-37:
		tmp = -2.0 * (U * 0.5)
	else:
		tmp = -2.0 * J
	return tmp
U = abs(U)
function code(J, K, U)
	tmp = 0.0
	if (J <= -7e+41)
		tmp = Float64(-2.0 * J);
	elseif (J <= -2e-310)
		tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(Float64(J * J) / U)));
	elseif (J <= 1.4e-37)
		tmp = Float64(-2.0 * Float64(U * 0.5));
	else
		tmp = Float64(-2.0 * J);
	end
	return tmp
end
U = abs(U)
function tmp_2 = code(J, K, U)
	tmp = 0.0;
	if (J <= -7e+41)
		tmp = -2.0 * J;
	elseif (J <= -2e-310)
		tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
	elseif (J <= 1.4e-37)
		tmp = -2.0 * (U * 0.5);
	else
		tmp = -2.0 * J;
	end
	tmp_2 = tmp;
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := If[LessEqual[J, -7e+41], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -2e-310], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(N[(J * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.4e-37], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -7 \cdot 10^{+41}:\\
\;\;\;\;-2 \cdot J\\

\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\

\mathbf{elif}\;J \leq 1.4 \cdot 10^{-37}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if J < -6.9999999999999998e41 or 1.4000000000000001e-37 < J

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

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

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{{U}^{2}}{{J}^{2}}}\right)} \]
    4. Step-by-step derivation
      1. unpow247.6%

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

        \[\leadsto -2 \cdot \left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{\color{blue}{J \cdot J}}}\right) \]
    5. Simplified47.6%

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{J \cdot J}}\right)} \]
    6. Taylor expanded in J around inf 47.0%

      \[\leadsto -2 \cdot \color{blue}{J} \]

    if -6.9999999999999998e41 < J < -1.999999999999994e-310

    1. Initial program 54.2%

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

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

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{{U}^{2}}{{J}^{2}}}\right)} \]
    4. Step-by-step derivation
      1. unpow226.0%

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

        \[\leadsto -2 \cdot \left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{\color{blue}{J \cdot J}}}\right) \]
    5. Simplified26.0%

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{J \cdot J}}\right)} \]
    6. Taylor expanded in U around -inf 44.0%

      \[\leadsto -2 \cdot \color{blue}{\left(-1 \cdot \frac{{J}^{2}}{U} + -0.5 \cdot U\right)} \]
    7. Step-by-step derivation
      1. +-commutative44.0%

        \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U + -1 \cdot \frac{{J}^{2}}{U}\right)} \]
      2. mul-1-neg44.0%

        \[\leadsto -2 \cdot \left(-0.5 \cdot U + \color{blue}{\left(-\frac{{J}^{2}}{U}\right)}\right) \]
      3. unsub-neg44.0%

        \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U - \frac{{J}^{2}}{U}\right)} \]
      4. *-commutative44.0%

        \[\leadsto -2 \cdot \left(\color{blue}{U \cdot -0.5} - \frac{{J}^{2}}{U}\right) \]
      5. unpow244.0%

        \[\leadsto -2 \cdot \left(U \cdot -0.5 - \frac{\color{blue}{J \cdot J}}{U}\right) \]
    8. Simplified44.0%

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

    if -1.999999999999994e-310 < J < 1.4000000000000001e-37

    1. Initial program 47.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. Simplified64.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \leq -7 \cdot 10^{+41}:\\ \;\;\;\;-2 \cdot J\\ \mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\ \mathbf{elif}\;J \leq 1.4 \cdot 10^{-37}:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot J\\ \end{array} \]

Alternative 10: 48.3% accurate, 37.5× speedup?

\[\begin{array}{l} U = |U|\\ \\ \begin{array}{l} \mathbf{if}\;J \leq -9.2 \cdot 10^{+184}:\\ \;\;\;\;-2 \cdot J\\ \mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\ \mathbf{elif}\;J \leq 1.45 \cdot 10^{-37}:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot J\\ \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (if (<= J -9.2e+184)
   (* -2.0 J)
   (if (<= J -2e-310)
     (* -2.0 (* U -0.5))
     (if (<= J 1.45e-37) (* -2.0 (* U 0.5)) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
	double tmp;
	if (J <= -9.2e+184) {
		tmp = -2.0 * J;
	} else if (J <= -2e-310) {
		tmp = -2.0 * (U * -0.5);
	} else if (J <= 1.45e-37) {
		tmp = -2.0 * (U * 0.5);
	} else {
		tmp = -2.0 * J;
	}
	return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (j <= (-9.2d+184)) then
        tmp = (-2.0d0) * j
    else if (j <= (-2d-310)) then
        tmp = (-2.0d0) * (u * (-0.5d0))
    else if (j <= 1.45d-37) then
        tmp = (-2.0d0) * (u * 0.5d0)
    else
        tmp = (-2.0d0) * j
    end if
    code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
	double tmp;
	if (J <= -9.2e+184) {
		tmp = -2.0 * J;
	} else if (J <= -2e-310) {
		tmp = -2.0 * (U * -0.5);
	} else if (J <= 1.45e-37) {
		tmp = -2.0 * (U * 0.5);
	} else {
		tmp = -2.0 * J;
	}
	return tmp;
}
U = abs(U)
def code(J, K, U):
	tmp = 0
	if J <= -9.2e+184:
		tmp = -2.0 * J
	elif J <= -2e-310:
		tmp = -2.0 * (U * -0.5)
	elif J <= 1.45e-37:
		tmp = -2.0 * (U * 0.5)
	else:
		tmp = -2.0 * J
	return tmp
U = abs(U)
function code(J, K, U)
	tmp = 0.0
	if (J <= -9.2e+184)
		tmp = Float64(-2.0 * J);
	elseif (J <= -2e-310)
		tmp = Float64(-2.0 * Float64(U * -0.5));
	elseif (J <= 1.45e-37)
		tmp = Float64(-2.0 * Float64(U * 0.5));
	else
		tmp = Float64(-2.0 * J);
	end
	return tmp
end
U = abs(U)
function tmp_2 = code(J, K, U)
	tmp = 0.0;
	if (J <= -9.2e+184)
		tmp = -2.0 * J;
	elseif (J <= -2e-310)
		tmp = -2.0 * (U * -0.5);
	elseif (J <= 1.45e-37)
		tmp = -2.0 * (U * 0.5);
	else
		tmp = -2.0 * J;
	end
	tmp_2 = tmp;
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := If[LessEqual[J, -9.2e+184], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -2e-310], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.45e-37], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -9.2 \cdot 10^{+184}:\\
\;\;\;\;-2 \cdot J\\

\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\

\mathbf{elif}\;J \leq 1.45 \cdot 10^{-37}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if J < -9.1999999999999999e184 or 1.45000000000000002e-37 < J

    1. Initial program 96.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. Simplified99.8%

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

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

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

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

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{J \cdot J}}\right)} \]
    6. Taylor expanded in J around inf 50.5%

      \[\leadsto -2 \cdot \color{blue}{J} \]

    if -9.1999999999999999e184 < J < -1.999999999999994e-310

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

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

      \[\leadsto -2 \cdot \color{blue}{\left(-0.5 \cdot U\right)} \]
    4. Step-by-step derivation
      1. *-commutative39.4%

        \[\leadsto -2 \cdot \color{blue}{\left(U \cdot -0.5\right)} \]
    5. Simplified39.4%

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

    if -1.999999999999994e-310 < J < 1.45000000000000002e-37

    1. Initial program 47.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. Simplified64.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \leq -9.2 \cdot 10^{+184}:\\ \;\;\;\;-2 \cdot J\\ \mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\ \mathbf{elif}\;J \leq 1.45 \cdot 10^{-37}:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot J\\ \end{array} \]

Alternative 11: 40.4% accurate, 59.5× speedup?

\[\begin{array}{l} U = |U|\\ \\ \begin{array}{l} \mathbf{if}\;U \leq 1.6 \cdot 10^{+25}:\\ \;\;\;\;-2 \cdot J\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \end{array} \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U)
 :precision binary64
 (if (<= U 1.6e+25) (* -2.0 J) (* -2.0 (* U 0.5))))
U = abs(U);
double code(double J, double K, double U) {
	double tmp;
	if (U <= 1.6e+25) {
		tmp = -2.0 * J;
	} else {
		tmp = -2.0 * (U * 0.5);
	}
	return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (u <= 1.6d+25) then
        tmp = (-2.0d0) * j
    else
        tmp = (-2.0d0) * (u * 0.5d0)
    end if
    code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
	double tmp;
	if (U <= 1.6e+25) {
		tmp = -2.0 * J;
	} else {
		tmp = -2.0 * (U * 0.5);
	}
	return tmp;
}
U = abs(U)
def code(J, K, U):
	tmp = 0
	if U <= 1.6e+25:
		tmp = -2.0 * J
	else:
		tmp = -2.0 * (U * 0.5)
	return tmp
U = abs(U)
function code(J, K, U)
	tmp = 0.0
	if (U <= 1.6e+25)
		tmp = Float64(-2.0 * J);
	else
		tmp = Float64(-2.0 * Float64(U * 0.5));
	end
	return tmp
end
U = abs(U)
function tmp_2 = code(J, K, U)
	tmp = 0.0;
	if (U <= 1.6e+25)
		tmp = -2.0 * J;
	else
		tmp = -2.0 * (U * 0.5);
	end
	tmp_2 = tmp;
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := If[LessEqual[U, 1.6e+25], N[(-2.0 * J), $MachinePrecision], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 1.6 \cdot 10^{+25}:\\
\;\;\;\;-2 \cdot J\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\


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

    1. Initial program 76.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. Simplified90.2%

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

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

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

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

      \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{J \cdot J}}\right)} \]
    6. Taylor expanded in J around inf 33.6%

      \[\leadsto -2 \cdot \color{blue}{J} \]

    if 1.6e25 < U

    1. Initial program 49.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. Simplified69.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq 1.6 \cdot 10^{+25}:\\ \;\;\;\;-2 \cdot J\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\ \end{array} \]

Alternative 12: 29.0% accurate, 140.0× speedup?

\[\begin{array}{l} U = |U|\\ \\ -2 \cdot J \end{array} \]
NOTE: U should be positive before calling this function
(FPCore (J K U) :precision binary64 (* -2.0 J))
U = abs(U);
double code(double J, double K, double U) {
	return -2.0 * J;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = (-2.0d0) * j
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
	return -2.0 * J;
}
U = abs(U)
def code(J, K, U):
	return -2.0 * J
U = abs(U)
function code(J, K, U)
	return Float64(-2.0 * J)
end
U = abs(U)
function tmp = code(J, K, U)
	tmp = -2.0 * J;
end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := N[(-2.0 * J), $MachinePrecision]
\begin{array}{l}
U = |U|\\
\\
-2 \cdot J
\end{array}
Derivation
  1. Initial program 71.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. Simplified86.3%

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

    \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{{U}^{2}}{{J}^{2}}}\right)} \]
  4. Step-by-step derivation
    1. unpow235.0%

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

      \[\leadsto -2 \cdot \left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{\color{blue}{J \cdot J}}}\right) \]
  5. Simplified35.0%

    \[\leadsto -2 \cdot \color{blue}{\left(J \cdot \sqrt{1 + 0.25 \cdot \frac{U \cdot U}{J \cdot J}}\right)} \]
  6. Taylor expanded in J around inf 28.8%

    \[\leadsto -2 \cdot \color{blue}{J} \]
  7. Final simplification28.8%

    \[\leadsto -2 \cdot J \]

Reproduce

?
herbie shell --seed 2023272 
(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)))))