
(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 1e+308) 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+308) {
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+308) {
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+308: 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+308) 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+308) 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+308], 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^{+308}:\\
\;\;\;\;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.3%
Simplified60.2%
Taylor expanded in J around 0 51.9%
neg-mul-151.9%
Simplified51.9%
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))))) < 1e308Initial program 99.8%
if 1e308 < (*.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%
Simplified57.3%
Taylor expanded in U around -inf 48.2%
Final simplification84.4%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= J 2.1e-197)
(- U_m)
(* 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));
double tmp;
if (J <= 2.1e-197) {
tmp = -U_m;
} else {
tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (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 <= 2.1e-197) {
tmp = -U_m;
} else {
tmp = J * ((-2.0 * t_0) * Math.hypot(1.0, ((U_m / 2.0) / (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 <= 2.1e-197: tmp = -U_m else: tmp = J * ((-2.0 * t_0) * math.hypot(1.0, ((U_m / 2.0) / (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 <= 2.1e-197) tmp = Float64(-U_m); else tmp = Float64(J * Float64(Float64(-2.0 * t_0) * hypot(1.0, Float64(Float64(U_m / 2.0) / 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 <= 2.1e-197) tmp = -U_m; else tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (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, 2.1e-197], (-U$95$m), 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)\\
\mathbf{if}\;J \leq 2.1 \cdot 10^{-197}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;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}
if J < 2.1e-197Initial program 65.5%
Simplified84.1%
Taylor expanded in J around 0 26.2%
neg-mul-126.2%
Simplified26.2%
if 2.1e-197 < J Initial program 78.6%
Simplified91.5%
Final simplification52.2%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 8e+123) (* 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 <= 8e+123) {
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 <= 8e+123) {
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 <= 8e+123: 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 <= 8e+123) 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 <= 8e+123) 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, 8e+123], 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 8 \cdot 10^{+123}:\\
\;\;\;\;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 < 7.99999999999999982e123Initial program 77.1%
Simplified92.4%
Taylor expanded in K around 0 76.9%
if 7.99999999999999982e123 < U Initial program 35.4%
Simplified57.1%
Taylor expanded in J around 0 39.3%
neg-mul-139.3%
Simplified39.3%
Final simplification71.1%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= J 1.12e-79) (and (not (<= J 8.2e-10)) (<= J 4e+30))) (- 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 <= 1.12e-79) || (!(J <= 8.2e-10) && (J <= 4e+30))) {
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 <= 1.12d-79) .or. (.not. (j <= 8.2d-10)) .and. (j <= 4d+30)) 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 <= 1.12e-79) || (!(J <= 8.2e-10) && (J <= 4e+30))) {
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 <= 1.12e-79) or (not (J <= 8.2e-10) and (J <= 4e+30)): 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 <= 1.12e-79) || (!(J <= 8.2e-10) && (J <= 4e+30))) 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 <= 1.12e-79) || (~((J <= 8.2e-10)) && (J <= 4e+30))) 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[Or[LessEqual[J, 1.12e-79], And[N[Not[LessEqual[J, 8.2e-10]], $MachinePrecision], LessEqual[J, 4e+30]]], (-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 1.12 \cdot 10^{-79} \lor \neg \left(J \leq 8.2 \cdot 10^{-10}\right) \land J \leq 4 \cdot 10^{+30}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\end{array}
\end{array}
if J < 1.11999999999999996e-79 or 8.1999999999999996e-10 < J < 4.0000000000000001e30Initial program 63.1%
Simplified83.1%
Taylor expanded in J around 0 28.6%
neg-mul-128.6%
Simplified28.6%
if 1.11999999999999996e-79 < J < 8.1999999999999996e-10 or 4.0000000000000001e30 < J Initial program 90.6%
Simplified97.2%
Taylor expanded in J around inf 74.4%
associate-*r*74.4%
*-commutative74.4%
*-commutative74.4%
*-commutative74.4%
*-commutative74.4%
*-commutative74.4%
Simplified74.4%
Final simplification41.3%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= U_m 1.1e-146)
(* (* -2.0 J) (cos (* K 0.5)))
(if (<= U_m 4.5e+103)
(* (* -2.0 J) (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 <= 1.1e-146) {
tmp = (-2.0 * J) * cos((K * 0.5));
} else if (U_m <= 4.5e+103) {
tmp = (-2.0 * J) * 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 <= 1.1e-146) {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
} else if (U_m <= 4.5e+103) {
tmp = (-2.0 * J) * 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 <= 1.1e-146: tmp = (-2.0 * J) * math.cos((K * 0.5)) elif U_m <= 4.5e+103: tmp = (-2.0 * J) * 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 <= 1.1e-146) tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))); elseif (U_m <= 4.5e+103) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(U_m * Float64(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 <= 1.1e-146) tmp = (-2.0 * J) * cos((K * 0.5)); elseif (U_m <= 4.5e+103) tmp = (-2.0 * J) * 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, 1.1e-146], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 4.5e+103], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U$95$m * N[(0.5 / 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.1 \cdot 10^{-146}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{elif}\;U\_m \leq 4.5 \cdot 10^{+103}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, U\_m \cdot \frac{0.5}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1.1e-146Initial program 78.0%
Simplified92.2%
Taylor expanded in J around inf 59.0%
associate-*r*59.0%
*-commutative59.0%
*-commutative59.0%
*-commutative59.0%
*-commutative59.0%
*-commutative59.0%
Simplified59.0%
if 1.1e-146 < U < 4.50000000000000001e103Initial program 76.3%
Simplified97.5%
Taylor expanded in K around 0 75.5%
Taylor expanded in K around 0 39.9%
associate-*r*39.9%
rem-square-sqrt0.0%
unpow20.0%
*-commutative0.0%
*-commutative0.0%
Simplified63.6%
if 4.50000000000000001e103 < U Initial program 35.5%
Simplified55.6%
Taylor expanded in J around 0 39.0%
neg-mul-139.0%
Simplified39.0%
Final simplification56.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 7.5e+57) (- U_m) (* -2.0 J)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 7.5e+57) {
tmp = -U_m;
} else {
tmp = -2.0 * J;
}
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 <= 7.5d+57) then
tmp = -u_m
else
tmp = (-2.0d0) * j
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 <= 7.5e+57) {
tmp = -U_m;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 7.5e+57: tmp = -U_m else: tmp = -2.0 * J return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 7.5e+57) tmp = Float64(-U_m); else tmp = Float64(-2.0 * J); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 7.5e+57) tmp = -U_m; else tmp = -2.0 * J; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 7.5e+57], (-U$95$m), N[(-2.0 * J), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 7.5 \cdot 10^{+57}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 7.5000000000000006e57Initial program 63.5%
Simplified83.5%
Taylor expanded in J around 0 29.1%
neg-mul-129.1%
Simplified29.1%
if 7.5000000000000006e57 < J Initial program 96.5%
Simplified99.8%
Applied egg-rr97.6%
rem-cube-cbrt99.7%
*-commutative99.7%
add-sqr-sqrt99.2%
associate-*r*99.2%
*-commutative99.2%
associate-*l*99.2%
associate-*r/99.3%
associate-*r/99.3%
Applied egg-rr99.3%
Taylor expanded in K around 0 44.1%
associate-*r*44.1%
metadata-eval44.1%
unpow244.1%
unpow244.1%
times-frac66.2%
swap-sqr66.2%
unpow266.2%
associate-*r/66.2%
*-commutative66.2%
Simplified66.2%
Taylor expanded in J around inf 52.5%
Final simplification34.2%
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 Float64(-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.8%
Simplified87.0%
Taylor expanded in J around 0 25.5%
neg-mul-125.5%
Simplified25.5%
Final simplification25.5%
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.8%
Simplified87.0%
Taylor expanded in U around -inf 29.0%
Final simplification29.0%
herbie shell --seed 2024077
(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)))))