Maksimov and Kolovsky, Equation (3)

Percentage Accurate: 73.1% → 87.9%
Time: 21.5s
Alternatives: 7
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 7 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.1% 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: 87.9% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(J \cdot \left(-2 \cdot t_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 72.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. *-commutative72.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*72.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. unpow272.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-def89.3%

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

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

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

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

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

Alternative 2: 87.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ J \cdot \left(t_0 \cdot \left(-2 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right) \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (* J (* t_0 (* -2.0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
double code(double J, double K, double U) {
	double t_0 = cos((K / 2.0));
	return J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
public static double code(double J, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	return J * (t_0 * (-2.0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
def code(J, K, U):
	t_0 = math.cos((K / 2.0))
	return J * (t_0 * (-2.0 * math.hypot(1.0, (U / (J * (2.0 * t_0))))))
function code(J, K, U)
	t_0 = cos(Float64(K / 2.0))
	return Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0)))))))
end
function tmp = code(J, K, U)
	t_0 = cos((K / 2.0));
	tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(J * N[(t$95$0 * N[(-2.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}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
J \cdot \left(t_0 \cdot \left(-2 \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 72.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. *-commutative72.7%

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

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

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

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

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

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

      \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
    8. hypot-1-def89.2%

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

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

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

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

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

Alternative 3: 73.1% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;U \leq -9 \cdot 10^{+200}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 4.9 \cdot 10^{+202}:\\ \;\;\;\;\left(-2 \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J}\right)\right)\\ \mathbf{elif}\;U \leq 1.42 \cdot 10^{+274}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (if (<= U -9e+200)
   (- U)
   (if (<= U 4.9e+202)
     (* (* -2.0 (cos (* K 0.5))) (* J (hypot 1.0 (/ (/ U 2.0) J))))
     (if (<= U 1.42e+274) U (- U)))))
double code(double J, double K, double U) {
	double tmp;
	if (U <= -9e+200) {
		tmp = -U;
	} else if (U <= 4.9e+202) {
		tmp = (-2.0 * cos((K * 0.5))) * (J * hypot(1.0, ((U / 2.0) / J)));
	} else if (U <= 1.42e+274) {
		tmp = U;
	} else {
		tmp = -U;
	}
	return tmp;
}
public static double code(double J, double K, double U) {
	double tmp;
	if (U <= -9e+200) {
		tmp = -U;
	} else if (U <= 4.9e+202) {
		tmp = (-2.0 * Math.cos((K * 0.5))) * (J * Math.hypot(1.0, ((U / 2.0) / J)));
	} else if (U <= 1.42e+274) {
		tmp = U;
	} else {
		tmp = -U;
	}
	return tmp;
}
def code(J, K, U):
	tmp = 0
	if U <= -9e+200:
		tmp = -U
	elif U <= 4.9e+202:
		tmp = (-2.0 * math.cos((K * 0.5))) * (J * math.hypot(1.0, ((U / 2.0) / J)))
	elif U <= 1.42e+274:
		tmp = U
	else:
		tmp = -U
	return tmp
function code(J, K, U)
	tmp = 0.0
	if (U <= -9e+200)
		tmp = Float64(-U);
	elseif (U <= 4.9e+202)
		tmp = Float64(Float64(-2.0 * cos(Float64(K * 0.5))) * Float64(J * hypot(1.0, Float64(Float64(U / 2.0) / J))));
	elseif (U <= 1.42e+274)
		tmp = U;
	else
		tmp = Float64(-U);
	end
	return tmp
end
function tmp_2 = code(J, K, U)
	tmp = 0.0;
	if (U <= -9e+200)
		tmp = -U;
	elseif (U <= 4.9e+202)
		tmp = (-2.0 * cos((K * 0.5))) * (J * hypot(1.0, ((U / 2.0) / J)));
	elseif (U <= 1.42e+274)
		tmp = U;
	else
		tmp = -U;
	end
	tmp_2 = tmp;
end
code[J_, K_, U_] := If[LessEqual[U, -9e+200], (-U), If[LessEqual[U, 4.9e+202], N[(N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U / 2.0), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 1.42e+274], U, (-U)]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;U \leq -9 \cdot 10^{+200}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq 4.9 \cdot 10^{+202}:\\
\;\;\;\;\left(-2 \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J}\right)\right)\\

\mathbf{elif}\;U \leq 1.42 \cdot 10^{+274}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if U < -8.99999999999999939e200 or 1.42e274 < U

    1. Initial program 44.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. *-commutative44.2%

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

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
      8. hypot-1-def64.1%

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

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

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

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

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

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

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

    if -8.99999999999999939e200 < U < 4.9e202

    1. Initial program 80.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. *-commutative80.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*80.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. unpow280.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-def96.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{2 \cdot J}\right)\right)} - 1} \]
      3. *-commutative25.9%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{hypot}\left(1, \frac{U}{2 \cdot J}\right) \cdot \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right)}\right)} - 1 \]
      4. *-commutative25.9%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \frac{U}{\color{blue}{J \cdot 2}}\right) \cdot \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right)\right)} - 1 \]
      5. div-inv25.9%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right) \cdot \left(J \cdot \left(-2 \cdot \cos \color{blue}{\left(K \cdot \frac{1}{2}\right)}\right)\right)\right)} - 1 \]
      6. metadata-eval25.9%

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right) \cdot \left(J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def50.9%

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

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

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

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

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

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

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

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

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

    if 4.9e202 < U < 1.42e274

    1. Initial program 41.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. *-commutative41.0%

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

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
      8. hypot-1-def65.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq -9 \cdot 10^{+200}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 4.9 \cdot 10^{+202}:\\ \;\;\;\;\left(-2 \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{2}}{J}\right)\right)\\ \mathbf{elif}\;U \leq 1.42 \cdot 10^{+274}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]

