Maksimov and Kolovsky, Equation (3)

Percentage Accurate: 73.4% → 88.1%
Time: 26.8s
Alternatives: 10
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 10 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.4% 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: 88.1% 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 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 \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*78.4%

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

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

      \[\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. *-commutative90.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}{\left(J \cdot 2\right)} \cdot \cos \left(\frac{K}{2}\right)}\right) \]
    6. associate-*l*90.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}{J \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}}\right) \]
  3. Simplified90.4%

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

    \[\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: 88.0% 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 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-def90.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. *-commutative90.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*90.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. Simplified90.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. Final simplification90.3%

    \[\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: 72.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;U \leq -9.5 \cdot 10^{+236}:\\
\;\;\;\;U + J \cdot \frac{2}{\frac{U}{J}}\\

\mathbf{elif}\;U \leq -3.2 \cdot 10^{+170}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq -4.2 \cdot 10^{+134}:\\
\;\;\;\;U\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if U < -9.4999999999999999e236

    1. Initial program 37.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. Step-by-step derivation
      1. *-commutative37.9%

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

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

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

        \[\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*37.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. *-commutative37.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. unpow237.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-def53.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. *-commutative53.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*53.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. Simplified53.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 U around -inf 29.5%

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

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

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

        \[\leadsto J \cdot \color{blue}{\left(\frac{U}{J} + 2 \cdot \frac{J}{U}\right)} \]
      3. distribute-lft-in29.5%

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

        \[\leadsto \color{blue}{\frac{J \cdot U}{J}} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      5. associate-*l/60.6%

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

        \[\leadsto \color{blue}{1} \cdot U + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      7. *-lft-identity60.6%

        \[\leadsto \color{blue}{U} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      8. associate-*r/60.6%

        \[\leadsto U + J \cdot \color{blue}{\frac{2 \cdot J}{U}} \]
      9. associate-/l*60.6%

        \[\leadsto U + J \cdot \color{blue}{\frac{2}{\frac{U}{J}}} \]
    7. Simplified60.6%

      \[\leadsto \color{blue}{U + J \cdot \frac{2}{\frac{U}{J}}} \]

    if -9.4999999999999999e236 < U < -3.19999999999999979e170 or 4.9999999999999998e274 < U

    1. Initial program 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.19999999999999979e170 < U < -4.2000000000000002e134

    1. Initial program 61.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. Step-by-step derivation
      1. *-commutative61.6%

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

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

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

        \[\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*61.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. *-commutative61.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. unpow261.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-def61.6%

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

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

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

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

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

    if -4.2000000000000002e134 < U < 4.9999999999999998e274

    1. Initial program 84.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. Step-by-step derivation
      1. *-commutative84.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq -9.5 \cdot 10^{+236}:\\ \;\;\;\;U + J \cdot \frac{2}{\frac{U}{J}}\\ \mathbf{elif}\;U \leq -3.2 \cdot 10^{+170}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -4.2 \cdot 10^{+134}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 5 \cdot 10^{+274}:\\ \;\;\;\;\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{\frac{J}{0.5}}\right)\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]

Alternative 4: 57.3% accurate, 3.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + J \cdot \frac{2}{\frac{U}{J}}\\ \mathbf{if}\;U \leq -1.2 \cdot 10^{+237}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;U \leq -2.2 \cdot 10^{+169}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -6 \cdot 10^{-10}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 2.5 \cdot 10^{+55}:\\ \;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;U \leq 1.6 \cdot 10^{+208}:\\ \;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\ \mathbf{elif}\;U \leq 1.42 \cdot 10^{+267}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (+ U (* J (/ 2.0 (/ U J))))))
   (if (<= U -1.2e+237)
     t_0
     (if (<= U -2.2e+169)
       (- U)
       (if (<= U -6e-10)
         U
         (if (<= U 2.5e+55)
           (* J (* -2.0 (cos (* K 0.5))))
           (if (<= U 1.6e+208)
             (- (* -2.0 (/ J (/ U J))) U)
             (if (<= U 1.42e+267) t_0 (- U)))))))))
double code(double J, double K, double U) {
	double t_0 = U + (J * (2.0 / (U / J)));
	double tmp;
	if (U <= -1.2e+237) {
		tmp = t_0;
	} else if (U <= -2.2e+169) {
		tmp = -U;
	} else if (U <= -6e-10) {
		tmp = U;
	} else if (U <= 2.5e+55) {
		tmp = J * (-2.0 * cos((K * 0.5)));
	} else if (U <= 1.6e+208) {
		tmp = (-2.0 * (J / (U / J))) - U;
	} else if (U <= 1.42e+267) {
		tmp = t_0;
	} 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 = u + (j * (2.0d0 / (u / j)))
    if (u <= (-1.2d+237)) then
        tmp = t_0
    else if (u <= (-2.2d+169)) then
        tmp = -u
    else if (u <= (-6d-10)) then
        tmp = u
    else if (u <= 2.5d+55) then
        tmp = j * ((-2.0d0) * cos((k * 0.5d0)))
    else if (u <= 1.6d+208) then
        tmp = ((-2.0d0) * (j / (u / j))) - u
    else if (u <= 1.42d+267) then
        tmp = t_0
    else
        tmp = -u
    end if
    code = tmp
end function
public static double code(double J, double K, double U) {
	double t_0 = U + (J * (2.0 / (U / J)));
	double tmp;
	if (U <= -1.2e+237) {
		tmp = t_0;
	} else if (U <= -2.2e+169) {
		tmp = -U;
	} else if (U <= -6e-10) {
		tmp = U;
	} else if (U <= 2.5e+55) {
		tmp = J * (-2.0 * Math.cos((K * 0.5)));
	} else if (U <= 1.6e+208) {
		tmp = (-2.0 * (J / (U / J))) - U;
	} else if (U <= 1.42e+267) {
		tmp = t_0;
	} else {
		tmp = -U;
	}
	return tmp;
}
def code(J, K, U):
	t_0 = U + (J * (2.0 / (U / J)))
	tmp = 0
	if U <= -1.2e+237:
		tmp = t_0
	elif U <= -2.2e+169:
		tmp = -U
	elif U <= -6e-10:
		tmp = U
	elif U <= 2.5e+55:
		tmp = J * (-2.0 * math.cos((K * 0.5)))
	elif U <= 1.6e+208:
		tmp = (-2.0 * (J / (U / J))) - U
	elif U <= 1.42e+267:
		tmp = t_0
	else:
		tmp = -U
	return tmp
function code(J, K, U)
	t_0 = Float64(U + Float64(J * Float64(2.0 / Float64(U / J))))
	tmp = 0.0
	if (U <= -1.2e+237)
		tmp = t_0;
	elseif (U <= -2.2e+169)
		tmp = Float64(-U);
	elseif (U <= -6e-10)
		tmp = U;
	elseif (U <= 2.5e+55)
		tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5))));
	elseif (U <= 1.6e+208)
		tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / J))) - U);
	elseif (U <= 1.42e+267)
		tmp = t_0;
	else
		tmp = Float64(-U);
	end
	return tmp
