
(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 6 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 (* J t_0))
(t_2
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_2 (- INFINITY))
(* -2.0 (* U_m 0.5))
(if (<= t_2 1e+307)
(* -2.0 (* t_1 (hypot 1.0 (/ (/ U_m 2.0) t_1))))
(* -2.0 (* U_m -0.5))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = J * t_0;
double t_2 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = -2.0 * (U_m * 0.5);
} else if (t_2 <= 1e+307) {
tmp = -2.0 * (t_1 * hypot(1.0, ((U_m / 2.0) / t_1)));
} else {
tmp = -2.0 * (U_m * -0.5);
}
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 * t_0;
double t_2 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = -2.0 * (U_m * 0.5);
} else if (t_2 <= 1e+307) {
tmp = -2.0 * (t_1 * Math.hypot(1.0, ((U_m / 2.0) / t_1)));
} else {
tmp = -2.0 * (U_m * -0.5);
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = J * t_0 t_2 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U_m / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_2 <= -math.inf: tmp = -2.0 * (U_m * 0.5) elif t_2 <= 1e+307: tmp = -2.0 * (t_1 * math.hypot(1.0, ((U_m / 2.0) / t_1))) else: tmp = -2.0 * (U_m * -0.5) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(J * t_0) t_2 = 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_2 <= Float64(-Inf)) tmp = Float64(-2.0 * Float64(U_m * 0.5)); elseif (t_2 <= 1e+307) tmp = Float64(-2.0 * Float64(t_1 * hypot(1.0, Float64(Float64(U_m / 2.0) / t_1)))); else tmp = Float64(-2.0 * Float64(U_m * -0.5)); 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 * t_0; t_2 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U_m / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_2 <= -Inf) tmp = -2.0 * (U_m * 0.5); elseif (t_2 <= 1e+307) tmp = -2.0 * (t_1 * hypot(1.0, ((U_m / 2.0) / t_1))); else tmp = -2.0 * (U_m * -0.5); 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 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = 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$2, (-Infinity)], N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+307], N[(-2.0 * N[(t$95$1 * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / t$95$1), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(U$95$m * -0.5), $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 t_0\\
t_2 := \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_2 \leq -\infty:\\
\;\;\;\;-2 \cdot \left(U_m \cdot 0.5\right)\\
\mathbf{elif}\;t_2 \leq 10^{+307}:\\
\;\;\;\;-2 \cdot \left(t_1 \cdot \mathsf{hypot}\left(1, \frac{\frac{U_m}{2}}{t_1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot -0.5\right)\\
\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 6.1%
associate-*l*6.1%
associate-*l*6.1%
*-commutative6.1%
unpow26.1%
sqr-neg6.1%
distribute-frac-neg6.1%
distribute-frac-neg6.1%
unpow26.1%
Simplified59.9%
Taylor expanded in J around 0 51.7%
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)))) < 9.99999999999999986e306Initial program 99.8%
associate-*l*99.8%
associate-*l*99.8%
unpow299.8%
sqr-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg99.8%
unpow299.8%
Simplified99.8%
if 9.99999999999999986e306 < (*.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 6.4%
associate-*l*6.4%
associate-*l*6.4%
*-commutative6.4%
unpow26.4%
sqr-neg6.4%
distribute-frac-neg6.4%
distribute-frac-neg6.4%
unpow26.4%
Simplified57.0%
Taylor expanded in U around -inf 46.7%
*-commutative46.7%
Simplified46.7%
Final simplification87.4%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U_m 4.9e+253)
(* -2.0 (* t_0 (* J (hypot 1.0 (/ (/ U_m 2.0) (* J t_0))))))
(* -2.0 (* U_m 0.5)))))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 <= 4.9e+253) {
tmp = -2.0 * (t_0 * (J * hypot(1.0, ((U_m / 2.0) / (J * t_0)))));
} else {
tmp = -2.0 * (U_m * 0.5);
}
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 <= 4.9e+253) {
tmp = -2.0 * (t_0 * (J * Math.hypot(1.0, ((U_m / 2.0) / (J * t_0)))));
} else {
tmp = -2.0 * (U_m * 0.5);
}
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 <= 4.9e+253: tmp = -2.0 * (t_0 * (J * math.hypot(1.0, ((U_m / 2.0) / (J * t_0))))) else: tmp = -2.0 * (U_m * 0.5) 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 <= 4.9e+253) tmp = Float64(-2.0 * Float64(t_0 * Float64(J * hypot(1.0, Float64(Float64(U_m / 2.0) / Float64(J * t_0)))))); else tmp = Float64(-2.0 * Float64(U_m * 0.5)); 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 <= 4.9e+253) tmp = -2.0 * (t_0 * (J * hypot(1.0, ((U_m / 2.0) / (J * t_0))))); else tmp = -2.0 * (U_m * 0.5); 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, 4.9e+253], N[(-2.0 * N[(t$95$0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / N[(J * t$95$0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U_m \leq 4.9 \cdot 10^{+253}:\\
\;\;\;\;-2 \cdot \left(t_0 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U_m}{2}}{J \cdot t_0}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot 0.5\right)\\
\end{array}
\end{array}
if U < 4.9000000000000001e253Initial program 79.4%
associate-*l*79.4%
associate-*l*79.4%
*-commutative79.4%
unpow279.4%
sqr-neg79.4%
distribute-frac-neg79.4%
distribute-frac-neg79.4%
unpow279.4%
Simplified91.8%
if 4.9000000000000001e253 < U Initial program 17.4%
associate-*l*17.4%
associate-*l*17.4%
*-commutative17.4%
unpow217.4%
sqr-neg17.4%
distribute-frac-neg17.4%
distribute-frac-neg17.4%
unpow217.4%
Simplified41.6%
Taylor expanded in J around 0 54.6%
Final simplification90.2%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 7.2e+143) (* -2.0 (* (* J (cos (/ K 2.0))) (hypot 1.0 (* 0.5 (/ U_m J))))) (* -2.0 (* U_m 0.5))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 7.2e+143) {
tmp = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, (0.5 * (U_m / J))));
} else {
tmp = -2.0 * (U_m * 0.5);
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 7.2e+143) {
tmp = -2.0 * ((J * Math.cos((K / 2.0))) * Math.hypot(1.0, (0.5 * (U_m / J))));
} else {
tmp = -2.0 * (U_m * 0.5);
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 7.2e+143: tmp = -2.0 * ((J * math.cos((K / 2.0))) * math.hypot(1.0, (0.5 * (U_m / J)))) else: tmp = -2.0 * (U_m * 0.5) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 7.2e+143) tmp = Float64(-2.0 * Float64(Float64(J * cos(Float64(K / 2.0))) * hypot(1.0, Float64(0.5 * Float64(U_m / J))))); else tmp = Float64(-2.0 * Float64(U_m * 0.5)); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (U_m <= 7.2e+143) tmp = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, (0.5 * (U_m / J)))); else tmp = -2.0 * (U_m * 0.5); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 7.2e+143], N[(-2.0 * N[(N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U_m \leq 7.2 \cdot 10^{+143}:\\
\;\;\;\;-2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U_m}{J}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot 0.5\right)\\
\end{array}
\end{array}
if U < 7.1999999999999998e143Initial program 81.9%
associate-*l*81.9%
associate-*l*81.9%
unpow281.9%
sqr-neg81.9%
distribute-frac-neg81.9%
distribute-frac-neg81.9%
unpow281.9%
Simplified93.7%
Taylor expanded in K around 0 81.1%
if 7.1999999999999998e143 < U Initial program 38.1%
associate-*l*38.1%
associate-*l*38.1%
*-commutative38.1%
unpow238.1%
sqr-neg38.1%
distribute-frac-neg38.1%
distribute-frac-neg38.1%
unpow238.1%
Simplified59.5%
Taylor expanded in J around 0 63.7%
Final simplification79.0%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= U_m 0.0017) (and (not (<= U_m 4.3e+15)) (<= U_m 2.7e+115))) (* -2.0 (* J (cos (/ K 2.0)))) (* -2.0 (* U_m 0.5))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if ((U_m <= 0.0017) || (!(U_m <= 4.3e+15) && (U_m <= 2.7e+115))) {
tmp = -2.0 * (J * cos((K / 2.0)));
} else {
tmp = -2.0 * (U_m * 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 ((u_m <= 0.0017d0) .or. (.not. (u_m <= 4.3d+15)) .and. (u_m <= 2.7d+115)) then
tmp = (-2.0d0) * (j * cos((k / 2.0d0)))
else
tmp = (-2.0d0) * (u_m * 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 ((U_m <= 0.0017) || (!(U_m <= 4.3e+15) && (U_m <= 2.7e+115))) {
tmp = -2.0 * (J * Math.cos((K / 2.0)));
} else {
tmp = -2.0 * (U_m * 0.5);
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if (U_m <= 0.0017) or (not (U_m <= 4.3e+15) and (U_m <= 2.7e+115)): tmp = -2.0 * (J * math.cos((K / 2.0))) else: tmp = -2.0 * (U_m * 0.5) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if ((U_m <= 0.0017) || (!(U_m <= 4.3e+15) && (U_m <= 2.7e+115))) tmp = Float64(-2.0 * Float64(J * cos(Float64(K / 2.0)))); else tmp = Float64(-2.0 * Float64(U_m * 0.5)); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if ((U_m <= 0.0017) || (~((U_m <= 4.3e+15)) && (U_m <= 2.7e+115))) tmp = -2.0 * (J * cos((K / 2.0))); else tmp = -2.0 * (U_m * 0.5); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[Or[LessEqual[U$95$m, 0.0017], And[N[Not[LessEqual[U$95$m, 4.3e+15]], $MachinePrecision], LessEqual[U$95$m, 2.7e+115]]], N[(-2.0 * N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U_m \leq 0.0017 \lor \neg \left(U_m \leq 4.3 \cdot 10^{+15}\right) \land U_m \leq 2.7 \cdot 10^{+115}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot 0.5\right)\\
\end{array}
\end{array}
if U < 0.00169999999999999991 or 4.3e15 < U < 2.70000000000000004e115Initial program 82.6%
associate-*l*82.6%
associate-*l*82.6%
*-commutative82.6%
unpow282.6%
sqr-neg82.6%
distribute-frac-neg82.6%
distribute-frac-neg82.6%
unpow282.6%
Simplified94.3%
Taylor expanded in J around inf 62.0%
if 0.00169999999999999991 < U < 4.3e15 or 2.70000000000000004e115 < U Initial program 42.1%
associate-*l*42.1%
associate-*l*42.1%
*-commutative42.1%
unpow242.1%
sqr-neg42.1%
distribute-frac-neg42.1%
distribute-frac-neg42.1%
unpow242.1%
Simplified61.9%
Taylor expanded in J around 0 65.5%
Final simplification62.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= U_m 3e-136) (and (not (<= U_m 7e-67)) (<= U_m 2e-46))) (* -2.0 J) (* -2.0 (* U_m 0.5))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if ((U_m <= 3e-136) || (!(U_m <= 7e-67) && (U_m <= 2e-46))) {
tmp = -2.0 * J;
} else {
tmp = -2.0 * (U_m * 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 ((u_m <= 3d-136) .or. (.not. (u_m <= 7d-67)) .and. (u_m <= 2d-46)) then
tmp = (-2.0d0) * j
else
tmp = (-2.0d0) * (u_m * 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 ((U_m <= 3e-136) || (!(U_m <= 7e-67) && (U_m <= 2e-46))) {
tmp = -2.0 * J;
} else {
tmp = -2.0 * (U_m * 0.5);
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if (U_m <= 3e-136) or (not (U_m <= 7e-67) and (U_m <= 2e-46)): tmp = -2.0 * J else: tmp = -2.0 * (U_m * 0.5) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if ((U_m <= 3e-136) || (!(U_m <= 7e-67) && (U_m <= 2e-46))) tmp = Float64(-2.0 * J); else tmp = Float64(-2.0 * Float64(U_m * 0.5)); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if ((U_m <= 3e-136) || (~((U_m <= 7e-67)) && (U_m <= 2e-46))) tmp = -2.0 * J; else tmp = -2.0 * (U_m * 0.5); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[Or[LessEqual[U$95$m, 3e-136], And[N[Not[LessEqual[U$95$m, 7e-67]], $MachinePrecision], LessEqual[U$95$m, 2e-46]]], N[(-2.0 * J), $MachinePrecision], N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U_m \leq 3 \cdot 10^{-136} \lor \neg \left(U_m \leq 7 \cdot 10^{-67}\right) \land U_m \leq 2 \cdot 10^{-46}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot 0.5\right)\\
\end{array}
\end{array}
if U < 2.9999999999999998e-136 or 7.0000000000000001e-67 < U < 2.00000000000000005e-46Initial program 81.8%
associate-*l*81.8%
associate-*l*81.8%
*-commutative81.8%
unpow281.8%
sqr-neg81.8%
distribute-frac-neg81.8%
distribute-frac-neg81.8%
unpow281.8%
Simplified93.1%
add-sqr-sqrt43.9%
pow243.9%
div-inv43.9%
times-frac43.9%
metadata-eval43.9%
div-inv43.9%
metadata-eval43.9%
Applied egg-rr43.9%
Taylor expanded in J around inf 30.2%
Taylor expanded in K around 0 35.9%
if 2.9999999999999998e-136 < U < 7.0000000000000001e-67 or 2.00000000000000005e-46 < U Initial program 67.4%
associate-*l*67.4%
associate-*l*67.4%
*-commutative67.4%
unpow267.4%
sqr-neg67.4%
distribute-frac-neg67.4%
distribute-frac-neg67.4%
unpow267.4%
Simplified83.1%
Taylor expanded in J around 0 44.6%
Final simplification39.0%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (* -2.0 J))
U_m = fabs(U);
double code(double J, double K, double U_m) {
return -2.0 * J;
}
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 = (-2.0d0) * j
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
return -2.0 * J;
}
U_m = math.fabs(U) def code(J, K, U_m): return -2.0 * J
U_m = abs(U) function code(J, K, U_m) return Float64(-2.0 * J) end
U_m = abs(U); function tmp = code(J, K, U_m) tmp = -2.0 * J; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := N[(-2.0 * J), $MachinePrecision]
\begin{array}{l}
U_m = \left|U\right|
\\
-2 \cdot J
\end{array}
Initial program 76.8%
associate-*l*76.8%
associate-*l*76.8%
*-commutative76.8%
unpow276.8%
sqr-neg76.8%
distribute-frac-neg76.8%
distribute-frac-neg76.8%
unpow276.8%
Simplified89.6%
add-sqr-sqrt46.5%
pow246.5%
div-inv46.5%
times-frac46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
Applied egg-rr46.5%
Taylor expanded in J around inf 28.4%
Taylor expanded in K around 0 28.1%
Final simplification28.1%
herbie shell --seed 2023339
(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)))))