
(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 1e+301) 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 <= 1e+301) {
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 <= 1e+301) {
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 <= 1e+301: 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 <= 1e+301) 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 <= 1e+301) 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, 1e+301], 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 10^{+301}:\\
\;\;\;\;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 6.4%
Simplified54.3%
Taylor expanded in J around 0 46.8%
neg-mul-146.8%
Simplified46.8%
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.00000000000000005e301Initial program 99.8%
if 1.00000000000000005e301 < (*.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.9%
Simplified50.5%
Taylor expanded in U around -inf 67.8%
Final simplification86.7%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U_m 4.9e+225)
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ (/ U_m (* J 2.0)) 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 <= 4.9e+225) {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, ((U_m / (J * 2.0)) / 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 <= 4.9e+225) {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, ((U_m / (J * 2.0)) / 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 <= 4.9e+225: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, ((U_m / (J * 2.0)) / 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 <= 4.9e+225) tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(Float64(U_m / Float64(J * 2.0)) / 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 <= 4.9e+225) tmp = (J * (-2.0 * t_0)) * hypot(1.0, ((U_m / (J * 2.0)) / 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, 4.9e+225], 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], (-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 4.9 \cdot 10^{+225}:\\
\;\;\;\;\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)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 4.90000000000000032e225Initial program 76.0%
*-commutative76.0%
associate-*l*76.0%
unpow276.0%
hypot-1-def88.6%
associate-/r*88.5%
cos-neg88.5%
distribute-frac-neg88.5%
associate-/r*88.6%
associate-/r*88.5%
*-commutative88.5%
distribute-frac-neg88.5%
cos-neg88.5%
Simplified88.5%
if 4.90000000000000032e225 < U Initial program 27.9%
Simplified55.7%
Taylor expanded in J around 0 56.6%
neg-mul-156.6%
Simplified56.6%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U_m 5e+225)
(* J (* (* -2.0 t_0) (hypot 1.0 (/ (/ U_m 2.0) (* 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 <= 5e+225) {
tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (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 <= 5e+225) {
tmp = J * ((-2.0 * t_0) * Math.hypot(1.0, ((U_m / 2.0) / (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 <= 5e+225: tmp = J * ((-2.0 * t_0) * math.hypot(1.0, ((U_m / 2.0) / (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 <= 5e+225) tmp = Float64(J * Float64(Float64(-2.0 * t_0) * hypot(1.0, Float64(Float64(U_m / 2.0) / 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 <= 5e+225) tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (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, 5e+225], 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], (-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 5 \cdot 10^{+225}:\\
\;\;\;\;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)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 4.99999999999999981e225Initial program 76.0%
Simplified88.5%
if 4.99999999999999981e225 < U Initial program 27.9%
Simplified55.7%
Taylor expanded in J around 0 56.6%
neg-mul-156.6%
Simplified56.6%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 2.7e+98) (* J (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J)))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 2.7e+98) {
tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / 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.7e+98) {
tmp = J * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 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 <= 2.7e+98: tmp = J * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 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 <= 2.7e+98) 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(-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.7e+98) tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 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, 2.7e+98], 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], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 2.7 \cdot 10^{+98}:\\
\;\;\;\;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}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 2.7e98Initial program 81.1%
Simplified91.6%
Taylor expanded in K around 0 75.1%
if 2.7e98 < U Initial program 33.8%
Simplified61.2%
Taylor expanded in J around 0 45.8%
neg-mul-145.8%
Simplified45.8%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 8.5e-20) (* (* -2.0 J) (cos (* K 0.5))) (if (<= U_m 4.5e+97) (* (* -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 <= 8.5e-20) {
tmp = (-2.0 * J) * cos((K * 0.5));
} else if (U_m <= 4.5e+97) {
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 <= 8.5e-20) {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
} else if (U_m <= 4.5e+97) {
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 <= 8.5e-20: tmp = (-2.0 * J) * math.cos((K * 0.5)) elif U_m <= 4.5e+97: 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 <= 8.5e-20) tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))); elseif (U_m <= 4.5e+97) 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 <= 8.5e-20) tmp = (-2.0 * J) * cos((K * 0.5)); elseif (U_m <= 4.5e+97) 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, 8.5e-20], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 4.5e+97], 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 8.5 \cdot 10^{-20}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{elif}\;U\_m \leq 4.5 \cdot 10^{+97}:\\
\;\;\;\;\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 < 8.5000000000000005e-20Initial program 81.6%
Simplified90.4%
Taylor expanded in J around inf 61.3%
*-commutative61.3%
*-commutative61.3%
*-commutative61.3%
associate-*r*61.3%
*-commutative61.3%
*-commutative61.3%
Simplified61.3%
if 8.5000000000000005e-20 < U < 4.49999999999999976e97Initial program 77.7%
*-commutative77.7%
associate-*l*77.7%
unpow277.7%
hypot-1-def99.8%
associate-/r*99.8%
cos-neg99.8%
distribute-frac-neg99.8%
associate-/r*99.8%
associate-/r*99.8%
*-commutative99.8%
distribute-frac-neg99.8%
cos-neg99.8%
Simplified99.8%
log1p-expm1-u99.8%
div-inv99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in K around 0 47.8%
associate-*r*47.8%
metadata-eval47.8%
metadata-eval47.8%
unpow247.8%
unpow247.8%
times-frac47.9%
swap-sqr47.9%
hypot-undefine55.3%
Simplified55.3%
if 4.49999999999999976e97 < U Initial program 33.8%
Simplified61.2%
Taylor expanded in J around 0 45.8%
neg-mul-145.8%
Simplified45.8%
Final simplification57.6%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 0.205) (* (* -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 <= 0.205) {
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 <= 0.205d0) 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 <= 0.205) {
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 <= 0.205: 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 <= 0.205) 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 <= 0.205) 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, 0.205], 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 0.205:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 0.204999999999999988Initial program 81.5%
Simplified90.7%
Taylor expanded in J around inf 60.4%
*-commutative60.4%
*-commutative60.4%
*-commutative60.4%
associate-*r*60.4%
*-commutative60.4%
*-commutative60.4%
Simplified60.4%
if 0.204999999999999988 < U Initial program 46.4%
Simplified72.5%
Taylor expanded in J around 0 41.4%
neg-mul-141.4%
Simplified41.4%
Final simplification55.1%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 8.8e-13) (* -2.0 J) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 8.8e-13) {
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 <= 8.8d-13) 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 <= 8.8e-13) {
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 <= 8.8e-13: 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 <= 8.8e-13) 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 <= 8.8e-13) 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, 8.8e-13], N[(-2.0 * J), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 8.8 \cdot 10^{-13}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 8.79999999999999986e-13Initial program 81.6%
Simplified90.4%
Taylor expanded in J around inf 61.3%
*-commutative61.3%
*-commutative61.3%
*-commutative61.3%
associate-*r*61.3%
*-commutative61.3%
*-commutative61.3%
Simplified61.3%
*-commutative61.3%
expm1-log1p-u61.2%
Applied egg-rr61.2%
Taylor expanded in K around 0 36.4%
if 8.79999999999999986e-13 < U Initial program 48.6%
Simplified74.2%
Taylor expanded in J around 0 41.2%
neg-mul-141.2%
Simplified41.2%
Final simplification37.8%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= K 9.5e+138) (- U_m) U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (K <= 9.5e+138) {
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 <= 9.5d+138) 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 <= 9.5e+138) {
tmp = -U_m;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if K <= 9.5e+138: tmp = -U_m else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (K <= 9.5e+138) 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 <= 9.5e+138) 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, 9.5e+138], (-U$95$m), U$95$m]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 9.5 \cdot 10^{+138}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if K < 9.49999999999999998e138Initial program 71.9%
Simplified84.4%
Taylor expanded in J around 0 25.7%
neg-mul-125.7%
Simplified25.7%
if 9.49999999999999998e138 < K Initial program 70.1%
Simplified92.2%
Taylor expanded in U around -inf 33.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 71.7%
Simplified85.5%
Taylor expanded in U around -inf 29.8%
herbie shell --seed 2024137
(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)))))