Alternative 4: 56.4% accurate, 3.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{if}\;U \leq -4 \cdot 10^{+182}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -1.16 \cdot 10^{+58}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;U \leq -1.25 \cdot 10^{+36}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -4.9 \cdot 10^{+23}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 4.8 \cdot 10^{-51}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;U \leq 8.2 \cdot 10^{-23}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 1.7 \cdot 10^{+119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;U \leq 9 \cdot 10^{+273}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
   (if (<= U -4e+182)
     (- U)
     (if (<= U -1.16e+58)
       t_0
       (if (<= U -1.25e+36)
         (- U)
         (if (<= U -4.9e+23)
           U
           (if (<= U 4.8e-51)
             t_0
             (if (<= U 8.2e-23)
               U
               (if (<= U 1.7e+119) t_0 (if (<= U 9e+273) U (- U)))))))))))
double code(double J, double K, double U) {
	double t_0 = J * (-2.0 * cos((K * 0.5)));
	double tmp;
	if (U <= -4e+182) {
		tmp = -U;
	} else if (U <= -1.16e+58) {
		tmp = t_0;
	} else if (U <= -1.25e+36) {
		tmp = -U;
	} else if (U <= -4.9e+23) {
		tmp = U;
	} else if (U <= 4.8e-51) {
		tmp = t_0;
	} else if (U <= 8.2e-23) {
		tmp = U;
	} else if (U <= 1.7e+119) {
		tmp = t_0;
	} else if (U <= 9e+273) {
		tmp = U;
	} else {
		tmp = -U;
	}
	return tmp;
}
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 = j * ((-2.0d0) * cos((k * 0.5d0)))
    if (u <= (-4d+182)) then
        tmp = -u
    else if (u <= (-1.16d+58)) then
        tmp = t_0
    else if (u <= (-1.25d+36)) then
        tmp = -u
    else if (u <= (-4.9d+23)) then
        tmp = u
    else if (u <= 4.8d-51) then
        tmp = t_0
    else if (u <= 8.2d-23) then
        tmp = u
    else if (u <= 1.7d+119) then
        tmp = t_0
    else if (u <= 9d+273) then
        tmp = u
    else
        tmp = -u
    end if
    code = tmp
