
(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 8 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}
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY))
(- U)
(if (<= t_1 1e+308)
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ U (* J (* 2.0 t_0)))))
U))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U;
} else if (t_1 <= 1e+308) {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U;
} else if (t_1 <= 1e+308) {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U elif t_1 <= 1e+308: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0)))) else: tmp = U return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U); elseif (t_1 <= 1e+308) tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U; elseif (t_1 <= 1e+308) tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0)))); else tmp = U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U), If[LessEqual[t$95$1, 1e+308], 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], U]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-U\\
\mathbf{elif}\;t_1 \leq 10^{+308}:\\
\;\;\;\;\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)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < -inf.0Initial program 5.1%
*-commutative5.1%
associate-*l*5.1%
unpow25.1%
hypot-1-def51.9%
*-commutative51.9%
associate-*l*51.9%
Simplified51.9%
Taylor expanded in J around 0 59.3%
neg-mul-159.3%
Simplified59.3%
if -inf.0 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < 1e308Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if 1e308 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) Initial program 5.2%
*-commutative5.2%
associate-*l*5.2%
unpow25.2%
hypot-1-def62.9%
*-commutative62.9%
associate-*l*62.9%
Simplified62.9%
Taylor expanded in U around -inf 68.9%
Final simplification89.4%
NOTE: U should be positive before calling this function
(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-172)
t_0
(if (<= J -6.7e-295)
U
(if (<= J 4.2e-73) (- (* -2.0 (/ J (/ U J))) U) t_0)))))U = abs(U);
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-172) {
tmp = t_0;
} else if (J <= -6.7e-295) {
tmp = U;
} else if (J <= 4.2e-73) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = Math.abs(U);
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-172) {
tmp = t_0;
} else if (J <= -6.7e-295) {
tmp = U;
} else if (J <= 4.2e-73) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) 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-172: tmp = t_0 elif J <= -6.7e-295: tmp = U elif J <= 4.2e-73: tmp = (-2.0 * (J / (U / J))) - U else: tmp = t_0 return tmp
U = abs(U) 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-172) tmp = t_0; elseif (J <= -6.7e-295) tmp = U; elseif (J <= 4.2e-73) tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / J))) - U); else tmp = t_0; end return tmp end
U = abs(U) 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-172) tmp = t_0; elseif (J <= -6.7e-295) tmp = U; elseif (J <= 4.2e-73) tmp = (-2.0 * (J / (U / J))) - U; else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(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-172], t$95$0, If[LessEqual[J, -6.7e-295], U, If[LessEqual[J, 4.2e-73], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\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^{-172}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -6.7 \cdot 10^{-295}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 4.2 \cdot 10^{-73}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -5.1999999999999996e-172 or 4.1999999999999997e-73 < J Initial program 89.8%
*-commutative89.8%
associate-*l*89.8%
unpow289.8%
hypot-1-def97.7%
*-commutative97.7%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in K around 0 88.3%
if -5.1999999999999996e-172 < J < -6.70000000000000034e-295Initial program 31.4%
*-commutative31.4%
associate-*l*31.4%
unpow231.4%
hypot-1-def66.3%
*-commutative66.3%
associate-*l*66.3%
Simplified66.3%
Taylor expanded in U around -inf 61.0%
if -6.70000000000000034e-295 < J < 4.1999999999999997e-73Initial program 40.7%
*-commutative40.7%
associate-*l*40.7%
unpow240.7%
hypot-1-def67.6%
*-commutative67.6%
associate-*l*67.6%
Simplified67.6%
Taylor expanded in K around 0 45.7%
Taylor expanded in K around 0 48.4%
Taylor expanded in J around 0 50.4%
fma-def50.4%
unpow250.4%
associate-/l*50.4%
neg-mul-150.4%
fma-neg50.4%
Simplified50.4%
Final simplification76.6%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (* -2.0 J) (cos (* K 0.5)))))
(if (<= J -2.4e+16)
t_0
(if (<= J -0.007)
U
(if (<= J -2.2e-153)
t_0
(if (<= J -6.7e-295)
U
(if (<= J 5.8e-36) (- (* -2.0 (/ J (/ U J))) U) t_0)))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = (-2.0 * J) * cos((K * 0.5));
double tmp;
if (J <= -2.4e+16) {
tmp = t_0;
} else if (J <= -0.007) {
tmp = U;
} else if (J <= -2.2e-153) {
tmp = t_0;
} else if (J <= -6.7e-295) {
tmp = U;
} else if (J <= 5.8e-36) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = ((-2.0d0) * j) * cos((k * 0.5d0))
if (j <= (-2.4d+16)) then
tmp = t_0
else if (j <= (-0.007d0)) then
tmp = u
else if (j <= (-2.2d-153)) then
tmp = t_0
else if (j <= (-6.7d-295)) then
tmp = u
else if (j <= 5.8d-36) then
tmp = ((-2.0d0) * (j / (u / j))) - u
else
tmp = t_0
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = (-2.0 * J) * Math.cos((K * 0.5));
double tmp;
if (J <= -2.4e+16) {
tmp = t_0;
} else if (J <= -0.007) {
tmp = U;
} else if (J <= -2.2e-153) {
tmp = t_0;
} else if (J <= -6.7e-295) {
tmp = U;
} else if (J <= 5.8e-36) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = (-2.0 * J) * math.cos((K * 0.5)) tmp = 0 if J <= -2.4e+16: tmp = t_0 elif J <= -0.007: tmp = U elif J <= -2.2e-153: tmp = t_0 elif J <= -6.7e-295: tmp = U elif J <= 5.8e-36: tmp = (-2.0 * (J / (U / J))) - U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) tmp = 0.0 if (J <= -2.4e+16) tmp = t_0; elseif (J <= -0.007) tmp = U; elseif (J <= -2.2e-153) tmp = t_0; elseif (J <= -6.7e-295) tmp = U; elseif (J <= 5.8e-36) tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / J))) - U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = (-2.0 * J) * cos((K * 0.5)); tmp = 0.0; if (J <= -2.4e+16) tmp = t_0; elseif (J <= -0.007) tmp = U; elseif (J <= -2.2e-153) tmp = t_0; elseif (J <= -6.7e-295) tmp = U; elseif (J <= 5.8e-36) tmp = (-2.0 * (J / (U / J))) - U; else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -2.4e+16], t$95$0, If[LessEqual[J, -0.007], U, If[LessEqual[J, -2.2e-153], t$95$0, If[LessEqual[J, -6.7e-295], U, If[LessEqual[J, 5.8e-36], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq -2.4 \cdot 10^{+16}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -0.007:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq -2.2 \cdot 10^{-153}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -6.7 \cdot 10^{-295}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 5.8 \cdot 10^{-36}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -2.4e16 or -0.00700000000000000015 < J < -2.20000000000000001e-153 or 5.80000000000000026e-36 < J Initial program 91.9%
*-commutative91.9%
associate-*l*91.9%
unpow291.9%
hypot-1-def98.6%
*-commutative98.6%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in J around inf 78.8%
associate-*r*78.8%
*-commutative78.8%
*-commutative78.8%
associate-*r*78.8%
*-commutative78.8%
Simplified78.8%
if -2.4e16 < J < -0.00700000000000000015 or -2.20000000000000001e-153 < J < -6.70000000000000034e-295Initial program 39.4%
*-commutative39.4%
associate-*l*39.4%
unpow239.4%
hypot-1-def74.4%
*-commutative74.4%
associate-*l*74.4%
Simplified74.4%
Taylor expanded in U around -inf 64.5%
if -6.70000000000000034e-295 < J < 5.80000000000000026e-36Initial program 44.8%
*-commutative44.8%
associate-*l*44.8%
unpow244.8%
hypot-1-def68.6%
*-commutative68.6%
associate-*l*68.6%
Simplified68.6%
Taylor expanded in K around 0 48.1%
Taylor expanded in K around 0 48.0%
Taylor expanded in J around 0 49.1%
fma-def49.1%
unpow249.1%
associate-/l*49.1%
neg-mul-149.1%
fma-neg49.1%
Simplified49.1%
Final simplification68.9%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= K 0.0078) (* (* -2.0 J) (hypot 1.0 (/ U (* J 2.0)))) (* (* -2.0 J) (cos (* K 0.5)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (K <= 0.0078) {
tmp = (-2.0 * J) * hypot(1.0, (U / (J * 2.0)));
} else {
tmp = (-2.0 * J) * cos((K * 0.5));
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (K <= 0.0078) {
tmp = (-2.0 * J) * Math.hypot(1.0, (U / (J * 2.0)));
} else {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if K <= 0.0078: tmp = (-2.0 * J) * math.hypot(1.0, (U / (J * 2.0))) else: tmp = (-2.0 * J) * math.cos((K * 0.5)) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (K <= 0.0078) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(U / Float64(J * 2.0)))); else tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (K <= 0.0078) tmp = (-2.0 * J) * hypot(1.0, (U / (J * 2.0))); else tmp = (-2.0 * J) * cos((K * 0.5)); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[K, 0.0078], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;K \leq 0.0078:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\end{array}
\end{array}
if K < 0.0077999999999999996Initial program 71.8%
*-commutative71.8%
associate-*l*71.8%
unpow271.8%
hypot-1-def88.0%
*-commutative88.0%
associate-*l*88.0%
Simplified88.0%
Taylor expanded in K around 0 79.6%
Taylor expanded in K around 0 67.2%
if 0.0077999999999999996 < K Initial program 74.1%
*-commutative74.1%
associate-*l*74.1%
unpow274.1%
hypot-1-def85.7%
*-commutative85.7%
associate-*l*85.7%
Simplified85.7%
Taylor expanded in J around inf 53.6%
associate-*r*53.6%
*-commutative53.6%
*-commutative53.6%
associate-*r*53.6%
*-commutative53.6%
Simplified53.6%
Final simplification63.7%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= J -2.6e+16)
(* -2.0 J)
(if (<= J -6.7e-295)
U
(if (<= J 7e+45) (- (* -2.0 (/ J (/ U J))) U) (* -2.0 J)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2.6e+16) {
tmp = -2.0 * J;
} else if (J <= -6.7e-295) {
tmp = U;
} else if (J <= 7e+45) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-2.6d+16)) then
tmp = (-2.0d0) * j
else if (j <= (-6.7d-295)) then
tmp = u
else if (j <= 7d+45) then
tmp = ((-2.0d0) * (j / (u / j))) - u
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -2.6e+16) {
tmp = -2.0 * J;
} else if (J <= -6.7e-295) {
tmp = U;
} else if (J <= 7e+45) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2.6e+16: tmp = -2.0 * J elif J <= -6.7e-295: tmp = U elif J <= 7e+45: tmp = (-2.0 * (J / (U / J))) - U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2.6e+16) tmp = Float64(-2.0 * J); elseif (J <= -6.7e-295) tmp = U; elseif (J <= 7e+45) tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / J))) - U); else tmp = Float64(-2.0 * J); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -2.6e+16) tmp = -2.0 * J; elseif (J <= -6.7e-295) tmp = U; elseif (J <= 7e+45) tmp = (-2.0 * (J / (U / J))) - U; else tmp = -2.0 * J; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -2.6e+16], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -6.7e-295], U, If[LessEqual[J, 7e+45], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.6 \cdot 10^{+16}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -6.7 \cdot 10^{-295}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 7 \cdot 10^{+45}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -2.6e16 or 7.00000000000000046e45 < J Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 45.5%
*-commutative45.5%
unpow245.5%
unpow245.5%
Simplified45.5%
Taylor expanded in J around inf 47.7%
if -2.6e16 < J < -6.70000000000000034e-295Initial program 54.0%
*-commutative54.0%
associate-*l*54.0%
unpow254.0%
hypot-1-def84.0%
*-commutative84.0%
associate-*l*84.0%
Simplified84.0%
Taylor expanded in U around -inf 50.0%
if -6.70000000000000034e-295 < J < 7.00000000000000046e45Initial program 52.9%
*-commutative52.9%
associate-*l*52.9%
unpow252.9%
hypot-1-def75.0%
*-commutative75.0%
associate-*l*75.0%
Simplified75.0%
Taylor expanded in K around 0 53.4%
Taylor expanded in K around 0 52.4%
Taylor expanded in J around 0 44.1%
fma-def44.1%
unpow244.1%
associate-/l*44.0%
neg-mul-144.0%
fma-neg44.0%
Simplified44.0%
Final simplification47.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2.5e+16) (* -2.0 J) (if (<= J -6.7e-295) U (if (<= J 2.15e+46) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2.5e+16) {
tmp = -2.0 * J;
} else if (J <= -6.7e-295) {
tmp = U;
} else if (J <= 2.15e+46) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-2.5d+16)) then
tmp = (-2.0d0) * j
else if (j <= (-6.7d-295)) then
tmp = u
else if (j <= 2.15d+46) then
tmp = -u
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -2.5e+16) {
tmp = -2.0 * J;
} else if (J <= -6.7e-295) {
tmp = U;
} else if (J <= 2.15e+46) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2.5e+16: tmp = -2.0 * J elif J <= -6.7e-295: tmp = U elif J <= 2.15e+46: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2.5e+16) tmp = Float64(-2.0 * J); elseif (J <= -6.7e-295) tmp = U; elseif (J <= 2.15e+46) tmp = Float64(-U); else tmp = Float64(-2.0 * J); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -2.5e+16) tmp = -2.0 * J; elseif (J <= -6.7e-295) tmp = U; elseif (J <= 2.15e+46) tmp = -U; else tmp = -2.0 * J; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -2.5e+16], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -6.7e-295], U, If[LessEqual[J, 2.15e+46], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.5 \cdot 10^{+16}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -6.7 \cdot 10^{-295}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2.15 \cdot 10^{+46}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -2.5e16 or 2.15000000000000002e46 < J Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 45.5%
*-commutative45.5%
unpow245.5%
unpow245.5%
Simplified45.5%
Taylor expanded in J around inf 47.7%
if -2.5e16 < J < -6.70000000000000034e-295Initial program 54.0%
*-commutative54.0%
associate-*l*54.0%
unpow254.0%
hypot-1-def84.0%
*-commutative84.0%
associate-*l*84.0%
Simplified84.0%
Taylor expanded in U around -inf 50.0%
if -6.70000000000000034e-295 < J < 2.15000000000000002e46Initial program 52.9%
*-commutative52.9%
associate-*l*52.9%
unpow252.9%
hypot-1-def75.0%
*-commutative75.0%
associate-*l*75.0%
Simplified75.0%
Taylor expanded in J around 0 44.1%
neg-mul-144.1%
Simplified44.1%
Final simplification47.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -1.35e-294) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.35e-294) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-1.35d-294)) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -1.35e-294) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.35e-294: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.35e-294) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -1.35e-294) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -1.35e-294], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.35 \cdot 10^{-294}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -1.35000000000000005e-294Initial program 72.2%
*-commutative72.2%
associate-*l*72.2%
unpow272.2%
hypot-1-def90.3%
*-commutative90.3%
associate-*l*90.3%
Simplified90.3%
Taylor expanded in U around -inf 32.2%
if -1.35000000000000005e-294 < J Initial program 72.6%
*-commutative72.6%
associate-*l*72.6%
unpow272.6%
hypot-1-def85.4%
*-commutative85.4%
associate-*l*85.4%
Simplified85.4%
Taylor expanded in J around 0 28.8%
neg-mul-128.8%
Simplified28.8%
Final simplification30.2%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 U)
U = abs(U);
double code(double J, double K, double U) {
return U;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
return U;
}
U = abs(U) def code(J, K, U): return U
U = abs(U) function code(J, K, U) return U end
U = abs(U) function tmp = code(J, K, U) tmp = U; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := U
\begin{array}{l}
U = |U|\\
\\
U
\end{array}
Initial program 72.4%
*-commutative72.4%
associate-*l*72.4%
unpow272.4%
hypot-1-def87.4%
*-commutative87.4%
associate-*l*87.4%
Simplified87.4%
Taylor expanded in U around -inf 28.4%
Final simplification28.4%
herbie shell --seed 2023243
(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)))))