
(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 10 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}
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* t_0 (* -2.0 J))
(sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY)) (- U_m) (if (<= t_1 2e+305) t_1 U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = (t_0 * (-2.0 * J)) * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_1 <= 2e+305) {
tmp = t_1;
} else {
tmp = U_m;
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
double t_1 = (t_0 * (-2.0 * J)) * Math.sqrt((1.0 + Math.pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U_m;
} else if (t_1 <= 2e+305) {
tmp = t_1;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = (t_0 * (-2.0 * J)) * math.sqrt((1.0 + math.pow((U_m / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U_m elif t_1 <= 2e+305: tmp = t_1 else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(t_0 * Float64(-2.0 * J)) * sqrt(Float64(1.0 + (Float64(U_m / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_1 <= 2e+305) tmp = t_1; else tmp = U_m; end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); t_1 = (t_0 * (-2.0 * J)) * sqrt((1.0 + ((U_m / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U_m; elseif (t_1 <= 2e+305) tmp = t_1; else tmp = U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U$95$m / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U$95$m), If[LessEqual[t$95$1, 2e+305], t$95$1, U$95$m]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(t\_0 \cdot \left(-2 \cdot J\right)\right) \cdot \sqrt{1 + {\left(\frac{U\_m}{t\_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < -inf.0Initial program 5.2%
Simplified58.5%
Taylor expanded in J around 0 50.4%
neg-mul-150.4%
Simplified50.4%
if -inf.0 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < 1.9999999999999999e305Initial program 99.7%
if 1.9999999999999999e305 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) Initial program 5.2%
Simplified66.5%
Taylor expanded in U around -inf 47.0%
Final simplification87.8%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (* J (cos (* K 0.5)))))
(if (<= J 6.6e-248)
(- (* -2.0 (* t_1 (/ t_1 U_m))) U_m)
(* J (* (* -2.0 t_0) (hypot 1.0 (/ (/ U_m 2.0) (* J t_0))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = J * cos((K * 0.5));
double tmp;
if (J <= 6.6e-248) {
tmp = (-2.0 * (t_1 * (t_1 / U_m))) - U_m;
} else {
tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J * t_0))));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
double t_1 = J * Math.cos((K * 0.5));
double tmp;
if (J <= 6.6e-248) {
tmp = (-2.0 * (t_1 * (t_1 / U_m))) - U_m;
} else {
tmp = J * ((-2.0 * t_0) * Math.hypot(1.0, ((U_m / 2.0) / (J * t_0))));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = J * math.cos((K * 0.5)) tmp = 0 if J <= 6.6e-248: tmp = (-2.0 * (t_1 * (t_1 / U_m))) - U_m else: tmp = J * ((-2.0 * t_0) * math.hypot(1.0, ((U_m / 2.0) / (J * t_0)))) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(J * cos(Float64(K * 0.5))) tmp = 0.0 if (J <= 6.6e-248) tmp = Float64(Float64(-2.0 * Float64(t_1 * Float64(t_1 / U_m))) - U_m); else tmp = Float64(J * Float64(Float64(-2.0 * t_0) * hypot(1.0, Float64(Float64(U_m / 2.0) / Float64(J * t_0))))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); t_1 = J * cos((K * 0.5)); tmp = 0.0; if (J <= 6.6e-248) tmp = (-2.0 * (t_1 * (t_1 / U_m))) - U_m; else tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J * t_0)))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, 6.6e-248], N[(N[(-2.0 * N[(t$95$1 * N[(t$95$1 / U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U$95$m), $MachinePrecision], N[(J * N[(N[(-2.0 * t$95$0), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / N[(J * t$95$0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := J \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq 6.6 \cdot 10^{-248}:\\
\;\;\;\;-2 \cdot \left(t\_1 \cdot \frac{t\_1}{U\_m}\right) - U\_m\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot t\_0\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J \cdot t\_0}\right)\right)\\
\end{array}
\end{array}
if J < 6.6000000000000004e-248Initial program 78.4%
unpow278.4%
hypot-1-def88.9%
associate-/r*88.8%
cos-neg88.8%
distribute-frac-neg88.8%
associate-/r*88.9%
hypot-1-def78.4%
unpow278.4%
Simplified88.8%
expm1-log1p-u88.8%
div-inv88.8%
metadata-eval88.8%
Applied egg-rr88.8%
Taylor expanded in J around 0 24.6%
mul-1-neg24.6%
unsub-neg24.6%
unpow224.6%
*-commutative24.6%
unpow224.6%
swap-sqr24.6%
unpow224.6%
*-commutative24.6%
Simplified24.6%
unpow224.6%
associate-/l*27.4%
*-commutative27.4%
*-commutative27.4%
Applied egg-rr27.4%
if 6.6000000000000004e-248 < J Initial program 76.6%
Simplified93.3%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* J (cos (* K 0.5)))))
(if (<= J 8.8e-178)
(- (* -2.0 (* t_0 (/ t_0 U_m))) U_m)
(* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (/ (/ U_m 2.0) J))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = J * cos((K * 0.5));
double tmp;
if (J <= 8.8e-178) {
tmp = (-2.0 * (t_0 * (t_0 / U_m))) - U_m;
} else {
tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, ((U_m / 2.0) / J));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = J * Math.cos((K * 0.5));
double tmp;
if (J <= 8.8e-178) {
tmp = (-2.0 * (t_0 * (t_0 / U_m))) - U_m;
} else {
tmp = (J * (-2.0 * Math.cos((K / 2.0)))) * Math.hypot(1.0, ((U_m / 2.0) / J));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = J * math.cos((K * 0.5)) tmp = 0 if J <= 8.8e-178: tmp = (-2.0 * (t_0 * (t_0 / U_m))) - U_m else: tmp = (J * (-2.0 * math.cos((K / 2.0)))) * math.hypot(1.0, ((U_m / 2.0) / J)) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(J * cos(Float64(K * 0.5))) tmp = 0.0 if (J <= 8.8e-178) tmp = Float64(Float64(-2.0 * Float64(t_0 * Float64(t_0 / U_m))) - U_m); else tmp = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = J * cos((K * 0.5)); tmp = 0.0; if (J <= 8.8e-178) tmp = (-2.0 * (t_0 * (t_0 / U_m))) - U_m; else tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, ((U_m / 2.0) / J)); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, 8.8e-178], N[(N[(-2.0 * N[(t$95$0 * N[(t$95$0 / U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U$95$m), $MachinePrecision], N[(N[(J * N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := J \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq 8.8 \cdot 10^{-178}:\\
\;\;\;\;-2 \cdot \left(t\_0 \cdot \frac{t\_0}{U\_m}\right) - U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J}\right)\\
\end{array}
\end{array}
if J < 8.8000000000000005e-178Initial program 72.3%
unpow272.3%
hypot-1-def85.3%
associate-/r*85.2%
cos-neg85.2%
distribute-frac-neg85.2%
associate-/r*85.3%
hypot-1-def72.3%
unpow272.3%
Simplified85.2%
expm1-log1p-u85.2%
div-inv85.2%
metadata-eval85.2%
Applied egg-rr85.2%
Taylor expanded in J around 0 27.3%
mul-1-neg27.3%
unsub-neg27.3%
unpow227.3%
*-commutative27.3%
unpow227.3%
swap-sqr27.3%
unpow227.3%
*-commutative27.3%
Simplified27.3%
unpow227.3%
associate-/l*29.9%
*-commutative29.9%
*-commutative29.9%
Applied egg-rr29.9%
if 8.8000000000000005e-178 < J Initial program 85.7%
unpow285.7%
hypot-1-def99.7%
associate-/r*99.6%
cos-neg99.6%
distribute-frac-neg99.6%
associate-/r*99.7%
hypot-1-def85.7%
unpow285.7%
Simplified99.6%
Taylor expanded in K around 0 81.1%
/-rgt-identity81.1%
*-un-lft-identity81.1%
times-frac81.0%
Applied egg-rr81.0%
associate-*l/81.1%
*-lft-identity81.1%
Simplified81.1%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 2.4e-180) (- U_m) (* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (/ (/ U_m 2.0) J)))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 2.4e-180) {
tmp = -U_m;
} else {
tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, ((U_m / 2.0) / J));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 2.4e-180) {
tmp = -U_m;
} else {
tmp = (J * (-2.0 * Math.cos((K / 2.0)))) * Math.hypot(1.0, ((U_m / 2.0) / J));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 2.4e-180: tmp = -U_m else: tmp = (J * (-2.0 * math.cos((K / 2.0)))) * math.hypot(1.0, ((U_m / 2.0) / J)) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 2.4e-180) tmp = Float64(-U_m); else tmp = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 2.4e-180) tmp = -U_m; else tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, ((U_m / 2.0) / J)); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 2.4e-180], (-U$95$m), N[(N[(J * N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 2.4 \cdot 10^{-180}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J}\right)\\
\end{array}
\end{array}
if J < 2.39999999999999979e-180Initial program 72.3%
Simplified85.2%
Taylor expanded in J around 0 29.5%
neg-mul-129.5%
Simplified29.5%
if 2.39999999999999979e-180 < J Initial program 85.7%
unpow285.7%
hypot-1-def99.7%
associate-/r*99.6%
cos-neg99.6%
distribute-frac-neg99.6%
associate-/r*99.7%
hypot-1-def85.7%
unpow285.7%
Simplified99.6%
Taylor expanded in K around 0 81.1%
/-rgt-identity81.1%
*-un-lft-identity81.1%
times-frac81.0%
Applied egg-rr81.0%
associate-*l/81.1%
*-lft-identity81.1%
Simplified81.1%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 1.75e-179) (- U_m) (* J (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 1.75e-179) {
tmp = -U_m;
} else {
tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 1.75e-179) {
tmp = -U_m;
} else {
tmp = J * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 2.0) / J)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 1.75e-179: tmp = -U_m else: tmp = J * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 2.0) / J))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 1.75e-179) tmp = Float64(-U_m); else tmp = Float64(J * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 1.75e-179) tmp = -U_m; else tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 1.75e-179], (-U$95$m), N[(J * N[(N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 1.75 \cdot 10^{-179}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J}\right)\right)\\
\end{array}
\end{array}
if J < 1.75000000000000012e-179Initial program 72.3%
Simplified85.2%
Taylor expanded in J around 0 29.5%
neg-mul-129.5%
Simplified29.5%
if 1.75000000000000012e-179 < J Initial program 85.7%
Simplified99.6%
Taylor expanded in K around 0 81.1%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= K 0.011) (* -2.0 (* J (hypot 1.0 (/ U_m (* J 2.0))))) (* J (* -2.0 (cos (* K 0.5))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (K <= 0.011) {
tmp = -2.0 * (J * hypot(1.0, (U_m / (J * 2.0))));
} else {
tmp = J * (-2.0 * cos((K * 0.5)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (K <= 0.011) {
tmp = -2.0 * (J * Math.hypot(1.0, (U_m / (J * 2.0))));
} else {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if K <= 0.011: tmp = -2.0 * (J * math.hypot(1.0, (U_m / (J * 2.0)))) else: tmp = J * (-2.0 * math.cos((K * 0.5))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (K <= 0.011) tmp = Float64(-2.0 * Float64(J * hypot(1.0, Float64(U_m / Float64(J * 2.0))))); else tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (K <= 0.011) tmp = -2.0 * (J * hypot(1.0, (U_m / (J * 2.0)))); else tmp = J * (-2.0 * cos((K * 0.5))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[K, 0.011], N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 0.011:\\
\;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{U\_m}{J \cdot 2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if K < 0.010999999999999999Initial program 80.8%
unpow280.8%
hypot-1-def91.1%
associate-/r*91.1%
cos-neg91.1%
distribute-frac-neg91.1%
associate-/r*91.1%
hypot-1-def80.8%
unpow280.8%
Simplified91.1%
Taylor expanded in K around 0 82.0%
Taylor expanded in K around 0 43.7%
metadata-eval43.7%
metadata-eval43.7%
unpow243.7%
unpow243.7%
times-frac56.6%
swap-sqr56.6%
hypot-undefine66.0%
metadata-eval66.0%
times-frac66.0%
neg-mul-166.0%
*-commutative66.0%
distribute-frac-neg66.0%
distribute-neg-frac266.0%
distribute-rgt-neg-in66.0%
metadata-eval66.0%
Simplified66.0%
if 0.010999999999999999 < K Initial program 67.5%
Simplified90.3%
Taylor expanded in U around 0 50.8%
Final simplification62.3%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 6.5e-7) (- U_m) (* J (* -2.0 (cos (* K 0.5))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 6.5e-7) {
tmp = -U_m;
} else {
tmp = J * (-2.0 * cos((K * 0.5)));
}
return tmp;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: tmp
if (j <= 6.5d-7) then
tmp = -u_m
else
tmp = j * ((-2.0d0) * cos((k * 0.5d0)))
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 6.5e-7) {
tmp = -U_m;
} else {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 6.5e-7: tmp = -U_m else: tmp = J * (-2.0 * math.cos((K * 0.5))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 6.5e-7) tmp = Float64(-U_m); else tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 6.5e-7) tmp = -U_m; else tmp = J * (-2.0 * cos((K * 0.5))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 6.5e-7], (-U$95$m), N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 6.5 \cdot 10^{-7}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if J < 6.50000000000000024e-7Initial program 72.0%
Simplified87.7%
Taylor expanded in J around 0 29.9%
neg-mul-129.9%
Simplified29.9%
if 6.50000000000000024e-7 < J Initial program 93.0%
Simplified99.7%
Taylor expanded in U around 0 72.6%
Final simplification41.3%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 1.5e+37) (- U_m) (* -2.0 J)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 1.5e+37) {
tmp = -U_m;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: tmp
if (j <= 1.5d+37) then
tmp = -u_m
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 1.5e+37) {
tmp = -U_m;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 1.5e+37: tmp = -U_m else: tmp = -2.0 * J return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 1.5e+37) tmp = Float64(-U_m); else tmp = Float64(-2.0 * J); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 1.5e+37) tmp = -U_m; else tmp = -2.0 * J; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 1.5e+37], (-U$95$m), N[(-2.0 * J), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 1.5 \cdot 10^{+37}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 1.50000000000000011e37Initial program 72.4%
Simplified88.1%
Taylor expanded in J around 0 31.1%
neg-mul-131.1%
Simplified31.1%
if 1.50000000000000011e37 < J Initial program 93.8%
Simplified99.7%
Taylor expanded in U around 0 76.0%
*-commutative76.0%
expm1-log1p-u75.9%
Applied egg-rr75.9%
Taylor expanded in K around 0 45.0%
Final simplification34.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (- U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
return -U_m;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
code = -u_m
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
return -U_m;
}
U_m = math.fabs(U) def code(J, K, U_m): return -U_m
U_m = abs(U) function code(J, K, U_m) return Float64(-U_m) end
U_m = abs(U); function tmp = code(J, K, U_m) tmp = -U_m; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := (-U$95$m)
\begin{array}{l}
U_m = \left|U\right|
\\
-U\_m
\end{array}
Initial program 77.6%
Simplified90.9%
Taylor expanded in J around 0 26.5%
neg-mul-126.5%
Simplified26.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 U_m)
U_m = fabs(U);
double code(double J, double K, double U_m) {
return U_m;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
code = u_m
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
return U_m;
}
U_m = math.fabs(U) def code(J, K, U_m): return U_m
U_m = abs(U) function code(J, K, U_m) return U_m end
U_m = abs(U); function tmp = code(J, K, U_m) tmp = U_m; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := U$95$m
\begin{array}{l}
U_m = \left|U\right|
\\
U\_m
\end{array}
Initial program 77.6%
Simplified90.9%
Taylor expanded in U around -inf 22.3%
herbie shell --seed 2024172
(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)))))