end function
public static double code(double J, double K, double U) {
	double t_0 = J * (-2.0 * Math.cos((K * 0.5)));
	double tmp;
	if (U <= -4e+182) {
		tmp = -U;
	} else if (U <= -1.16e+58) {
		tmp = t_0;
	} else if (U <= -1.25e+36) {
		tmp = -U;
	} else if (U <= -4.9e+23) {
		tmp = U;
	} else if (U <= 4.8e-51) {
		tmp = t_0;
	} else if (U <= 8.2e-23) {
		tmp = U;
	} else if (U <= 1.7e+119) {
		tmp = t_0;
	} else if (U <= 9e+273) {
		tmp = U;
	} else {
		tmp = -U;
	}
	return tmp;
}
def code(J, K, U):
	t_0 = J * (-2.0 * math.cos((K * 0.5)))
	tmp = 0
	if U <= -4e+182:
		tmp = -U
	elif U <= -1.16e+58:
		tmp = t_0
	elif U <= -1.25e+36:
		tmp = -U
	elif U <= -4.9e+23:
		tmp = U
	elif U <= 4.8e-51:
		tmp = t_0
	elif U <= 8.2e-23:
		tmp = U
	elif U <= 1.7e+119:
		tmp = t_0
	elif U <= 9e+273:
		tmp = U
	else:
		tmp = -U
	return tmp
function code(J, K, U)
	t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5))))
	tmp = 0.0
	if (U <= -4e+182)
		tmp = Float64(-U);
	elseif (U <= -1.16e+58)
		tmp = t_0;
	elseif (U <= -1.25e+36)
		tmp = Float64(-U);
	elseif (U <= -4.9e+23)
		tmp = U;
	elseif (U <= 4.8e-51)
		tmp = t_0;
	elseif (U <= 8.2e-23)
		tmp = U;
	elseif (U <= 1.7e+119)
		tmp = t_0;
	elseif (U <= 9e+273)
		tmp = U;
	else
		tmp = Float64(-U);
	end
	return tmp
end
function tmp_2 = code(J, K, U)
	t_0 = J * (-2.0 * cos((K * 0.5)));
	tmp = 0.0;
	if (U <= -4e+182)
		tmp = -U;
	elseif (U <= -1.16e+58)
		tmp = t_0;
	elseif (U <= -1.25e+36)
		tmp = -U;
	elseif (U <= -4.9e+23)
		tmp = U;
	elseif (U <= 4.8e-51)
		tmp = t_0;
	elseif (U <= 8.2e-23)
		tmp = U;
	elseif (U <= 1.7e+119)
		tmp = t_0;
	elseif (U <= 9e+273)
		tmp = U;
	else
		tmp = -U;
	end
	tmp_2 = tmp;
