
(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 5e+306)
(* (* 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 <= 5e+306) {
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 <= 5e+306) {
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 <= 5e+306: 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 <= 5e+306) 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 <= 5e+306) 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, 5e+306], 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 5 \cdot 10^{+306}:\\
\;\;\;\;\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.6%
*-commutative5.6%
associate-*l*5.6%
associate-*r*5.6%
*-commutative5.6%
associate-*l*5.6%
*-commutative5.6%
unpow25.6%
hypot-1-def58.9%
*-commutative58.9%
associate-*l*58.9%
Simplified58.9%
Taylor expanded in J around 0 47.2%
neg-mul-147.2%
Simplified47.2%
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)))) < 4.99999999999999993e306Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if 4.99999999999999993e306 < (*.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.1%
*-commutative5.1%
associate-*l*5.1%
associate-*r*5.1%
*-commutative5.1%
associate-*l*5.1%
*-commutative5.1%
unpow25.1%
hypot-1-def77.7%
*-commutative77.7%
associate-*l*77.7%
Simplified77.7%
Taylor expanded in U around -inf 50.4%
Final simplification86.6%
NOTE: U should be positive before calling this function (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)))))))))
U = abs(U);
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))))));
}
U = Math.abs(U);
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))))));
}
U = abs(U) 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))))))
U = abs(U) 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
U = abs(U) 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
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(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}
U = |U|\\
\\
\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 75.4%
*-commutative75.4%
associate-*l*75.4%
associate-*r*75.4%
*-commutative75.4%
associate-*l*75.4%
*-commutative75.4%
unpow275.4%
hypot-1-def91.7%
*-commutative91.7%
associate-*l*91.7%
Simplified91.7%
Final simplification91.7%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (or (<= J -9e-229) (not (<= J 4.8e-153))) (* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (/ U (* J 2.0)))) (fma (/ J (/ U J)) -2.0 (- U))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if ((J <= -9e-229) || !(J <= 4.8e-153)) {
tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0)));
} else {
tmp = fma((J / (U / J)), -2.0, -U);
}
return tmp;
}
U = abs(U) function code(J, K, U) tmp = 0.0 if ((J <= -9e-229) || !(J <= 4.8e-153)) tmp = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(U / Float64(J * 2.0)))); else tmp = fma(Float64(J / Float64(U / J)), -2.0, Float64(-U)); end return tmp end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[Or[LessEqual[J, -9e-229], N[Not[LessEqual[J, 4.8e-153]], $MachinePrecision]], 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], N[(N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision] * -2.0 + (-U)), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -9 \cdot 10^{-229} \lor \neg \left(J \leq 4.8 \cdot 10^{-153}\right):\\
\;\;\;\;\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{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{J}{\frac{U}{J}}, -2, -U\right)\\
\end{array}
\end{array}
if J < -9.0000000000000004e-229 or 4.8000000000000004e-153 < J Initial program 81.6%
*-commutative81.6%
associate-*l*81.6%
unpow281.6%
hypot-1-def97.6%
*-commutative97.6%
associate-*l*97.6%
Simplified97.6%
Taylor expanded in K around 0 81.0%
if -9.0000000000000004e-229 < J < 4.8000000000000004e-153Initial program 44.7%
*-commutative44.7%
associate-*l*44.7%
associate-*r*44.7%
*-commutative44.7%
associate-*l*44.6%
*-commutative44.6%
unpow244.6%
hypot-1-def62.6%
*-commutative62.6%
associate-*l*62.6%
Simplified62.6%
Taylor expanded in K around 0 4.5%
associate-*r*4.5%
unpow24.5%
unpow24.5%
Simplified4.5%
Taylor expanded in U around inf 43.2%
Taylor expanded in J around 0 58.5%
*-commutative58.5%
fma-def58.5%
unpow258.5%
associate-/l*58.8%
neg-mul-158.8%
Simplified58.8%
Final simplification77.2%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -2.8e-25)
t_0
(if (<= J -3.8e-220)
U
(if (<= J 2e-134) (fma (/ J (/ U J)) -2.0 (- U)) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -2.8e-25) {
tmp = t_0;
} else if (J <= -3.8e-220) {
tmp = U;
} else if (J <= 2e-134) {
tmp = fma((J / (U / J)), -2.0, -U);
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -2.8e-25) tmp = t_0; elseif (J <= -3.8e-220) tmp = U; elseif (J <= 2e-134) tmp = fma(Float64(J / Float64(U / J)), -2.0, Float64(-U)); else tmp = t_0; end return tmp end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -2.8e-25], t$95$0, If[LessEqual[J, -3.8e-220], U, If[LessEqual[J, 2e-134], N[(N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision] * -2.0 + (-U)), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -2.8 \cdot 10^{-25}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -3.8 \cdot 10^{-220}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2 \cdot 10^{-134}:\\
\;\;\;\;\mathsf{fma}\left(\frac{J}{\frac{U}{J}}, -2, -U\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -2.79999999999999988e-25 or 2.00000000000000008e-134 < J Initial program 89.2%
*-commutative89.2%
associate-*l*89.2%
associate-*r*89.2%
*-commutative89.2%
associate-*l*89.2%
*-commutative89.2%
unpow289.2%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in U around 0 71.5%
if -2.79999999999999988e-25 < J < -3.80000000000000009e-220Initial program 58.2%
*-commutative58.2%
associate-*l*58.2%
associate-*r*58.2%
*-commutative58.2%
associate-*l*58.2%
*-commutative58.2%
unpow258.2%
hypot-1-def90.6%
*-commutative90.6%
associate-*l*90.6%
Simplified90.6%
Taylor expanded in U around -inf 39.7%
if -3.80000000000000009e-220 < J < 2.00000000000000008e-134Initial program 46.2%
*-commutative46.2%
associate-*l*46.2%
associate-*r*46.2%
*-commutative46.2%
associate-*l*46.1%
*-commutative46.1%
unpow246.1%
hypot-1-def65.0%
*-commutative65.0%
associate-*l*65.0%
Simplified65.0%
Taylor expanded in K around 0 6.5%
associate-*r*6.5%
unpow26.5%
unpow26.5%
Simplified6.5%
Taylor expanded in U around inf 40.6%
Taylor expanded in J around 0 54.9%
*-commutative54.9%
fma-def54.9%
unpow254.9%
associate-/l*55.2%
neg-mul-155.2%
Simplified55.2%
Final simplification62.4%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -3.8e-25)
t_0
(if (<= J -4.6e-220) U (if (<= J 8.4e-135) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -3.8e-25) {
tmp = t_0;
} else if (J <= -4.6e-220) {
tmp = U;
} else if (J <= 8.4e-135) {
tmp = -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 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-3.8d-25)) then
tmp = t_0
else if (j <= (-4.6d-220)) then
tmp = u
else if (j <= 8.4d-135) then
tmp = -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 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (J <= -3.8e-25) {
tmp = t_0;
} else if (J <= -4.6e-220) {
tmp = U;
} else if (J <= 8.4e-135) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -3.8e-25: tmp = t_0 elif J <= -4.6e-220: tmp = U elif J <= 8.4e-135: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -3.8e-25) tmp = t_0; elseif (J <= -4.6e-220) tmp = U; elseif (J <= 8.4e-135) tmp = Float64(-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 * 0.5))); tmp = 0.0; if (J <= -3.8e-25) tmp = t_0; elseif (J <= -4.6e-220) tmp = U; elseif (J <= 8.4e-135) tmp = -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[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -3.8e-25], t$95$0, If[LessEqual[J, -4.6e-220], U, If[LessEqual[J, 8.4e-135], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -3.8 \cdot 10^{-25}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4.6 \cdot 10^{-220}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 8.4 \cdot 10^{-135}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -3.7999999999999998e-25 or 8.4000000000000001e-135 < J Initial program 89.2%
*-commutative89.2%
associate-*l*89.2%
associate-*r*89.2%
*-commutative89.2%
associate-*l*89.2%
*-commutative89.2%
unpow289.2%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in U around 0 71.5%
if -3.7999999999999998e-25 < J < -4.59999999999999961e-220Initial program 58.2%
*-commutative58.2%
associate-*l*58.2%
associate-*r*58.2%
*-commutative58.2%
associate-*l*58.2%
*-commutative58.2%
unpow258.2%
hypot-1-def90.6%
*-commutative90.6%
associate-*l*90.6%
Simplified90.6%
Taylor expanded in U around -inf 39.7%
if -4.59999999999999961e-220 < J < 8.4000000000000001e-135Initial program 46.2%
*-commutative46.2%
associate-*l*46.2%
associate-*r*46.2%
*-commutative46.2%
associate-*l*46.1%
*-commutative46.1%
unpow246.1%
hypot-1-def65.0%
*-commutative65.0%
associate-*l*65.0%
Simplified65.0%
Taylor expanded in J around 0 54.9%
neg-mul-154.9%
Simplified54.9%
Final simplification62.3%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -8e+128) (* -2.0 J) (if (<= J -3.8e-220) U (if (<= J 1.45e+34) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -8e+128) {
tmp = -2.0 * J;
} else if (J <= -3.8e-220) {
tmp = U;
} else if (J <= 1.45e+34) {
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 <= (-8d+128)) then
tmp = (-2.0d0) * j
else if (j <= (-3.8d-220)) then
tmp = u
else if (j <= 1.45d+34) 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 <= -8e+128) {
tmp = -2.0 * J;
} else if (J <= -3.8e-220) {
tmp = U;
} else if (J <= 1.45e+34) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -8e+128: tmp = -2.0 * J elif J <= -3.8e-220: tmp = U elif J <= 1.45e+34: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -8e+128) tmp = Float64(-2.0 * J); elseif (J <= -3.8e-220) tmp = U; elseif (J <= 1.45e+34) 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 <= -8e+128) tmp = -2.0 * J; elseif (J <= -3.8e-220) tmp = U; elseif (J <= 1.45e+34) 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, -8e+128], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -3.8e-220], U, If[LessEqual[J, 1.45e+34], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -8 \cdot 10^{+128}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -3.8 \cdot 10^{-220}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.45 \cdot 10^{+34}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -8.0000000000000006e128 or 1.4500000000000001e34 < J Initial program 97.8%
*-commutative97.8%
associate-*l*97.8%
associate-*r*97.8%
*-commutative97.8%
associate-*l*97.8%
*-commutative97.8%
unpow297.8%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in K around 0 42.8%
associate-*r*42.8%
unpow242.8%
unpow242.8%
Simplified42.8%
Taylor expanded in U around 0 45.2%
if -8.0000000000000006e128 < J < -3.80000000000000009e-220Initial program 68.8%
*-commutative68.8%
associate-*l*68.8%
associate-*r*68.8%
*-commutative68.8%
associate-*l*68.7%
*-commutative68.7%
unpow268.7%
hypot-1-def93.9%
*-commutative93.9%
associate-*l*93.9%
Simplified93.9%
Taylor expanded in U around -inf 32.1%
if -3.80000000000000009e-220 < J < 1.4500000000000001e34Initial program 56.9%
*-commutative56.9%
associate-*l*56.9%
associate-*r*56.9%
*-commutative56.9%
associate-*l*56.9%
*-commutative56.9%
unpow256.9%
hypot-1-def80.7%
*-commutative80.7%
associate-*l*80.7%
Simplified80.7%
Taylor expanded in J around 0 41.9%
neg-mul-141.9%
Simplified41.9%
Final simplification40.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -5.5e-220) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -5.5e-220) {
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 <= (-5.5d-220)) 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 <= -5.5e-220) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -5.5e-220: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -5.5e-220) 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 <= -5.5e-220) 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, -5.5e-220], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -5.5 \cdot 10^{-220}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -5.4999999999999999e-220Initial program 79.2%
*-commutative79.2%
associate-*l*79.2%
associate-*r*79.2%
*-commutative79.2%
associate-*l*79.2%
*-commutative79.2%
unpow279.2%
hypot-1-def95.9%
*-commutative95.9%
associate-*l*95.9%
Simplified95.9%
Taylor expanded in U around -inf 22.9%
if -5.4999999999999999e-220 < J Initial program 72.1%
*-commutative72.1%
associate-*l*72.1%
associate-*r*72.1%
*-commutative72.1%
associate-*l*72.1%
*-commutative72.1%
unpow272.1%
hypot-1-def88.0%
*-commutative88.0%
associate-*l*88.0%
Simplified88.0%
Taylor expanded in J around 0 27.1%
neg-mul-127.1%
Simplified27.1%
Final simplification25.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 75.4%
*-commutative75.4%
associate-*l*75.4%
associate-*r*75.4%
*-commutative75.4%
associate-*l*75.4%
*-commutative75.4%
unpow275.4%
hypot-1-def91.7%
*-commutative91.7%
associate-*l*91.7%
Simplified91.7%
Taylor expanded in U around -inf 26.7%
Final simplification26.7%
herbie shell --seed 2023229
(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)))))