
(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 (* (* 2.0 J) t_0)) 2.0))))))
(if (<= t_1 (- INFINITY)) (* -1.0 U_m) (if (<= t_1 1e+299) 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 / ((2.0 * J) * t_0)), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -1.0 * U_m;
} else if (t_1 <= 1e+299) {
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 / ((2.0 * J) * t_0)), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -1.0 * U_m;
} else if (t_1 <= 1e+299) {
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 / ((2.0 * J) * t_0)), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -1.0 * U_m elif t_1 <= 1e+299: 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(Float64(2.0 * J) * t_0)) ^ 2.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-1.0 * U_m); elseif (t_1 <= 1e+299) 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 / ((2.0 * J) * t_0)) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -1.0 * U_m; elseif (t_1 <= 1e+299) 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[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(-1.0 * U$95$m), $MachinePrecision], If[LessEqual[t$95$1, 1e+299], 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}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-1 \cdot U\_m\\
\mathbf{elif}\;t\_1 \leq 10^{+299}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\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 4.9%
Simplified70.5%
Taylor expanded in J around 0 40.6%
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)))) < 1.0000000000000001e299Initial program 99.8%
if 1.0000000000000001e299 < (*.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 7.7%
Simplified63.0%
Taylor expanded in U around -inf 49.2%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* 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));
return J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J * t_0))));
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
return J * ((-2.0 * t_0) * Math.hypot(1.0, ((U_m / 2.0) / (J * t_0))));
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) return J * ((-2.0 * t_0) * math.hypot(1.0, ((U_m / 2.0) / (J * t_0))))
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) return Float64(J * Float64(Float64(-2.0 * t_0) * hypot(1.0, Float64(Float64(U_m / 2.0) / Float64(J * t_0))))) end
U_m = abs(U); function tmp = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J * t_0)))); 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]}, 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)\\
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}
Initial program 68.4%
Simplified88.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* 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));
return (J * (-2.0 * t_0)) * hypot(1.0, ((U_m / (J * 2.0)) / t_0));
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
return (J * (-2.0 * t_0)) * Math.hypot(1.0, ((U_m / (J * 2.0)) / t_0));
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) return (J * (-2.0 * t_0)) * math.hypot(1.0, ((U_m / (J * 2.0)) / t_0))
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(Float64(U_m / Float64(J * 2.0)) / t_0))) end
U_m = abs(U); function tmp = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = (J * (-2.0 * t_0)) * hypot(1.0, ((U_m / (J * 2.0)) / t_0)); 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]}, 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)\\
\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}
Initial program 68.4%
*-commutative68.4%
associate-*l*68.4%
unpow268.4%
hypot-1-def88.8%
associate-/r*88.7%
cos-neg88.7%
distribute-frac-neg88.7%
associate-/r*88.8%
associate-/r*88.7%
*-commutative88.7%
distribute-frac-neg88.7%
cos-neg88.7%
Simplified88.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 8e+66) (* J (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J)))) (* -1.0 U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 8e+66) {
tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J)));
} else {
tmp = -1.0 * 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 <= 8e+66) {
tmp = J * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 2.0) / J)));
} else {
tmp = -1.0 * U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 8e+66: tmp = J * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 2.0) / J))) else: tmp = -1.0 * U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 8e+66) tmp = Float64(J * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J)))); else tmp = Float64(-1.0 * U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (U_m <= 8e+66) tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J))); else tmp = -1.0 * U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 8e+66], 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], N[(-1.0 * U$95$m), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 8 \cdot 10^{+66}:\\
\;\;\;\;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)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot U\_m\\
\end{array}
\end{array}
if U < 7.99999999999999956e66Initial program 73.5%
Simplified91.2%
Taylor expanded in K around 0 76.4%
if 7.99999999999999956e66 < U Initial program 50.6%
Simplified80.0%
Taylor expanded in J around 0 37.0%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 1.1e+33) (* J (* -2.0 (cos (* 0.5 K)))) (* -1.0 U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.1e+33) {
tmp = J * (-2.0 * cos((0.5 * K)));
} else {
tmp = -1.0 * 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 <= 1.1d+33) then
tmp = j * ((-2.0d0) * cos((0.5d0 * k)))
else
tmp = (-1.0d0) * 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 <= 1.1e+33) {
tmp = J * (-2.0 * Math.cos((0.5 * K)));
} else {
tmp = -1.0 * U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 1.1e+33: tmp = J * (-2.0 * math.cos((0.5 * K))) else: tmp = -1.0 * U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 1.1e+33) tmp = Float64(J * Float64(-2.0 * cos(Float64(0.5 * K)))); else tmp = Float64(-1.0 * 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.1e+33) tmp = J * (-2.0 * cos((0.5 * K))); else tmp = -1.0 * 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.1e+33], N[(J * N[(-2.0 * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * U$95$m), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 1.1 \cdot 10^{+33}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(0.5 \cdot K\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot U\_m\\
\end{array}
\end{array}
if U < 1.09999999999999997e33Initial program 74.1%
Simplified91.4%
Taylor expanded in U around 0 55.3%
if 1.09999999999999997e33 < U Initial program 50.7%
Simplified80.3%
Taylor expanded in J around 0 36.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= K 3.2) (* -2.0 J) U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (K <= 3.2) {
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 (k <= 3.2d0) 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 (K <= 3.2) {
tmp = -2.0 * J;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if K <= 3.2: tmp = -2.0 * J else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (K <= 3.2) tmp = Float64(-2.0 * J); 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 <= 3.2) 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[K, 3.2], N[(-2.0 * J), $MachinePrecision], U$95$m]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 3.2:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if K < 3.2000000000000002Initial program 65.1%
Simplified87.9%
Taylor expanded in U around 0 45.7%
Taylor expanded in K around 0 31.6%
if 3.2000000000000002 < K Initial program 79.9%
Simplified91.2%
Taylor expanded in U around -inf 26.2%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 2.6e-71) (* -2.0 J) (* -1.0 U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 2.6e-71) {
tmp = -2.0 * J;
} else {
tmp = -1.0 * 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 <= 2.6d-71) then
tmp = (-2.0d0) * j
else
tmp = (-1.0d0) * 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 <= 2.6e-71) {
tmp = -2.0 * J;
} else {
tmp = -1.0 * U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 2.6e-71: tmp = -2.0 * J else: tmp = -1.0 * U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 2.6e-71) tmp = Float64(-2.0 * J); else tmp = Float64(-1.0 * 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.6e-71) tmp = -2.0 * J; else tmp = -1.0 * 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.6e-71], N[(-2.0 * J), $MachinePrecision], N[(-1.0 * U$95$m), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 2.6 \cdot 10^{-71}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot U\_m\\
\end{array}
\end{array}
if U < 2.5999999999999999e-71Initial program 73.5%
Simplified90.7%
Taylor expanded in U around 0 55.9%
Taylor expanded in K around 0 30.9%
if 2.5999999999999999e-71 < U Initial program 56.9%
Simplified84.2%
Taylor expanded in J around 0 35.9%
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 68.4%
Simplified88.7%
Taylor expanded in U around -inf 30.6%
herbie shell --seed 2024050 -o generate:simplify
(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)))))