
(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}
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY)) (- U_m) (if (<= t_1 5e+302) 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 = ((-2.0 * J) * t_0) * 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 <= 5e+302) {
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 = ((-2.0 * J) * t_0) * 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 <= 5e+302) {
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 = ((-2.0 * J) * t_0) * 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 <= 5e+302: 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(Float64(-2.0 * J) * t_0) * 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 <= 5e+302) 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 = ((-2.0 * J) * t_0) * 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 <= 5e+302) 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[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $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, 5e+302], 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(\left(-2 \cdot J\right) \cdot t\_0\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 5 \cdot 10^{+302}:\\
\;\;\;\;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.4%
*-commutative5.4%
associate-*l*5.4%
unpow25.4%
hypot-1-def71.4%
associate-/r*71.2%
*-commutative71.2%
Simplified71.2%
Taylor expanded in J around 0 48.7%
neg-mul-148.7%
Simplified48.7%
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))))) < 5e302Initial program 99.8%
if 5e302 < (*.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 8.0%
*-commutative8.0%
associate-*l*8.0%
unpow28.0%
hypot-1-def61.7%
associate-/r*61.6%
*-commutative61.6%
Simplified61.6%
Taylor expanded in U around -inf 49.3%
Final simplification83.6%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= J 4e-218)
(- U_m)
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ (/ U_m (* J 2.0)) t_0))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (J <= 4e-218) {
tmp = -U_m;
} else {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, ((U_m / (J * 2.0)) / 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 tmp;
if (J <= 4e-218) {
tmp = -U_m;
} else {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, ((U_m / (J * 2.0)) / t_0));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if J <= 4e-218: tmp = -U_m else: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, ((U_m / (J * 2.0)) / t_0)) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (J <= 4e-218) tmp = Float64(-U_m); else tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(Float64(U_m / Float64(J * 2.0)) / t_0))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = 0.0; if (J <= 4e-218) tmp = -U_m; else tmp = (J * (-2.0 * t_0)) * hypot(1.0, ((U_m / (J * 2.0)) / 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]}, If[LessEqual[J, 4e-218], (-U$95$m), N[(N[(J * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;J \leq 4 \cdot 10^{-218}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot t\_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{J \cdot 2}}{t\_0}\right)\\
\end{array}
\end{array}
if J < 4.0000000000000001e-218Initial program 66.6%
*-commutative66.6%
associate-*l*66.6%
unpow266.6%
hypot-1-def85.8%
associate-/r*85.7%
*-commutative85.7%
Simplified85.7%
Taylor expanded in J around 0 27.8%
neg-mul-127.8%
Simplified27.8%
if 4.0000000000000001e-218 < J Initial program 75.2%
*-commutative75.2%
associate-*l*75.2%
unpow275.2%
hypot-1-def93.4%
associate-/r*93.4%
*-commutative93.4%
Simplified93.4%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= J 2e-218)
(- U_m)
(* -2.0 (* J (* t_0 (hypot 1.0 (/ (* U_m 0.5) (* J t_0)))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (J <= 2e-218) {
tmp = -U_m;
} else {
tmp = -2.0 * (J * (t_0 * hypot(1.0, ((U_m * 0.5) / (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 tmp;
if (J <= 2e-218) {
tmp = -U_m;
} else {
tmp = -2.0 * (J * (t_0 * Math.hypot(1.0, ((U_m * 0.5) / (J * t_0)))));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if J <= 2e-218: tmp = -U_m else: tmp = -2.0 * (J * (t_0 * math.hypot(1.0, ((U_m * 0.5) / (J * t_0))))) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (J <= 2e-218) tmp = Float64(-U_m); else tmp = Float64(-2.0 * Float64(J * Float64(t_0 * hypot(1.0, Float64(Float64(U_m * 0.5) / 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)); tmp = 0.0; if (J <= 2e-218) tmp = -U_m; else tmp = -2.0 * (J * (t_0 * hypot(1.0, ((U_m * 0.5) / (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]}, If[LessEqual[J, 2e-218], (-U$95$m), N[(-2.0 * N[(J * N[(t$95$0 * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m * 0.5), $MachinePrecision] / N[(J * t$95$0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;J \leq 2 \cdot 10^{-218}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \left(t\_0 \cdot \mathsf{hypot}\left(1, \frac{U\_m \cdot 0.5}{J \cdot t\_0}\right)\right)\right)\\
\end{array}
\end{array}
if J < 2.0000000000000001e-218Initial program 66.6%
*-commutative66.6%
associate-*l*66.6%
unpow266.6%
hypot-1-def85.8%
associate-/r*85.7%
*-commutative85.7%
Simplified85.7%
Taylor expanded in J around 0 27.8%
neg-mul-127.8%
Simplified27.8%
if 2.0000000000000001e-218 < J Initial program 75.2%
Simplified93.4%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 2.2e+166) (* -2.0 (* J (* (cos (/ K 2.0)) (hypot 1.0 (/ (* U_m 0.5) J))))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 2.2e+166) {
tmp = -2.0 * (J * (cos((K / 2.0)) * hypot(1.0, ((U_m * 0.5) / J))));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 2.2e+166) {
tmp = -2.0 * (J * (Math.cos((K / 2.0)) * Math.hypot(1.0, ((U_m * 0.5) / J))));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 2.2e+166: tmp = -2.0 * (J * (math.cos((K / 2.0)) * math.hypot(1.0, ((U_m * 0.5) / J)))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 2.2e+166) tmp = Float64(-2.0 * Float64(J * Float64(cos(Float64(K / 2.0)) * hypot(1.0, Float64(Float64(U_m * 0.5) / J))))); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (U_m <= 2.2e+166) tmp = -2.0 * (J * (cos((K / 2.0)) * hypot(1.0, ((U_m * 0.5) / J)))); else tmp = -U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 2.2e+166], N[(-2.0 * N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 2.2 \cdot 10^{+166}:\\
\;\;\;\;-2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m \cdot 0.5}{J}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 2.1999999999999999e166Initial program 73.8%
Simplified89.9%
Taylor expanded in K around 0 77.2%
if 2.1999999999999999e166 < U Initial program 38.2%
*-commutative38.2%
associate-*l*38.2%
unpow238.2%
hypot-1-def79.4%
associate-/r*79.2%
*-commutative79.2%
Simplified79.2%
Taylor expanded in J around 0 29.8%
neg-mul-129.8%
Simplified29.8%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= K 2.15e+55) (* (* -2.0 J) (hypot 1.0 (* U_m (/ 0.5 J)))) (* (* -2.0 J) (cos (* K 0.5)))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (K <= 2.15e+55) {
tmp = (-2.0 * J) * hypot(1.0, (U_m * (0.5 / J)));
} else {
tmp = (-2.0 * J) * 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 <= 2.15e+55) {
tmp = (-2.0 * J) * Math.hypot(1.0, (U_m * (0.5 / J)));
} else {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if K <= 2.15e+55: tmp = (-2.0 * J) * math.hypot(1.0, (U_m * (0.5 / J))) else: tmp = (-2.0 * J) * math.cos((K * 0.5)) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (K <= 2.15e+55) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(U_m * Float64(0.5 / J)))); else tmp = Float64(Float64(-2.0 * J) * 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 <= 2.15e+55) tmp = (-2.0 * J) * hypot(1.0, (U_m * (0.5 / J))); else tmp = (-2.0 * J) * cos((K * 0.5)); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[K, 2.15e+55], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U$95$m * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 2.15 \cdot 10^{+55}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, U\_m \cdot \frac{0.5}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\end{array}
\end{array}
if K < 2.1499999999999999e55Initial program 69.5%
*-commutative69.5%
associate-*l*69.5%
unpow269.5%
hypot-1-def89.2%
associate-/r*89.1%
*-commutative89.1%
Simplified89.1%
expm1-log1p-u89.1%
div-inv89.1%
metadata-eval89.1%
Applied egg-rr89.1%
Taylor expanded in K around 0 41.1%
associate-*r*41.1%
metadata-eval41.1%
metadata-eval41.1%
unpow241.1%
unpow241.1%
times-frac53.1%
swap-sqr53.1%
hypot-undefine67.9%
associate-*r/68.3%
remove-double-neg68.3%
distribute-neg-frac268.3%
*-commutative68.3%
metadata-eval68.3%
distribute-rgt-neg-in68.3%
distribute-rgt-neg-in68.3%
metadata-eval68.3%
neg-mul-168.3%
times-frac68.2%
metadata-eval68.2%
distribute-neg-frac268.2%
/-rgt-identity68.2%
Simplified68.2%
if 2.1499999999999999e55 < K Initial program 72.7%
*-commutative72.7%
associate-*l*72.7%
unpow272.7%
hypot-1-def87.3%
associate-/r*87.3%
*-commutative87.3%
Simplified87.3%
Taylor expanded in J around inf 55.3%
associate-*r*55.3%
*-commutative55.3%
Simplified55.3%
Final simplification65.9%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 9.5e+23) (* (* -2.0 J) (cos (* K 0.5))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 9.5e+23) {
tmp = (-2.0 * J) * cos((K * 0.5));
} else {
tmp = -U_m;
}
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 (u_m <= 9.5d+23) then
tmp = ((-2.0d0) * j) * cos((k * 0.5d0))
else
tmp = -u_m
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 (U_m <= 9.5e+23) {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 9.5e+23: tmp = (-2.0 * J) * math.cos((K * 0.5)) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 9.5e+23) tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (U_m <= 9.5e+23) tmp = (-2.0 * J) * cos((K * 0.5)); else tmp = -U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 9.5e+23], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 9.5 \cdot 10^{+23}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 9.50000000000000038e23Initial program 78.1%
*-commutative78.1%
associate-*l*78.1%
unpow278.1%
hypot-1-def92.2%
associate-/r*92.1%
*-commutative92.1%
Simplified92.1%
Taylor expanded in J around inf 57.7%
associate-*r*57.7%
*-commutative57.7%
Simplified57.7%
if 9.50000000000000038e23 < U Initial program 44.4%
*-commutative44.4%
associate-*l*44.4%
unpow244.4%
hypot-1-def78.3%
associate-/r*78.1%
*-commutative78.1%
Simplified78.1%
Taylor expanded in J around 0 40.1%
neg-mul-140.1%
Simplified40.1%
Final simplification53.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 3.1e-93) (* -2.0 J) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 3.1e-93) {
tmp = -2.0 * J;
} else {
tmp = -U_m;
}
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 (u_m <= 3.1d-93) then
tmp = (-2.0d0) * j
else
tmp = -u_m
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 (U_m <= 3.1e-93) {
tmp = -2.0 * J;
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 3.1e-93: tmp = -2.0 * J else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 3.1e-93) tmp = Float64(-2.0 * J); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (U_m <= 3.1e-93) tmp = -2.0 * J; else tmp = -U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 3.1e-93], N[(-2.0 * J), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 3.1 \cdot 10^{-93}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 3.1e-93Initial program 77.7%
*-commutative77.7%
associate-*l*77.7%
unpow277.7%
hypot-1-def91.2%
associate-/r*91.2%
*-commutative91.2%
Simplified91.2%
expm1-log1p-u91.1%
div-inv91.1%
metadata-eval91.1%
Applied egg-rr91.1%
Taylor expanded in K around 0 39.2%
associate-*r*39.2%
metadata-eval39.2%
metadata-eval39.2%
unpow239.2%
unpow239.2%
times-frac51.2%
swap-sqr51.2%
hypot-undefine60.4%
associate-*r/60.4%
remove-double-neg60.4%
distribute-neg-frac260.4%
*-commutative60.4%
metadata-eval60.4%
distribute-rgt-neg-in60.4%
distribute-rgt-neg-in60.4%
metadata-eval60.4%
neg-mul-160.4%
times-frac60.3%
metadata-eval60.3%
distribute-neg-frac260.3%
/-rgt-identity60.3%
Simplified60.3%
Taylor expanded in U around 0 36.0%
if 3.1e-93 < U Initial program 53.9%
*-commutative53.9%
associate-*l*53.9%
unpow253.9%
hypot-1-def83.8%
associate-/r*83.7%
*-commutative83.7%
Simplified83.7%
Taylor expanded in J around 0 36.4%
neg-mul-136.4%
Simplified36.4%
Final simplification36.1%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= K 6e+79) (- U_m) U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (K <= 6e+79) {
tmp = -U_m;
} else {
tmp = U_m;
}
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 (k <= 6d+79) then
tmp = -u_m
else
tmp = u_m
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 (K <= 6e+79) {
tmp = -U_m;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if K <= 6e+79: tmp = -U_m else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (K <= 6e+79) tmp = Float64(-U_m); else tmp = U_m; end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (K <= 6e+79) tmp = -U_m; else tmp = U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[K, 6e+79], (-U$95$m), U$95$m]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 6 \cdot 10^{+79}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if K < 5.99999999999999948e79Initial program 69.6%
*-commutative69.6%
associate-*l*69.6%
unpow269.6%
hypot-1-def89.4%
associate-/r*89.3%
*-commutative89.3%
Simplified89.3%
Taylor expanded in J around 0 29.0%
neg-mul-129.0%
Simplified29.0%
if 5.99999999999999948e79 < K Initial program 72.4%
*-commutative72.4%
associate-*l*72.4%
unpow272.4%
hypot-1-def86.1%
associate-/r*86.1%
*-commutative86.1%
Simplified86.1%
Taylor expanded in U around -inf 31.1%
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 70.1%
*-commutative70.1%
associate-*l*70.1%
unpow270.1%
hypot-1-def88.9%
associate-/r*88.8%
*-commutative88.8%
Simplified88.8%
Taylor expanded in U around -inf 30.2%
herbie shell --seed 2024117
(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)))))