
(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:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(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}
Initial program 77.3%
*-commutative77.3%
associate-*l*77.3%
unpow277.3%
hypot-1-def92.5%
*-commutative92.5%
associate-*l*92.5%
Simplified92.5%
Final simplification92.5%
(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}
Initial program 77.3%
*-commutative77.3%
associate-*l*77.3%
associate-*r*77.3%
*-commutative77.3%
associate-*l*77.2%
*-commutative77.2%
unpow277.2%
hypot-1-def92.4%
*-commutative92.4%
associate-*l*92.4%
Simplified92.4%
Final simplification92.4%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (/ U (* J 2.0))))))
(if (<= J -5.2e-113)
t_0
(if (<= J -3.6e-287) U (if (<= J 8e-190) (- U) t_0)))))
double code(double J, double K, double U) {
double t_0 = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0)));
double tmp;
if (J <= -5.2e-113) {
tmp = t_0;
} else if (J <= -3.6e-287) {
tmp = U;
} else if (J <= 8e-190) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double J, double K, double U) {
double t_0 = (J * (-2.0 * Math.cos((K / 2.0)))) * Math.hypot(1.0, (U / (J * 2.0)));
double tmp;
if (J <= -5.2e-113) {
tmp = t_0;
} else if (J <= -3.6e-287) {
tmp = U;
} else if (J <= 8e-190) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, K, U): t_0 = (J * (-2.0 * math.cos((K / 2.0)))) * math.hypot(1.0, (U / (J * 2.0))) tmp = 0 if J <= -5.2e-113: tmp = t_0 elif J <= -3.6e-287: tmp = U elif J <= 8e-190: tmp = -U else: tmp = t_0 return tmp
function code(J, K, U) t_0 = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(U / Float64(J * 2.0)))) tmp = 0.0 if (J <= -5.2e-113) tmp = t_0; elseif (J <= -3.6e-287) tmp = U; elseif (J <= 8e-190) tmp = Float64(-U); else tmp = t_0; end return tmp end
function tmp_2 = code(J, K, U) t_0 = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0))); tmp = 0.0; if (J <= -5.2e-113) tmp = t_0; elseif (J <= -3.6e-287) tmp = U; elseif (J <= 8e-190) tmp = -U; else tmp = t_0; end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = 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 * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -5.2e-113], t$95$0, If[LessEqual[J, -3.6e-287], U, If[LessEqual[J, 8e-190], (-U), t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\\
\mathbf{if}\;J \leq -5.2 \cdot 10^{-113}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -3.6 \cdot 10^{-287}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 8 \cdot 10^{-190}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -5.1999999999999998e-113 or 8.0000000000000002e-190 < J Initial program 87.6%
*-commutative87.6%
associate-*l*87.6%
unpow287.6%
hypot-1-def98.9%
*-commutative98.9%
associate-*l*98.9%
Simplified98.9%
Taylor expanded in K around 0 84.9%
if -5.1999999999999998e-113 < J < -3.6000000000000001e-287Initial program 54.8%
*-commutative54.8%
associate-*l*54.8%
associate-*r*54.8%
*-commutative54.8%
associate-*l*54.5%
*-commutative54.5%
unpow254.5%
hypot-1-def77.2%
*-commutative77.2%
associate-*l*77.2%
Simplified77.2%
Taylor expanded in U around -inf 75.9%
if -3.6000000000000001e-287 < J < 8.0000000000000002e-190Initial program 36.6%
*-commutative36.6%
associate-*l*36.6%
associate-*r*36.6%
*-commutative36.6%
associate-*l*36.4%
*-commutative36.4%
unpow236.4%
hypot-1-def68.4%
*-commutative68.4%
associate-*l*68.4%
Simplified68.4%
Taylor expanded in J around 0 60.5%
neg-mul-160.5%
Simplified60.5%
Final simplification81.0%
(FPCore (J K U)
:precision binary64
(if (<= K -3.5e+72)
(- (* -2.0 (/ J (/ U J))) U)
(if (or (<= K -16000.0) (not (<= K 2e-25)))
(* J (* -2.0 (cos (* K 0.5))))
(* (hypot 1.0 (/ U (* J 2.0))) (* J -2.0)))))
double code(double J, double K, double U) {
double tmp;
if (K <= -3.5e+72) {
tmp = (-2.0 * (J / (U / J))) - U;
} else if ((K <= -16000.0) || !(K <= 2e-25)) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else {
tmp = hypot(1.0, (U / (J * 2.0))) * (J * -2.0);
}
return tmp;
}
public static double code(double J, double K, double U) {
double tmp;
if (K <= -3.5e+72) {
tmp = (-2.0 * (J / (U / J))) - U;
} else if ((K <= -16000.0) || !(K <= 2e-25)) {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
} else {
tmp = Math.hypot(1.0, (U / (J * 2.0))) * (J * -2.0);
}
return tmp;
}
def code(J, K, U): tmp = 0 if K <= -3.5e+72: tmp = (-2.0 * (J / (U / J))) - U elif (K <= -16000.0) or not (K <= 2e-25): tmp = J * (-2.0 * math.cos((K * 0.5))) else: tmp = math.hypot(1.0, (U / (J * 2.0))) * (J * -2.0) return tmp
function code(J, K, U) tmp = 0.0 if (K <= -3.5e+72) tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / J))) - U); elseif ((K <= -16000.0) || !(K <= 2e-25)) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); else tmp = Float64(hypot(1.0, Float64(U / Float64(J * 2.0))) * Float64(J * -2.0)); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (K <= -3.5e+72) tmp = (-2.0 * (J / (U / J))) - U; elseif ((K <= -16000.0) || ~((K <= 2e-25))) tmp = J * (-2.0 * cos((K * 0.5))); else tmp = hypot(1.0, (U / (J * 2.0))) * (J * -2.0); end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[K, -3.5e+72], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[Or[LessEqual[K, -16000.0], N[Not[LessEqual[K, 2e-25]], $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 * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * N[(J * -2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq -3.5 \cdot 10^{+72}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\
\mathbf{elif}\;K \leq -16000 \lor \neg \left(K \leq 2 \cdot 10^{-25}\right):\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right) \cdot \left(J \cdot -2\right)\\
\end{array}
\end{array}
if K < -3.5000000000000001e72Initial program 68.1%
*-commutative68.1%
associate-*l*68.1%
associate-*r*68.1%
*-commutative68.1%
associate-*l*67.9%
*-commutative67.9%
unpow267.9%
hypot-1-def86.4%
*-commutative86.4%
associate-*l*86.4%
Simplified86.4%
Taylor expanded in J around 0 41.2%
neg-mul-141.2%
unsub-neg41.2%
associate-/l*41.2%
associate-*r/41.2%
unpow241.2%
Simplified41.2%
Taylor expanded in K around 0 41.2%
unpow241.2%
associate-/l*43.6%
Simplified43.6%
if -3.5000000000000001e72 < K < -16000 or 2.00000000000000008e-25 < K Initial program 83.0%
*-commutative83.0%
associate-*l*83.0%
associate-*r*83.0%
*-commutative83.0%
associate-*l*82.8%
*-commutative82.8%
unpow282.8%
hypot-1-def94.9%
*-commutative94.9%
associate-*l*94.9%
Simplified94.9%
Taylor expanded in U around 0 57.4%
if -16000 < K < 2.00000000000000008e-25Initial program 75.2%
*-commutative75.2%
associate-*l*75.2%
unpow275.2%
hypot-1-def92.0%
*-commutative92.0%
associate-*l*92.0%
Simplified92.0%
Taylor expanded in K around 0 91.3%
Taylor expanded in K around 0 92.0%
Final simplification71.4%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -2.1e-111)
t_0
(if (<= J -4.8e-288) U (if (<= J 1.25e-189) (- U) t_0)))))
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -2.1e-111) {
tmp = t_0;
} else if (J <= -4.8e-288) {
tmp = U;
} else if (J <= 1.25e-189) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-2.1d-111)) then
tmp = t_0
else if (j <= (-4.8d-288)) then
tmp = u
else if (j <= 1.25d-189) then
tmp = -u
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double t_0 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (J <= -2.1e-111) {
tmp = t_0;
} else if (J <= -4.8e-288) {
tmp = U;
} else if (J <= 1.25e-189) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -2.1e-111: tmp = t_0 elif J <= -4.8e-288: tmp = U elif J <= 1.25e-189: tmp = -U else: tmp = t_0 return tmp
function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -2.1e-111) tmp = t_0; elseif (J <= -4.8e-288) tmp = U; elseif (J <= 1.25e-189) tmp = Float64(-U); else tmp = t_0; end return tmp end
function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (J <= -2.1e-111) tmp = t_0; elseif (J <= -4.8e-288) tmp = U; elseif (J <= 1.25e-189) tmp = -U; else tmp = t_0; end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -2.1e-111], t$95$0, If[LessEqual[J, -4.8e-288], U, If[LessEqual[J, 1.25e-189], (-U), t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -2.1 \cdot 10^{-111}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4.8 \cdot 10^{-288}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.25 \cdot 10^{-189}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -2.0999999999999999e-111 or 1.2499999999999999e-189 < J Initial program 87.6%
*-commutative87.6%
associate-*l*87.6%
associate-*r*87.6%
*-commutative87.6%
associate-*l*87.5%
*-commutative87.5%
unpow287.5%
hypot-1-def98.8%
*-commutative98.8%
associate-*l*98.8%
Simplified98.8%
Taylor expanded in U around 0 67.3%
if -2.0999999999999999e-111 < J < -4.7999999999999997e-288Initial program 54.8%
*-commutative54.8%
associate-*l*54.8%
associate-*r*54.8%
*-commutative54.8%
associate-*l*54.5%
*-commutative54.5%
unpow254.5%
hypot-1-def77.2%
*-commutative77.2%
associate-*l*77.2%
Simplified77.2%
Taylor expanded in U around -inf 75.9%
if -4.7999999999999997e-288 < J < 1.2499999999999999e-189Initial program 36.6%
*-commutative36.6%
associate-*l*36.6%
associate-*r*36.6%
*-commutative36.6%
associate-*l*36.4%
*-commutative36.4%
unpow236.4%
hypot-1-def68.4%
*-commutative68.4%
associate-*l*68.4%
Simplified68.4%
Taylor expanded in J around 0 60.5%
neg-mul-160.5%
Simplified60.5%
Final simplification67.8%
(FPCore (J K U)
:precision binary64
(if (<= J -3.6e+54)
U
(if (<= J -1.08e-125)
(- U)
(if (<= J -1.44e-288)
U
(if (<= J 2.7e+25) (- U) (if (<= J 9.5e+92) U (- U)))))))
double code(double J, double K, double U) {
double tmp;
if (J <= -3.6e+54) {
tmp = U;
} else if (J <= -1.08e-125) {
tmp = -U;
} else if (J <= -1.44e-288) {
tmp = U;
} else if (J <= 2.7e+25) {
tmp = -U;
} else if (J <= 9.5e+92) {
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 (j <= (-3.6d+54)) then
tmp = u
else if (j <= (-1.08d-125)) then
tmp = -u
else if (j <= (-1.44d-288)) then
tmp = u
else if (j <= 2.7d+25) then
tmp = -u
else if (j <= 9.5d+92) 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 (J <= -3.6e+54) {
tmp = U;
} else if (J <= -1.08e-125) {
tmp = -U;
} else if (J <= -1.44e-288) {
tmp = U;
} else if (J <= 2.7e+25) {
tmp = -U;
} else if (J <= 9.5e+92) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if J <= -3.6e+54: tmp = U elif J <= -1.08e-125: tmp = -U elif J <= -1.44e-288: tmp = U elif J <= 2.7e+25: tmp = -U elif J <= 9.5e+92: tmp = U else: tmp = -U return tmp
function code(J, K, U) tmp = 0.0 if (J <= -3.6e+54) tmp = U; elseif (J <= -1.08e-125) tmp = Float64(-U); elseif (J <= -1.44e-288) tmp = U; elseif (J <= 2.7e+25) tmp = Float64(-U); elseif (J <= 9.5e+92) tmp = U; else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -3.6e+54) tmp = U; elseif (J <= -1.08e-125) tmp = -U; elseif (J <= -1.44e-288) tmp = U; elseif (J <= 2.7e+25) tmp = -U; elseif (J <= 9.5e+92) tmp = U; else tmp = -U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[J, -3.6e+54], U, If[LessEqual[J, -1.08e-125], (-U), If[LessEqual[J, -1.44e-288], U, If[LessEqual[J, 2.7e+25], (-U), If[LessEqual[J, 9.5e+92], U, (-U)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \leq -3.6 \cdot 10^{+54}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq -1.08 \cdot 10^{-125}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq -1.44 \cdot 10^{-288}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2.7 \cdot 10^{+25}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq 9.5 \cdot 10^{+92}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -3.6000000000000001e54 or -1.07999999999999998e-125 < J < -1.44e-288 or 2.7e25 < J < 9.4999999999999995e92Initial program 81.3%
*-commutative81.3%
associate-*l*81.3%
associate-*r*81.3%
*-commutative81.3%
associate-*l*81.2%
*-commutative81.2%
unpow281.2%
hypot-1-def91.4%
*-commutative91.4%
associate-*l*91.4%
Simplified91.4%
Taylor expanded in U around -inf 44.7%
if -3.6000000000000001e54 < J < -1.07999999999999998e-125 or -1.44e-288 < J < 2.7e25 or 9.4999999999999995e92 < J Initial program 74.7%
*-commutative74.7%
associate-*l*74.7%
associate-*r*74.7%
*-commutative74.7%
associate-*l*74.6%
*-commutative74.6%
unpow274.6%
hypot-1-def93.0%
*-commutative93.0%
associate-*l*93.0%
Simplified93.0%
Taylor expanded in J around 0 32.2%
neg-mul-132.2%
Simplified32.2%
Final simplification37.2%
(FPCore (J K U) :precision binary64 (if (<= U -6.4e-11) (- (* -2.0 (/ J (/ U J))) U) (if (<= U 2e-62) (* J -2.0) (if (<= U 5e+234) U (- U)))))
double code(double J, double K, double U) {
double tmp;
if (U <= -6.4e-11) {
tmp = (-2.0 * (J / (U / J))) - U;
} else if (U <= 2e-62) {
tmp = J * -2.0;
} else if (U <= 5e+234) {
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 <= (-6.4d-11)) then
tmp = ((-2.0d0) * (j / (u / j))) - u
else if (u <= 2d-62) then
tmp = j * (-2.0d0)
else if (u <= 5d+234) 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 <= -6.4e-11) {
tmp = (-2.0 * (J / (U / J))) - U;
} else if (U <= 2e-62) {
tmp = J * -2.0;
} else if (U <= 5e+234) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if U <= -6.4e-11: tmp = (-2.0 * (J / (U / J))) - U elif U <= 2e-62: tmp = J * -2.0 elif U <= 5e+234: tmp = U else: tmp = -U return tmp
function code(J, K, U) tmp = 0.0 if (U <= -6.4e-11) tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / J))) - U); elseif (U <= 2e-62) tmp = Float64(J * -2.0); elseif (U <= 5e+234) tmp = U; else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= -6.4e-11) tmp = (-2.0 * (J / (U / J))) - U; elseif (U <= 2e-62) tmp = J * -2.0; elseif (U <= 5e+234) tmp = U; else tmp = -U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[U, -6.4e-11], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[LessEqual[U, 2e-62], N[(J * -2.0), $MachinePrecision], If[LessEqual[U, 5e+234], U, (-U)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -6.4 \cdot 10^{-11}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\
\mathbf{elif}\;U \leq 2 \cdot 10^{-62}:\\
\;\;\;\;J \cdot -2\\
\mathbf{elif}\;U \leq 5 \cdot 10^{+234}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < -6.39999999999999987e-11Initial program 57.9%
*-commutative57.9%
associate-*l*57.9%
associate-*r*57.9%
*-commutative57.9%
associate-*l*57.8%
*-commutative57.8%
unpow257.8%
hypot-1-def85.9%
*-commutative85.9%
associate-*l*85.9%
Simplified85.9%
Taylor expanded in J around 0 37.5%
neg-mul-137.5%
unsub-neg37.5%
associate-/l*37.5%
associate-*r/37.5%
unpow237.5%
Simplified37.5%
Taylor expanded in K around 0 37.5%
unpow237.5%
associate-/l*43.2%
Simplified43.2%
if -6.39999999999999987e-11 < U < 2.0000000000000001e-62Initial program 97.6%
*-commutative97.6%
associate-*l*97.6%
associate-*r*97.6%
*-commutative97.6%
associate-*l*97.5%
*-commutative97.5%
unpow297.5%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in K around 0 45.6%
associate-*r*45.6%
unpow245.6%
unpow245.6%
Simplified45.6%
Taylor expanded in U around 0 47.1%
if 2.0000000000000001e-62 < U < 5.0000000000000003e234Initial program 55.8%
*-commutative55.8%
associate-*l*55.8%
associate-*r*55.8%
*-commutative55.8%
associate-*l*55.7%
*-commutative55.7%
unpow255.7%
hypot-1-def84.2%
*-commutative84.2%
associate-*l*84.2%
Simplified84.2%
Taylor expanded in U around -inf 50.8%
if 5.0000000000000003e234 < U Initial program 49.3%
*-commutative49.3%
associate-*l*49.3%
associate-*r*49.3%
*-commutative49.3%
associate-*l*49.3%
*-commutative49.3%
unpow249.3%
hypot-1-def79.9%
*-commutative79.9%
associate-*l*79.9%
Simplified79.9%
Taylor expanded in J around 0 77.8%
neg-mul-177.8%
Simplified77.8%
Final simplification47.9%
(FPCore (J K U) :precision binary64 (if (<= U -9.5e-23) (- U) (if (<= U 2.8e-62) (* J -2.0) (if (<= U 2e+239) U (- U)))))
double code(double J, double K, double U) {
double tmp;
if (U <= -9.5e-23) {
tmp = -U;
} else if (U <= 2.8e-62) {
tmp = J * -2.0;
} else if (U <= 2e+239) {
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 <= (-9.5d-23)) then
tmp = -u
else if (u <= 2.8d-62) then
tmp = j * (-2.0d0)
else if (u <= 2d+239) 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 <= -9.5e-23) {
tmp = -U;
} else if (U <= 2.8e-62) {
tmp = J * -2.0;
} else if (U <= 2e+239) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if U <= -9.5e-23: tmp = -U elif U <= 2.8e-62: tmp = J * -2.0 elif U <= 2e+239: tmp = U else: tmp = -U return tmp
function code(J, K, U) tmp = 0.0 if (U <= -9.5e-23) tmp = Float64(-U); elseif (U <= 2.8e-62) tmp = Float64(J * -2.0); elseif (U <= 2e+239) tmp = U; else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= -9.5e-23) tmp = -U; elseif (U <= 2.8e-62) tmp = J * -2.0; elseif (U <= 2e+239) tmp = U; else tmp = -U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[U, -9.5e-23], (-U), If[LessEqual[U, 2.8e-62], N[(J * -2.0), $MachinePrecision], If[LessEqual[U, 2e+239], U, (-U)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -9.5 \cdot 10^{-23}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq 2.8 \cdot 10^{-62}:\\
\;\;\;\;J \cdot -2\\
\mathbf{elif}\;U \leq 2 \cdot 10^{+239}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < -9.50000000000000058e-23 or 1.99999999999999998e239 < U Initial program 57.4%
*-commutative57.4%
associate-*l*57.4%
associate-*r*57.4%
*-commutative57.4%
associate-*l*57.3%
*-commutative57.3%
unpow257.3%
hypot-1-def85.3%
*-commutative85.3%
associate-*l*85.3%
Simplified85.3%
Taylor expanded in J around 0 46.7%
neg-mul-146.7%
Simplified46.7%
if -9.50000000000000058e-23 < U < 2.80000000000000002e-62Initial program 97.6%
*-commutative97.6%
associate-*l*97.6%
associate-*r*97.6%
*-commutative97.6%
associate-*l*97.4%
*-commutative97.4%
unpow297.4%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in K around 0 45.9%
associate-*r*45.9%
unpow245.9%
unpow245.9%
Simplified45.9%
Taylor expanded in U around 0 47.5%
if 2.80000000000000002e-62 < U < 1.99999999999999998e239Initial program 55.8%
*-commutative55.8%
associate-*l*55.8%
associate-*r*55.8%
*-commutative55.8%
associate-*l*55.7%
*-commutative55.7%
unpow255.7%
hypot-1-def84.2%
*-commutative84.2%
associate-*l*84.2%
Simplified84.2%
Taylor expanded in U around -inf 50.8%
Final simplification47.9%
(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}
Initial program 77.3%
*-commutative77.3%
associate-*l*77.3%
associate-*r*77.3%
*-commutative77.3%
associate-*l*77.2%
*-commutative77.2%
unpow277.2%
hypot-1-def92.4%
*-commutative92.4%
associate-*l*92.4%
Simplified92.4%
Taylor expanded in U around -inf 29.0%
Final simplification29.0%
herbie shell --seed 2023182
(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)))))