end
function tmp_2 = code(J, K, U)
	t_0 = U + (J * (2.0 / (U / J)));
	tmp = 0.0;
	if (U <= -1.2e+237)
		tmp = t_0;
	elseif (U <= -2.2e+169)
		tmp = -U;
	elseif (U <= -6e-10)
		tmp = U;
	elseif (U <= 2.5e+55)
		tmp = J * (-2.0 * cos((K * 0.5)));
	elseif (U <= 1.6e+208)
		tmp = (-2.0 * (J / (U / J))) - U;
	elseif (U <= 1.42e+267)
		tmp = t_0;
	else
		tmp = -U;
	end
	tmp_2 = tmp;
end
code[J_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(2.0 / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U, -1.2e+237], t$95$0, If[LessEqual[U, -2.2e+169], (-U), If[LessEqual[U, -6e-10], U, If[LessEqual[U, 2.5e+55], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 1.6e+208], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[LessEqual[U, 1.42e+267], t$95$0, (-U)]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + J \cdot \frac{2}{\frac{U}{J}}\\
\mathbf{if}\;U \leq -1.2 \cdot 10^{+237}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;U \leq -2.2 \cdot 10^{+169}:\\
\;\;\;\;-U\\

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

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

\mathbf{elif}\;U \leq 1.6 \cdot 10^{+208}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if U < -1.1999999999999999e237 or 1.6000000000000001e208 < U < 1.42000000000000003e267

    1. Initial program 55.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. *-commutative55.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*55.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*55.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. *-commutative55.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*55.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. *-commutative55.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. unpow255.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-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 37.8%

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

      \[\leadsto \color{blue}{\left(2 \cdot \frac{J}{U} + \frac{U}{J}\right) \cdot J} \]
    6. Step-by-step derivation
      1. *-commutative37.0%

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

        \[\leadsto J \cdot \color{blue}{\left(\frac{U}{J} + 2 \cdot \frac{J}{U}\right)} \]
      3. distribute-lft-in37.0%

        \[\leadsto \color{blue}{J \cdot \frac{U}{J} + J \cdot \left(2 \cdot \frac{J}{U}\right)} \]
      4. associate-*r/40.6%

        \[\leadsto \color{blue}{\frac{J \cdot U}{J}} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      5. associate-*l/61.7%

        \[\leadsto \color{blue}{\frac{J}{J} \cdot U} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      6. *-inverses61.7%

        \[\leadsto \color{blue}{1} \cdot U + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      7. *-lft-identity61.7%

        \[\leadsto \color{blue}{U} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      8. associate-*r/61.7%

        \[\leadsto U + J \cdot \color{blue}{\frac{2 \cdot J}{U}} \]
      9. associate-/l*61.7%

        \[\leadsto U + J \cdot \color{blue}{\frac{2}{\frac{U}{J}}} \]
    7. Simplified61.7%

      \[\leadsto \color{blue}{U + J \cdot \frac{2}{\frac{U}{J}}} \]

    if -1.1999999999999999e237 < U < -2.2e169 or 1.42000000000000003e267 < U

    1. Initial program 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.2e169 < U < -6e-10

    1. Initial program 69.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. Step-by-step derivation
      1. *-commutative69.6%

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

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

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

        \[\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*69.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. *-commutative69.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. unpow269.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-def91.7%

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

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

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

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

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

    if -6e-10 < U < 2.50000000000000023e55

    1. Initial program 92.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. *-commutative92.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*92.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*92.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. *-commutative92.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*92.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. *-commutative92.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. unpow292.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 77.9%

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

    if 2.50000000000000023e55 < U < 1.6000000000000001e208

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-2 \cdot \frac{{J}^{2}}{U} + -1 \cdot U} \]
    9. Step-by-step derivation
      1. neg-mul-152.9%

        \[\leadsto -2 \cdot \frac{{J}^{2}}{U} + \color{blue}{\left(-U\right)} \]
      2. unsub-neg52.9%

        \[\leadsto \color{blue}{-2 \cdot \frac{{J}^{2}}{U} - U} \]
      3. associate-*r/52.9%

        \[\leadsto \color{blue}{\frac{-2 \cdot {J}^{2}}{U}} - U \]
      4. unpow252.9%

        \[\leadsto \frac{-2 \cdot \color{blue}{\left(J \cdot J\right)}}{U} - U \]
    10. Simplified52.9%

      \[\leadsto \color{blue}{\frac{-2 \cdot \left(J \cdot J\right)}{U} - U} \]
    11. Taylor expanded in J around 0 52.9%

      \[\leadsto \color{blue}{-2 \cdot \frac{{J}^{2}}{U}} - U \]
    12. Step-by-step derivation
      1. unpow252.9%

        \[\leadsto -2 \cdot \frac{\color{blue}{J \cdot J}}{U} - U \]
      2. associate-/l*56.5%

        \[\leadsto -2 \cdot \color{blue}{\frac{J}{\frac{U}{J}}} - U \]
    13. Simplified56.5%

      \[\leadsto \color{blue}{-2 \cdot \frac{J}{\frac{U}{J}}} - U \]
  3. Recombined 5 regimes into one program.
  4. Final simplification71.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq -1.2 \cdot 10^{+237}:\\ \;\;\;\;U + J \cdot \frac{2}{\frac{U}{J}}\\ \mathbf{elif}\;U \leq -2.2 \cdot 10^{+169}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -6 \cdot 10^{-10}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 2.5 \cdot 10^{+55}:\\ \;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;U \leq 1.6 \cdot 10^{+208}:\\ \;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\ \mathbf{elif}\;U \leq 1.42 \cdot 10^{+267}:\\ \;\;\;\;U + J \cdot \frac{2}{\frac{U}{J}}\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]

Alternative 5: 69.2% accurate, 3.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;K \leq -2.75 \cdot 10^{+31} \lor \neg \left(K \leq 0.095\right):\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if K < -2.75000000000000001e31 or 0.095000000000000001 < K

    1. Initial program 79.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. *-commutative79.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.75000000000000001e31 < K < 0.095000000000000001

    1. Initial program 77.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. *-commutative77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 39.3% accurate, 19.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + J \cdot \frac{2}{\frac{U}{J}}\\ \mathbf{if}\;U \leq -1.35 \cdot 10^{+237}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;U \leq -1.65 \cdot 10^{+170}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -4.4 \cdot 10^{-17}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 6.6 \cdot 10^{-84}:\\ \;\;\;\;J \cdot -2\\ \mathbf{elif}\;U \leq 1.86 \cdot 10^{+208}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 5 \cdot 10^{+266}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (+ U (* J (/ 2.0 (/ U J))))))
   (if (<= U -1.35e+237)
     t_0
     (if (<= U -1.65e+170)
       (- U)
       (if (<= U -4.4e-17)
         U
         (if (<= U 6.6e-84)
           (* J -2.0)
           (if (<= U 1.86e+208) (- U) (if (<= U 5e+266) t_0 (- U)))))))))
double code(double J, double K, double U) {
	double t_0 = U + (J * (2.0 / (U / J)));
	double tmp;
	if (U <= -1.35e+237) {
		tmp = t_0;
	} else if (U <= -1.65e+170) {
		tmp = -U;
	} else if (U <= -4.4e-17) {
		tmp = U;
	} else if (U <= 6.6e-84) {
		tmp = J * -2.0;
	} else if (U <= 1.86e+208) {
		tmp = -U;
	} else if (U <= 5e+266) {
		tmp = t_0;
	} 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 = u + (j * (2.0d0 / (u / j)))
    if (u <= (-1.35d+237)) then
        tmp = t_0
    else if (u <= (-1.65d+170)) then
        tmp = -u
    else if (u <= (-4.4d-17)) then
        tmp = u
    else if (u <= 6.6d-84) then
        tmp = j * (-2.0d0)
    else if (u <= 1.86d+208) then
        tmp = -u
    else if (u <= 5d+266) then
        tmp = t_0
    else
        tmp = -u
    end if
    code = tmp
end function
public static double code(double J, double K, double U) {
	double t_0 = U + (J * (2.0 / (U / J)));
	double tmp;
	if (U <= -1.35e+237) {
		tmp = t_0;
	} else if (U <= -1.65e+170) {
		tmp = -U;
	} else if (U <= -4.4e-17) {
		tmp = U;
	} else if (U <= 6.6e-84) {
		tmp = J * -2.0;
	} else if (U <= 1.86e+208) {
		tmp = -U;
	} else if (U <= 5e+266) {
		tmp = t_0;
	} else {
		tmp = -U;
	}
	return tmp;
}
def code(J, K, U):
	t_0 = U + (J * (2.0 / (U / J)))
	tmp = 0
	if U <= -1.35e+237:
		tmp = t_0
	elif U <= -1.65e+170:
		tmp = -U
	elif U <= -4.4e-17:
		tmp = U
	elif U <= 6.6e-84:
		tmp = J * -2.0
	elif U <= 1.86e+208:
		tmp = -U
	elif U <= 5e+266:
		tmp = t_0
	else:
		tmp = -U
	return tmp
function code(J, K, U)
	t_0 = Float64(U + Float64(J * Float64(2.0 / Float64(U / J))))
	tmp = 0.0
	if (U <= -1.35e+237)
		tmp = t_0;
	elseif (U <= -1.65e+170)
		tmp = Float64(-U);
	elseif (U <= -4.4e-17)
		tmp = U;
	elseif (U <= 6.6e-84)
		tmp = Float64(J * -2.0);
	elseif (U <= 1.86e+208)
		tmp = Float64(-U);
	elseif (U <= 5e+266)
		tmp = t_0;
	else
		tmp = Float64(-U);
	end
	return tmp
end
function tmp_2 = code(J, K, U)
	t_0 = U + (J * (2.0 / (U / J)));
	tmp = 0.0;
	if (U <= -1.35e+237)
		tmp = t_0;
	elseif (U <= -1.65e+170)
		tmp = -U;
	elseif (U <= -4.4e-17)
		tmp = U;
	elseif (U <= 6.6e-84)
		tmp = J * -2.0;
	elseif (U <= 1.86e+208)
		tmp = -U;
	elseif (U <= 5e+266)
		tmp = t_0;
	else
		tmp = -U;
	end
	tmp_2 = tmp;
end
code[J_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(2.0 / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U, -1.35e+237], t$95$0, If[LessEqual[U, -1.65e+170], (-U), If[LessEqual[U, -4.4e-17], U, If[LessEqual[U, 6.6e-84], N[(J * -2.0), $MachinePrecision], If[LessEqual[U, 1.86e+208], (-U), If[LessEqual[U, 5e+266], t$95$0, (-U)]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + J \cdot \frac{2}{\frac{U}{J}}\\
\mathbf{if}\;U \leq -1.35 \cdot 10^{+237}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;U \leq -1.65 \cdot 10^{+170}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq -4.4 \cdot 10^{-17}:\\
\;\;\;\;U\\

\mathbf{elif}\;U \leq 6.6 \cdot 10^{-84}:\\
\;\;\;\;J \cdot -2\\

\mathbf{elif}\;U \leq 1.86 \cdot 10^{+208}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq 5 \cdot 10^{+266}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if U < -1.35e237 or 1.85999999999999993e208 < U < 4.9999999999999999e266

    1. Initial program 55.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. *-commutative55.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*55.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*55.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. *-commutative55.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*55.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. *-commutative55.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. unpow255.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-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 37.8%

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

      \[\leadsto \color{blue}{\left(2 \cdot \frac{J}{U} + \frac{U}{J}\right) \cdot J} \]
    6. Step-by-step derivation
      1. *-commutative37.0%

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

        \[\leadsto J \cdot \color{blue}{\left(\frac{U}{J} + 2 \cdot \frac{J}{U}\right)} \]
      3. distribute-lft-in37.0%

        \[\leadsto \color{blue}{J \cdot \frac{U}{J} + J \cdot \left(2 \cdot \frac{J}{U}\right)} \]
      4. associate-*r/40.6%

        \[\leadsto \color{blue}{\frac{J \cdot U}{J}} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      5. associate-*l/61.7%

        \[\leadsto \color{blue}{\frac{J}{J} \cdot U} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      6. *-inverses61.7%

        \[\leadsto \color{blue}{1} \cdot U + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      7. *-lft-identity61.7%

        \[\leadsto \color{blue}{U} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      8. associate-*r/61.7%

        \[\leadsto U + J \cdot \color{blue}{\frac{2 \cdot J}{U}} \]
      9. associate-/l*61.7%

        \[\leadsto U + J \cdot \color{blue}{\frac{2}{\frac{U}{J}}} \]
    7. Simplified61.7%

      \[\leadsto \color{blue}{U + J \cdot \frac{2}{\frac{U}{J}}} \]

    if -1.35e237 < U < -1.65000000000000012e170 or 6.59999999999999968e-84 < U < 1.85999999999999993e208 or 4.9999999999999999e266 < U

    1. Initial program 58.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. Step-by-step derivation
      1. *-commutative58.1%

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

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

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

        \[\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*58.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. *-commutative58.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. unpow258.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-def81.5%

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

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

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

      \[\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 -1.65000000000000012e170 < U < -4.4e-17

    1. Initial program 69.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. Step-by-step derivation
      1. *-commutative69.6%

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

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

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

        \[\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*69.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. *-commutative69.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. unpow269.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-def91.7%

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

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

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

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

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

    if -4.4e-17 < U < 6.59999999999999968e-84

    1. Initial program 98.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. *-commutative98.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*98.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*98.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. *-commutative98.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*98.1%

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

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

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

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

      \[\leadsto \color{blue}{-2 \cdot J} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification52.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq -1.35 \cdot 10^{+237}:\\ \;\;\;\;U + J \cdot \frac{2}{\frac{U}{J}}\\ \mathbf{elif}\;U \leq -1.65 \cdot 10^{+170}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -4.4 \cdot 10^{-17}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 6.6 \cdot 10^{-84}:\\ \;\;\;\;J \cdot -2\\ \mathbf{elif}\;U \leq 1.86 \cdot 10^{+208}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 5 \cdot 10^{+266}:\\ \;\;\;\;U + J \cdot \frac{2}{\frac{U}{J}}\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]

Alternative 7: 39.5% accurate, 19.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + J \cdot \frac{2}{\frac{U}{J}}\\ \mathbf{if}\;U \leq -1 \cdot 10^{+237}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;U \leq -2.3 \cdot 10^{+171}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -1.8 \cdot 10^{-16}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 3.3 \cdot 10^{-82}:\\ \;\;\;\;J \cdot -2\\ \mathbf{elif}\;U \leq 4.2 \cdot 10^{+212}:\\ \;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\ \mathbf{elif}\;U \leq 5 \cdot 10^{+266}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (let* ((t_0 (+ U (* J (/ 2.0 (/ U J))))))
   (if (<= U -1e+237)
     t_0
     (if (<= U -2.3e+171)
       (- U)
       (if (<= U -1.8e-16)
         U
         (if (<= U 3.3e-82)
           (* J -2.0)
           (if (<= U 4.2e+212)
             (- (* -2.0 (/ J (/ U J))) U)
             (if (<= U 5e+266) t_0 (- U)))))))))
double code(double J, double K, double U) {
	double t_0 = U + (J * (2.0 / (U / J)));
	double tmp;
	if (U <= -1e+237) {
		tmp = t_0;
	} else if (U <= -2.3e+171) {
		tmp = -U;
	} else if (U <= -1.8e-16) {
		tmp = U;
	} else if (U <= 3.3e-82) {
		tmp = J * -2.0;
	} else if (U <= 4.2e+212) {
		tmp = (-2.0 * (J / (U / J))) - U;
	} else if (U <= 5e+266) {
		tmp = t_0;
	} 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 = u + (j * (2.0d0 / (u / j)))
    if (u <= (-1d+237)) then
        tmp = t_0
    else if (u <= (-2.3d+171)) then
        tmp = -u
    else if (u <= (-1.8d-16)) then
        tmp = u
    else if (u <= 3.3d-82) then
        tmp = j * (-2.0d0)
    else if (u <= 4.2d+212) then
        tmp = ((-2.0d0) * (j / (u / j))) - u
    else if (u <= 5d+266) then
        tmp = t_0
    else
        tmp = -u
    end if
    code = tmp
end function
public static double code(double J, double K, double U) {
	double t_0 = U + (J * (2.0 / (U / J)));
	double tmp;
	if (U <= -1e+237) {
		tmp = t_0;
	} else if (U <= -2.3e+171) {
		tmp = -U;
	} else if (U <= -1.8e-16) {
		tmp = U;
	} else if (U <= 3.3e-82) {
		tmp = J * -2.0;
	} else if (U <= 4.2e+212) {
		tmp = (-2.0 * (J / (U / J))) - U;
	} else if (U <= 5e+266) {
		tmp = t_0;
	} else {
		tmp = -U;
	}
	return tmp;
}
def code(J, K, U):
	t_0 = U + (J * (2.0 / (U / J)))
	tmp = 0
	if U <= -1e+237:
		tmp = t_0
	elif U <= -2.3e+171:
		tmp = -U
	elif U <= -1.8e-16:
		tmp = U
	elif U <= 3.3e-82:
		tmp = J * -2.0
	elif U <= 4.2e+212:
		tmp = (-2.0 * (J / (U / J))) - U
	elif U <= 5e+266:
		tmp = t_0
	else:
		tmp = -U
	return tmp
function code(J, K, U)
	t_0 = Float64(U + Float64(J * Float64(2.0 / Float64(U / J))))
	tmp = 0.0
	if (U <= -1e+237)
		tmp = t_0;
	elseif (U <= -2.3e+171)
		tmp = Float64(-U);
	elseif (U <= -1.8e-16)
		tmp = U;
	elseif (U <= 3.3e-82)
		tmp = Float64(J * -2.0);
	elseif (U <= 4.2e+212)
		tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / J))) - U);
	elseif (U <= 5e+266)
		tmp = t_0;
	else
		tmp = Float64(-U);
	end
	return tmp
end
function tmp_2 = code(J, K, U)
	t_0 = U + (J * (2.0 / (U / J)));
	tmp = 0.0;
	if (U <= -1e+237)
		tmp = t_0;
	elseif (U <= -2.3e+171)
		tmp = -U;
	elseif (U <= -1.8e-16)
		tmp = U;
	elseif (U <= 3.3e-82)
		tmp = J * -2.0;
	elseif (U <= 4.2e+212)
		tmp = (-2.0 * (J / (U / J))) - U;
	elseif (U <= 5e+266)
		tmp = t_0;
	else
		tmp = -U;
	end
	tmp_2 = tmp;
end
code[J_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(2.0 / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U, -1e+237], t$95$0, If[LessEqual[U, -2.3e+171], (-U), If[LessEqual[U, -1.8e-16], U, If[LessEqual[U, 3.3e-82], N[(J * -2.0), $MachinePrecision], If[LessEqual[U, 4.2e+212], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[LessEqual[U, 5e+266], t$95$0, (-U)]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + J \cdot \frac{2}{\frac{U}{J}}\\
\mathbf{if}\;U \leq -1 \cdot 10^{+237}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;U \leq -2.3 \cdot 10^{+171}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq -1.8 \cdot 10^{-16}:\\
\;\;\;\;U\\

\mathbf{elif}\;U \leq 3.3 \cdot 10^{-82}:\\
\;\;\;\;J \cdot -2\\

\mathbf{elif}\;U \leq 4.2 \cdot 10^{+212}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\

\mathbf{elif}\;U \leq 5 \cdot 10^{+266}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if U < -9.9999999999999994e236 or 4.2e212 < U < 4.9999999999999999e266

    1. Initial program 55.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. *-commutative55.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*55.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*55.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. *-commutative55.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*55.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. *-commutative55.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. unpow255.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-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 37.8%

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

      \[\leadsto \color{blue}{\left(2 \cdot \frac{J}{U} + \frac{U}{J}\right) \cdot J} \]
    6. Step-by-step derivation
      1. *-commutative37.0%

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

        \[\leadsto J \cdot \color{blue}{\left(\frac{U}{J} + 2 \cdot \frac{J}{U}\right)} \]
      3. distribute-lft-in37.0%

        \[\leadsto \color{blue}{J \cdot \frac{U}{J} + J \cdot \left(2 \cdot \frac{J}{U}\right)} \]
      4. associate-*r/40.6%

        \[\leadsto \color{blue}{\frac{J \cdot U}{J}} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      5. associate-*l/61.7%

        \[\leadsto \color{blue}{\frac{J}{J} \cdot U} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      6. *-inverses61.7%

        \[\leadsto \color{blue}{1} \cdot U + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      7. *-lft-identity61.7%

        \[\leadsto \color{blue}{U} + J \cdot \left(2 \cdot \frac{J}{U}\right) \]
      8. associate-*r/61.7%

        \[\leadsto U + J \cdot \color{blue}{\frac{2 \cdot J}{U}} \]
      9. associate-/l*61.7%

        \[\leadsto U + J \cdot \color{blue}{\frac{2}{\frac{U}{J}}} \]
    7. Simplified61.7%

      \[\leadsto \color{blue}{U + J \cdot \frac{2}{\frac{U}{J}}} \]

    if -9.9999999999999994e236 < U < -2.30000000000000017e171 or 4.9999999999999999e266 < U

    1. Initial program 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.30000000000000017e171 < U < -1.79999999999999991e-16

    1. Initial program 69.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. Step-by-step derivation
      1. *-commutative69.6%

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

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

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

        \[\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*69.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. *-commutative69.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. unpow269.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-def91.7%

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

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

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

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

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

    if -1.79999999999999991e-16 < U < 3.30000000000000022e-82

    1. Initial program 98.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. *-commutative98.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*98.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*98.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. *-commutative98.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*98.1%

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

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

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

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

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

    if 3.30000000000000022e-82 < U < 4.2e212

    1. Initial program 62.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. Step-by-step derivation
      1. *-commutative62.3%

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

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

        \[\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-def91.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. *-commutative91.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*91.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. Simplified91.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. Taylor expanded in K around 0 64.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-2 \cdot \frac{{J}^{2}}{U} + -1 \cdot U} \]
    9. Step-by-step derivation
      1. neg-mul-140.9%

        \[\leadsto -2 \cdot \frac{{J}^{2}}{U} + \color{blue}{\left(-U\right)} \]
      2. unsub-neg40.9%

        \[\leadsto \color{blue}{-2 \cdot \frac{{J}^{2}}{U} - U} \]
      3. associate-*r/40.9%

        \[\leadsto \color{blue}{\frac{-2 \cdot {J}^{2}}{U}} - U \]
      4. unpow240.9%

        \[\leadsto \frac{-2 \cdot \color{blue}{\left(J \cdot J\right)}}{U} - U \]
    10. Simplified40.9%

      \[\leadsto \color{blue}{\frac{-2 \cdot \left(J \cdot J\right)}{U} - U} \]
    11. Taylor expanded in J around 0 40.9%

      \[\leadsto \color{blue}{-2 \cdot \frac{{J}^{2}}{U}} - U \]
    12. Step-by-step derivation
      1. unpow240.9%

        \[\leadsto -2 \cdot \frac{\color{blue}{J \cdot J}}{U} - U \]
      2. associate-/l*42.7%

        \[\leadsto -2 \cdot \color{blue}{\frac{J}{\frac{U}{J}}} - U \]
    13. Simplified42.7%

      \[\leadsto \color{blue}{-2 \cdot \frac{J}{\frac{U}{J}}} - U \]
  3. Recombined 5 regimes into one program.
  4. Final simplification52.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq -1 \cdot 10^{+237}:\\ \;\;\;\;U + J \cdot \frac{2}{\frac{U}{J}}\\ \mathbf{elif}\;U \leq -2.3 \cdot 10^{+171}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -1.8 \cdot 10^{-16}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 3.3 \cdot 10^{-82}:\\ \;\;\;\;J \cdot -2\\ \mathbf{elif}\;U \leq 4.2 \cdot 10^{+212}:\\ \;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\ \mathbf{elif}\;U \leq 5 \cdot 10^{+266}:\\ \;\;\;\;U + J \cdot \frac{2}{\frac{U}{J}}\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]

Alternative 8: 26.6% accurate, 25.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;U \leq -1.2 \cdot 10^{+237}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq -1.55 \cdot 10^{+169}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -9.8 \cdot 10^{-194}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 7800000000:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 1.95 \cdot 10^{+167}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 3.9 \cdot 10^{+210}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 6.7 \cdot 10^{+270}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (if (<= U -1.2e+237)
   U
   (if (<= U -1.55e+169)
     (- U)
     (if (<= U -9.8e-194)
       U
       (if (<= U 7800000000.0)
         (- U)
         (if (<= U 1.95e+167)
           U
           (if (<= U 3.9e+210) (- U) (if (<= U 6.7e+270) U (- U)))))))))
double code(double J, double K, double U) {
	double tmp;
	if (U <= -1.2e+237) {
		tmp = U;
	} else if (U <= -1.55e+169) {
		tmp = -U;
	} else if (U <= -9.8e-194) {
		tmp = U;
	} else if (U <= 7800000000.0) {
		tmp = -U;
	} else if (U <= 1.95e+167) {
		tmp = U;
	} else if (U <= 3.9e+210) {
		tmp = -U;
	} else if (U <= 6.7e+270) {
		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 <= (-1.2d+237)) then
        tmp = u
    else if (u <= (-1.55d+169)) then
        tmp = -u
    else if (u <= (-9.8d-194)) then
        tmp = u
    else if (u <= 7800000000.0d0) then
        tmp = -u
    else if (u <= 1.95d+167) then
        tmp = u
    else if (u <= 3.9d+210) then
        tmp = -u
    else if (u <= 6.7d+270) 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 <= -1.2e+237) {
		tmp = U;
	} else if (U <= -1.55e+169) {
		tmp = -U;
	} else if (U <= -9.8e-194) {
		tmp = U;
	} else if (U <= 7800000000.0) {
		tmp = -U;
	} else if (U <= 1.95e+167) {
		tmp = U;
	} else if (U <= 3.9e+210) {
		tmp = -U;
	} else if (U <= 6.7e+270) {
		tmp = U;
	} else {
		tmp = -U;
	}
	return tmp;
}
def code(J, K, U):
	tmp = 0
	if U <= -1.2e+237:
		tmp = U
	elif U <= -1.55e+169:
		tmp = -U
	elif U <= -9.8e-194:
		tmp = U
	elif U <= 7800000000.0:
		tmp = -U
	elif U <= 1.95e+167:
		tmp = U
	elif U <= 3.9e+210:
		tmp = -U
	elif U <= 6.7e+270:
		tmp = U
	else:
		tmp = -U
	return tmp
function code(J, K, U)
	tmp = 0.0
	if (U <= -1.2e+237)
		tmp = U;
	elseif (U <= -1.55e+169)
		tmp = Float64(-U);
	elseif (U <= -9.8e-194)
		tmp = U;
	elseif (U <= 7800000000.0)
		tmp = Float64(-U);
	elseif (U <= 1.95e+167)
		tmp = U;
	elseif (U <= 3.9e+210)
		tmp = Float64(-U);
	elseif (U <= 6.7e+270)
		tmp = U;
	else
		tmp = Float64(-U);
	end
	return tmp
end
function tmp_2 = code(J, K, U)
	tmp = 0.0;
	if (U <= -1.2e+237)
		tmp = U;
	elseif (U <= -1.55e+169)
		tmp = -U;
	elseif (U <= -9.8e-194)
		tmp = U;
	elseif (U <= 7800000000.0)
		tmp = -U;
	elseif (U <= 1.95e+167)
		tmp = U;
	elseif (U <= 3.9e+210)
		tmp = -U;
	elseif (U <= 6.7e+270)
		tmp = U;
	else
		tmp = -U;
	end
	tmp_2 = tmp;
end
code[J_, K_, U_] := If[LessEqual[U, -1.2e+237], U, If[LessEqual[U, -1.55e+169], (-U), If[LessEqual[U, -9.8e-194], U, If[LessEqual[U, 7800000000.0], (-U), If[LessEqual[U, 1.95e+167], U, If[LessEqual[U, 3.9e+210], (-U), If[LessEqual[U, 6.7e+270], U, (-U)]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;U \leq -9.8 \cdot 10^{-194}:\\
\;\;\;\;U\\

\mathbf{elif}\;U \leq 7800000000:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq 1.95 \cdot 10^{+167}:\\
\;\;\;\;U\\

\mathbf{elif}\;U \leq 3.9 \cdot 10^{+210}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq 6.7 \cdot 10^{+270}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if U < -1.1999999999999999e237 or -1.55e169 < U < -9.80000000000000008e-194 or 7.8e9 < U < 1.9499999999999999e167 or 3.9e210 < U < 6.7e270

    1. Initial program 77.8%

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

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

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

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

        \[\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*77.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. *-commutative77.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. unpow277.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-def89.6%

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

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

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

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

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

    if -1.1999999999999999e237 < U < -1.55e169 or -9.80000000000000008e-194 < U < 7.8e9 or 1.9499999999999999e167 < U < 3.9e210 or 6.7e270 < U

    1. Initial program 79.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. *-commutative79.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*79.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*79.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. *-commutative79.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*78.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. *-commutative78.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. unpow278.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-def90.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. *-commutative90.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*90.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. Simplified90.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 33.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq -1.2 \cdot 10^{+237}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq -1.55 \cdot 10^{+169}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -9.8 \cdot 10^{-194}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 7800000000:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 1.95 \cdot 10^{+167}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 3.9 \cdot 10^{+210}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 6.7 \cdot 10^{+270}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]

Alternative 9: 39.1% accurate, 29.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;U \leq -1.1 \cdot 10^{+237}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq -2.9 \cdot 10^{+162}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -4.5 \cdot 10^{-14}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 1.2 \cdot 10^{-82}:\\ \;\;\;\;J \cdot -2\\ \mathbf{elif}\;U \leq 1.25 \cdot 10^{+212}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 2 \cdot 10^{+269}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \end{array} \]
(FPCore (J K U)
 :precision binary64
 (if (<= U -1.1e+237)
   U
   (if (<= U -2.9e+162)
     (- U)
     (if (<= U -4.5e-14)
       U
       (if (<= U 1.2e-82)
         (* J -2.0)
         (if (<= U 1.25e+212) (- U) (if (<= U 2e+269) U (- U))))))))
double code(double J, double K, double U) {
	double tmp;
	if (U <= -1.1e+237) {
		tmp = U;
	} else if (U <= -2.9e+162) {
		tmp = -U;
	} else if (U <= -4.5e-14) {
		tmp = U;
	} else if (U <= 1.2e-82) {
		tmp = J * -2.0;
	} else if (U <= 1.25e+212) {
		tmp = -U;
	} else if (U <= 2e+269) {
		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 <= (-1.1d+237)) then
        tmp = u
    else if (u <= (-2.9d+162)) then
        tmp = -u
    else if (u <= (-4.5d-14)) then
        tmp = u
    else if (u <= 1.2d-82) then
        tmp = j * (-2.0d0)
    else if (u <= 1.25d+212) then
        tmp = -u
    else if (u <= 2d+269) 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 <= -1.1e+237) {
		tmp = U;
	} else if (U <= -2.9e+162) {
		tmp = -U;
	} else if (U <= -4.5e-14) {
		tmp = U;
	} else if (U <= 1.2e-82) {
		tmp = J * -2.0;
	} else if (U <= 1.25e+212) {
		tmp = -U;
	} else if (U <= 2e+269) {
		tmp = U;
	} else {
		tmp = -U;
	}
	return tmp;
}
def code(J, K, U):
	tmp = 0
	if U <= -1.1e+237:
		tmp = U
	elif U <= -2.9e+162:
		tmp = -U
	elif U <= -4.5e-14:
		tmp = U
	elif U <= 1.2e-82:
		tmp = J * -2.0
	elif U <= 1.25e+212:
		tmp = -U
	elif U <= 2e+269:
		tmp = U
	else:
		tmp = -U
	return tmp
function code(J, K, U)
	tmp = 0.0
	if (U <= -1.1e+237)
		tmp = U;
	elseif (U <= -2.9e+162)
		tmp = Float64(-U);
	elseif (U <= -4.5e-14)
		tmp = U;
	elseif (U <= 1.2e-82)
		tmp = Float64(J * -2.0);
	elseif (U <= 1.25e+212)
		tmp = Float64(-U);
	elseif (U <= 2e+269)
		tmp = U;
	else
		tmp = Float64(-U);
	end
	return tmp
end
function tmp_2 = code(J, K, U)
	tmp = 0.0;
	if (U <= -1.1e+237)
		tmp = U;
	elseif (U <= -2.9e+162)
		tmp = -U;
	elseif (U <= -4.5e-14)
		tmp = U;
	elseif (U <= 1.2e-82)
		tmp = J * -2.0;
	elseif (U <= 1.25e+212)
		tmp = -U;
	elseif (U <= 2e+269)
		tmp = U;
	else
		tmp = -U;
	end
	tmp_2 = tmp;
end
code[J_, K_, U_] := If[LessEqual[U, -1.1e+237], U, If[LessEqual[U, -2.9e+162], (-U), If[LessEqual[U, -4.5e-14], U, If[LessEqual[U, 1.2e-82], N[(J * -2.0), $MachinePrecision], If[LessEqual[U, 1.25e+212], (-U), If[LessEqual[U, 2e+269], U, (-U)]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;U \leq -2.9 \cdot 10^{+162}:\\
\;\;\;\;-U\\

\mathbf{elif}\;U \leq -4.5 \cdot 10^{-14}:\\
\;\;\;\;U\\

\mathbf{elif}\;U \leq 1.2 \cdot 10^{-82}:\\
\;\;\;\;J \cdot -2\\

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

\mathbf{elif}\;U \leq 2 \cdot 10^{+269}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if U < -1.1e237 or -2.90000000000000006e162 < U < -4.4999999999999998e-14 or 1.24999999999999998e212 < U < 2.0000000000000001e269

    1. Initial program 64.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. *-commutative64.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*64.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*64.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. *-commutative64.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*64.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. *-commutative64.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. unpow264.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-def82.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. *-commutative82.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*82.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. Simplified82.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 61.1%

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

    if -1.1e237 < U < -2.90000000000000006e162 or 1.20000000000000004e-82 < U < 1.24999999999999998e212 or 2.0000000000000001e269 < U

    1. Initial program 58.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. Step-by-step derivation
      1. *-commutative58.1%

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

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

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

        \[\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*58.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. *-commutative58.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. unpow258.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-def81.5%

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

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

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

      \[\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 -4.4999999999999998e-14 < U < 1.20000000000000004e-82

    1. Initial program 98.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. *-commutative98.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*98.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*98.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. *-commutative98.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*98.1%

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

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

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

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

      \[\leadsto \color{blue}{-2 \cdot J} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification52.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;U \leq -1.1 \cdot 10^{+237}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq -2.9 \cdot 10^{+162}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq -4.5 \cdot 10^{-14}:\\ \;\;\;\;U\\ \mathbf{elif}\;U \leq 1.2 \cdot 10^{-82}:\\ \;\;\;\;J \cdot -2\\ \mathbf{elif}\;U \leq 1.25 \cdot 10^{+212}:\\ \;\;\;\;-U\\ \mathbf{elif}\;U \leq 2 \cdot 10^{+269}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array} \]

Alternative 10: 26.1% 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 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-def90.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. *-commutative90.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*90.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. Simplified90.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 25.7%

    \[\leadsto \color{blue}{U} \]
  5. Final simplification25.7%

    \[\leadsto U \]

Reproduce

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