end
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U, -4e+182], (-U), If[LessEqual[U, -1.16e+58], t$95$0, If[LessEqual[U, -1.25e+36], (-U), If[LessEqual[U, -4.9e+23], U, If[LessEqual[U, 4.8e-51], t$95$0, If[LessEqual[U, 8.2e-23], U, If[LessEqual[U, 1.7e+119], t$95$0, If[LessEqual[U, 9e+273], U, (-U)]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;U \leq -4 \cdot 10^{+182}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq -1.16 \cdot 10^{+58}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;U \leq -1.25 \cdot 10^{+36}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq -4.9 \cdot 10^{+23}:\\
\;\;\;\;U\\

\mathbf{elif}\;U \leq 4.8 \cdot 10^{-51}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;U \leq 8.2 \cdot 10^{-23}:\\
\;\;\;\;U\\

\mathbf{elif}\;U \leq 1.7 \cdot 10^{+119}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;U \leq 9 \cdot 10^{+273}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if U < -4.0000000000000003e182 or -1.1600000000000001e58 < U < -1.24999999999999994e36 or 8.99999999999999987e273 < U

    1. Initial program 46.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. *-commutative46.2%

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

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
      8. hypot-1-def69.0%

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

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

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

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

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

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

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

    if -4.0000000000000003e182 < U < -1.1600000000000001e58 or -4.9000000000000003e23 < U < 4.8e-51 or 8.20000000000000059e-23 < U < 1.70000000000000007e119

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

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

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
      8. hypot-1-def97.4%

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

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

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

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

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

    if -1.24999999999999994e36 < U < -4.9000000000000003e23 or 4.8e-51 < U < 8.20000000000000059e-23 or 1.70000000000000007e119 < U < 8.99999999999999987e273

    1. Initial program 50.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. *-commutative50.7%

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

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
      8. hypot-1-def83.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq -4 \cdot 10^{+182}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -1.16 \cdot 10^{+58}:\\ \;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;U \leq -1.25 \cdot 10^{+36}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -4.9 \cdot 10^{+23}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 4.8 \cdot 10^{-51}:\\ \;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;U \leq 8.2 \cdot 10^{-23}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 1.7 \cdot 10^{+119}:\\ \;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;U \leq 9 \cdot 10^{+273}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]

Alternative 5: 39.3% accurate, 51.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;U \leq -7 \cdot 10^{+36}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 2.5 \cdot 10^{-53}:\\ \;\;\;\;J \cdot -2\\ \mathbf{elif}\;U \leq 1.12 \cdot 10^{+274}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (if (<= U -7e+36)
   (- U)
   (if (<= U 2.5e-53) (* J -2.0) (if (<= U 1.12e+274) U (- U)))))
double code(double J, double K, double U) {
	double tmp;
	if (U <= -7e+36) {
		tmp = -U;
	} else if (U <= 2.5e-53) {
		tmp = J * -2.0;
	} else if (U <= 1.12e+274) {
		tmp = U;
	} else {
		tmp = -U;
	}
	return tmp;
}
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 <= (-7d+36)) then
        tmp = -u
    else if (u <= 2.5d-53) then
        tmp = j * (-2.0d0)
    else if (u <= 1.12d+274) then
        tmp = u
    else
        tmp = -u
    end if
    code = tmp
end function
public static double code(double J, double K, double U) {
	double tmp;
	if (U <= -7e+36) {
		tmp = -U;
	} else if (U <= 2.5e-53) {
		tmp = J * -2.0;
	} else if (U <= 1.12e+274) {
		tmp = U;
	} else {
		tmp = -U;
	}
	return tmp;
}
def code(J, K, U):
	tmp = 0
	if U <= -7e+36:
		tmp = -U
	elif U <= 2.5e-53:
		tmp = J * -2.0
	elif U <= 1.12e+274:
		tmp = U
	else:
		tmp = -U
	return tmp
function code(J, K, U)
	tmp = 0.0
	if (U <= -7e+36)
		tmp = Float64(-U);
	elseif (U <= 2.5e-53)
		tmp = Float64(J * -2.0);
	elseif (U <= 1.12e+274)
		tmp = U;
	else
		tmp = Float64(-U);
	end
	return tmp
end
function tmp_2 = code(J, K, U)
	tmp = 0.0;
	if (U <= -7e+36)
		tmp = -U;
	elseif (U <= 2.5e-53)
		tmp = J * -2.0;
	elseif (U <= 1.12e+274)
		tmp = U;
	else
		tmp = -U;
	end
	tmp_2 = tmp;
end
code[J_, K_, U_] := If[LessEqual[U, -7e+36], (-U), If[LessEqual[U, 2.5e-53], N[(J * -2.0), $MachinePrecision], If[LessEqual[U, 1.12e+274], U, (-U)]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;U \leq -7 \cdot 10^{+36}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq 2.5 \cdot 10^{-53}:\\
\;\;\;\;J \cdot -2\\

\mathbf{elif}\;U \leq 1.12 \cdot 10^{+274}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if U < -6.9999999999999996e36 or 1.12000000000000007e274 < U

    1. Initial program 50.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. *-commutative50.0%

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

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
      8. hypot-1-def74.9%

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

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

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

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

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

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

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

    if -6.9999999999999996e36 < U < 2.5e-53

    1. Initial program 93.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. *-commutative93.7%

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

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
      8. hypot-1-def99.8%

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

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

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

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

      \[\leadsto J \cdot \color{blue}{\left(-2 \cdot \cos \left(0.5 \cdot K\right)\right)} \]
    5. Taylor expanded in K around 0 45.0%

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

    if 2.5e-53 < U < 1.12000000000000007e274

    1. Initial program 54.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. *-commutative54.7%

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

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
      8. hypot-1-def83.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq -7 \cdot 10^{+36}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 2.5 \cdot 10^{-53}:\\ \;\;\;\;J \cdot -2\\ \mathbf{elif}\;U \leq 1.12 \cdot 10^{+274}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]

Alternative 6: 26.6% accurate, 68.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;U \leq -3.6 \cdot 10^{+113}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 1.55 \cdot 10^{+274}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (if (<= U -3.6e+113) (- U) (if (<= U 1.55e+274) U (- U))))
double code(double J, double K, double U) {
	double tmp;
	if (U <= -3.6e+113) {
		tmp = -U;
	} else if (U <= 1.55e+274) {
		tmp = U;
	} else {
		tmp = -U;
	}
	return tmp;
}
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 <= (-3.6d+113)) then
        tmp = -u
    else if (u <= 1.55d+274) then
        tmp = u
    else
        tmp = -u
    end if
    code = tmp
end function
public static double code(double J, double K, double U) {
	double tmp;
	if (U <= -3.6e+113) {
		tmp = -U;
	} else if (U <= 1.55e+274) {
		tmp = U;
	} else {
		tmp = -U;
	}
	return tmp;
}
def code(J, K, U):
	tmp = 0
	if U <= -3.6e+113:
		tmp = -U
	elif U <= 1.55e+274:
		tmp = U
	else:
		tmp = -U
	return tmp
function code(J, K, U)
	tmp = 0.0
	if (U <= -3.6e+113)
		tmp = Float64(-U);
	elseif (U <= 1.55e+274)
		tmp = U;
	else
		tmp = Float64(-U);
	end
	return tmp
end
function tmp_2 = code(J, K, U)
	tmp = 0.0;
	if (U <= -3.6e+113)
		tmp = -U;
	elseif (U <= 1.55e+274)
		tmp = U;
	else
		tmp = -U;
	end
	tmp_2 = tmp;
end
code[J_, K_, U_] := If[LessEqual[U, -3.6e+113], (-U), If[LessEqual[U, 1.55e+274], U, (-U)]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;U \leq -3.6 \cdot 10^{+113}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq 1.55 \cdot 10^{+274}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if U < -3.59999999999999992e113 or 1.55e274 < 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. Step-by-step derivation
      1. *-commutative49.4%

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

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
      8. hypot-1-def69.0%

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

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

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

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

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

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

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

    if -3.59999999999999992e113 < U < 1.55e274

    1. Initial program 78.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. Step-by-step derivation
      1. *-commutative78.4%

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

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
      8. hypot-1-def94.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq -3.6 \cdot 10^{+113}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 1.55 \cdot 10^{+274}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]

Alternative 7: 26.6% accurate, 420.0× speedup?

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

\\
U
\end{array}
Derivation
  1. Initial program 72.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. *-commutative72.7%

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

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

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

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

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

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

      \[\leadsto J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \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)\right) \]
    8. hypot-1-def89.2%

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

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

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

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

    \[\leadsto \color{blue}{U} \]
  5. Final simplification31.0%

    \[\leadsto U \]

Reproduce

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