
(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}
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+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 = ((-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+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 = ((-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+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 = ((-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+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(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+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 = ((-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+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[(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+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(\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^{+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.7%
Simplified56.6%
Taylor expanded in J around 0 49.1%
neg-mul-149.1%
Simplified49.1%
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))))) < 5.00000000000000009e305Initial program 99.7%
if 5.00000000000000009e305 < (*.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 6.4%
Simplified49.3%
Taylor expanded in U around -inf 62.4%
Final simplification86.6%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U_m 3.9e+205)
(* -2.0 (* J (* t_0 (hypot 1.0 (/ (* U_m 0.5) (* J t_0))))))
(- U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (U_m <= 3.9e+205) {
tmp = -2.0 * (J * (t_0 * hypot(1.0, ((U_m * 0.5) / (J * t_0)))));
} 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 tmp;
if (U_m <= 3.9e+205) {
tmp = -2.0 * (J * (t_0 * Math.hypot(1.0, ((U_m * 0.5) / (J * t_0)))));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if U_m <= 3.9e+205: tmp = -2.0 * (J * (t_0 * math.hypot(1.0, ((U_m * 0.5) / (J * t_0))))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (U_m <= 3.9e+205) tmp = Float64(-2.0 * Float64(J * Float64(t_0 * hypot(1.0, Float64(Float64(U_m * 0.5) / Float64(J * t_0)))))); else tmp = Float64(-U_m); 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 (U_m <= 3.9e+205) tmp = -2.0 * (J * (t_0 * hypot(1.0, ((U_m * 0.5) / (J * t_0))))); 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]}, If[LessEqual[U$95$m, 3.9e+205], 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], (-U$95$m)]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U\_m \leq 3.9 \cdot 10^{+205}:\\
\;\;\;\;-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)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 3.8999999999999998e205Initial program 76.7%
Simplified89.1%
if 3.8999999999999998e205 < U Initial program 29.4%
Simplified57.4%
Taylor expanded in J around 0 42.4%
neg-mul-142.4%
Simplified42.4%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 2e+173) (* -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 <= 2e+173) {
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 <= 2e+173) {
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 <= 2e+173: 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 <= 2e+173) 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 <= 2e+173) 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, 2e+173], 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 \cdot 10^{+173}:\\
\;\;\;\;-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 < 2e173Initial program 78.2%
Simplified89.6%
Taylor expanded in K around 0 76.1%
if 2e173 < U Initial program 27.8%
Simplified59.4%
Taylor expanded in J around 0 37.6%
neg-mul-137.6%
Simplified37.6%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= U_m 1.3e-16)
(* (* -2.0 J) (cos (* K 0.5)))
(if (<= U_m 3.5e+155)
(* (* -2.0 J) (hypot 1.0 (* 0.5 (/ U_m J))))
(- U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.3e-16) {
tmp = (-2.0 * J) * cos((K * 0.5));
} else if (U_m <= 3.5e+155) {
tmp = (-2.0 * J) * hypot(1.0, (0.5 * (U_m / 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 <= 1.3e-16) {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
} else if (U_m <= 3.5e+155) {
tmp = (-2.0 * J) * Math.hypot(1.0, (0.5 * (U_m / J)));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 1.3e-16: tmp = (-2.0 * J) * math.cos((K * 0.5)) elif U_m <= 3.5e+155: tmp = (-2.0 * J) * math.hypot(1.0, (0.5 * (U_m / J))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 1.3e-16) tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))); elseif (U_m <= 3.5e+155) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(0.5 * Float64(U_m / 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 <= 1.3e-16) tmp = (-2.0 * J) * cos((K * 0.5)); elseif (U_m <= 3.5e+155) tmp = (-2.0 * J) * hypot(1.0, (0.5 * (U_m / 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, 1.3e-16], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 3.5e+155], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], (-U$95$m)]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 1.3 \cdot 10^{-16}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{elif}\;U\_m \leq 3.5 \cdot 10^{+155}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U\_m}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1.2999999999999999e-16Initial program 81.5%
Simplified90.9%
Taylor expanded in J around inf 59.2%
associate-*r*59.2%
Simplified59.2%
if 1.2999999999999999e-16 < U < 3.49999999999999985e155Initial program 60.0%
*-commutative60.0%
associate-*l*60.0%
unpow260.0%
hypot-1-def83.1%
associate-/r*83.0%
cos-neg83.0%
distribute-frac-neg83.0%
associate-/r*83.1%
associate-/r*83.0%
*-commutative83.0%
distribute-frac-neg83.0%
cos-neg83.0%
Simplified83.0%
log1p-expm1-u83.1%
div-inv83.1%
metadata-eval83.1%
Applied egg-rr83.1%
Taylor expanded in K around 0 26.7%
associate-*r*26.7%
metadata-eval26.7%
metadata-eval26.7%
unpow226.7%
unpow226.7%
times-frac33.5%
swap-sqr33.5%
hypot-undefine53.3%
Simplified53.3%
if 3.49999999999999985e155 < U Initial program 30.6%
Simplified61.2%
Taylor expanded in J around 0 39.3%
neg-mul-139.3%
Simplified39.3%
Final simplification55.8%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 8.5e-75) (- U_m) (* (* -2.0 J) (cos (* K 0.5)))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 8.5e-75) {
tmp = -U_m;
} else {
tmp = (-2.0 * J) * 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 <= 8.5d-75) then
tmp = -u_m
else
tmp = ((-2.0d0) * j) * 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 <= 8.5e-75) {
tmp = -U_m;
} 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 J <= 8.5e-75: tmp = -U_m 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 (J <= 8.5e-75) tmp = Float64(-U_m); 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 (J <= 8.5e-75) tmp = -U_m; 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[J, 8.5e-75], (-U$95$m), 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}\;J \leq 8.5 \cdot 10^{-75}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\end{array}
\end{array}
if J < 8.5000000000000001e-75Initial program 64.4%
Simplified81.1%
Taylor expanded in J around 0 30.3%
neg-mul-130.3%
Simplified30.3%
if 8.5000000000000001e-75 < J Initial program 92.0%
Simplified98.5%
Taylor expanded in J around inf 73.6%
associate-*r*73.6%
Simplified73.6%
Final simplification42.1%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 4.2e-109) (* -2.0 J) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 4.2e-109) {
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 <= 4.2d-109) 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 <= 4.2e-109) {
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 <= 4.2e-109: 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 <= 4.2e-109) 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 <= 4.2e-109) 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, 4.2e-109], N[(-2.0 * J), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 4.2 \cdot 10^{-109}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 4.19999999999999992e-109Initial program 81.3%
Simplified90.1%
Taylor expanded in J around inf 58.9%
associate-*r*58.9%
Simplified58.9%
Taylor expanded in K around 0 31.5%
if 4.19999999999999992e-109 < U Initial program 52.3%
Simplified77.1%
Taylor expanded in J around 0 32.8%
neg-mul-132.8%
Simplified32.8%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= K 8e+238) (- U_m) U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (K <= 8e+238) {
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 <= 8d+238) 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 <= 8e+238) {
tmp = -U_m;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if K <= 8e+238: tmp = -U_m else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (K <= 8e+238) 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 <= 8e+238) 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, 8e+238], (-U$95$m), U$95$m]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 8 \cdot 10^{+238}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if K < 8.0000000000000004e238Initial program 72.0%
Simplified86.1%
Taylor expanded in J around 0 25.7%
neg-mul-125.7%
Simplified25.7%
if 8.0000000000000004e238 < K Initial program 70.2%
Simplified81.8%
Taylor expanded in U around -inf 26.8%
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 71.9%
Simplified85.8%
Taylor expanded in U around -inf 28.3%
herbie shell --seed 2024132
(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)))))