
(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)))))
(t_2 (* J t_0)))
(if (<= t_1 (- INFINITY))
(- U_m)
(if (<= t_1 5e+305)
(* -2.0 (* t_2 (hypot 1.0 (/ (/ U_m 2.0) t_2))))
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 t_2 = J * t_0;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_1 <= 5e+305) {
tmp = -2.0 * (t_2 * hypot(1.0, ((U_m / 2.0) / t_2)));
} 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 t_2 = J * t_0;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U_m;
} else if (t_1 <= 5e+305) {
tmp = -2.0 * (t_2 * Math.hypot(1.0, ((U_m / 2.0) / t_2)));
} 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))) t_2 = J * t_0 tmp = 0 if t_1 <= -math.inf: tmp = -U_m elif t_1 <= 5e+305: tmp = -2.0 * (t_2 * math.hypot(1.0, ((U_m / 2.0) / t_2))) 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)))) t_2 = Float64(J * t_0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_1 <= 5e+305) tmp = Float64(-2.0 * Float64(t_2 * hypot(1.0, Float64(Float64(U_m / 2.0) / t_2)))); 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))); t_2 = J * t_0; tmp = 0.0; if (t_1 <= -Inf) tmp = -U_m; elseif (t_1 <= 5e+305) tmp = -2.0 * (t_2 * hypot(1.0, ((U_m / 2.0) / t_2))); 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]}, Block[{t$95$2 = N[(J * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U$95$m), If[LessEqual[t$95$1, 5e+305], N[(-2.0 * N[(t$95$2 * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / t$95$2), $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)\\
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}}\\
t_2 := J \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;-2 \cdot \left(t\_2 \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{t\_2}\right)\right)\\
\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 6.2%
Simplified6.2%
Taylor expanded in J around 0 39.1%
mul-1-neg39.1%
Simplified39.1%
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)))) < 5.00000000000000009e305Initial program 99.8%
unpow299.8%
sqr-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg99.8%
unpow299.8%
associate-*l*99.8%
associate-*l*99.8%
Simplified99.8%
if 5.00000000000000009e305 < (*.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.9%
Simplified7.9%
Taylor expanded in U around -inf 43.5%
Final simplification82.7%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (* K 0.5))))
(if (<= J 1.5e-95)
(- U_m)
(+ (* -2.0 (* J t_0)) (* -0.25 (* (/ U_m t_0) (/ U_m J)))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K * 0.5));
double tmp;
if (J <= 1.5e-95) {
tmp = -U_m;
} else {
tmp = (-2.0 * (J * t_0)) + (-0.25 * ((U_m / t_0) * (U_m / 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) :: t_0
real(8) :: tmp
t_0 = cos((k * 0.5d0))
if (j <= 1.5d-95) then
tmp = -u_m
else
tmp = ((-2.0d0) * (j * t_0)) + ((-0.25d0) * ((u_m / t_0) * (u_m / j)))
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K * 0.5));
double tmp;
if (J <= 1.5e-95) {
tmp = -U_m;
} else {
tmp = (-2.0 * (J * t_0)) + (-0.25 * ((U_m / t_0) * (U_m / J)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K * 0.5)) tmp = 0 if J <= 1.5e-95: tmp = -U_m else: tmp = (-2.0 * (J * t_0)) + (-0.25 * ((U_m / t_0) * (U_m / J))) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K * 0.5)) tmp = 0.0 if (J <= 1.5e-95) tmp = Float64(-U_m); else tmp = Float64(Float64(-2.0 * Float64(J * t_0)) + Float64(-0.25 * Float64(Float64(U_m / t_0) * Float64(U_m / J)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K * 0.5)); tmp = 0.0; if (J <= 1.5e-95) tmp = -U_m; else tmp = (-2.0 * (J * t_0)) + (-0.25 * ((U_m / t_0) * (U_m / J))); 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 * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[J, 1.5e-95], (-U$95$m), N[(N[(-2.0 * N[(J * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(N[(U$95$m / t$95$0), $MachinePrecision] * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq 1.5 \cdot 10^{-95}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot t\_0\right) + -0.25 \cdot \left(\frac{U\_m}{t\_0} \cdot \frac{U\_m}{J}\right)\\
\end{array}
\end{array}
if J < 1.5e-95Initial program 64.8%
Simplified64.8%
Taylor expanded in J around 0 27.0%
mul-1-neg27.0%
Simplified27.0%
if 1.5e-95 < J Initial program 89.5%
Simplified89.5%
Taylor expanded in J around inf 64.5%
unpow264.5%
*-commutative64.5%
times-frac71.4%
*-commutative71.4%
Applied egg-rr71.4%
Final simplification41.1%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 1.75e-95) (- U_m) (+ (* -2.0 (* J (cos (* K 0.5)))) (* -0.25 (* U_m (/ U_m J))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 1.75e-95) {
tmp = -U_m;
} else {
tmp = (-2.0 * (J * cos((K * 0.5)))) + (-0.25 * (U_m * (U_m / 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 <= 1.75d-95) then
tmp = -u_m
else
tmp = ((-2.0d0) * (j * cos((k * 0.5d0)))) + ((-0.25d0) * (u_m * (u_m / 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 <= 1.75e-95) {
tmp = -U_m;
} else {
tmp = (-2.0 * (J * Math.cos((K * 0.5)))) + (-0.25 * (U_m * (U_m / J)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 1.75e-95: tmp = -U_m else: tmp = (-2.0 * (J * math.cos((K * 0.5)))) + (-0.25 * (U_m * (U_m / J))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 1.75e-95) tmp = Float64(-U_m); else tmp = Float64(Float64(-2.0 * Float64(J * cos(Float64(K * 0.5)))) + Float64(-0.25 * Float64(U_m * Float64(U_m / J)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 1.75e-95) tmp = -U_m; else tmp = (-2.0 * (J * cos((K * 0.5)))) + (-0.25 * (U_m * (U_m / J))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 1.75e-95], (-U$95$m), N[(N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(U$95$m * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 1.75 \cdot 10^{-95}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right) + -0.25 \cdot \left(U\_m \cdot \frac{U\_m}{J}\right)\\
\end{array}
\end{array}
if J < 1.7499999999999999e-95Initial program 64.8%
Simplified64.8%
Taylor expanded in J around 0 27.0%
mul-1-neg27.0%
Simplified27.0%
if 1.7499999999999999e-95 < J Initial program 89.5%
Simplified89.5%
Taylor expanded in J around inf 64.5%
Taylor expanded in K around 0 63.5%
*-commutative63.5%
Simplified63.5%
unpow263.5%
*-un-lft-identity63.5%
times-frac70.5%
Applied egg-rr70.5%
Final simplification40.8%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 1.9e-95) (- 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.9e-95) {
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.9d-95) 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.9e-95) {
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.9e-95: 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.9e-95) 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.9e-95) 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, 1.9e-95], (-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.9 \cdot 10^{-95}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\end{array}
\end{array}
if J < 1.8999999999999999e-95Initial program 64.8%
Simplified64.8%
Taylor expanded in J around 0 27.0%
mul-1-neg27.0%
Simplified27.0%
if 1.8999999999999999e-95 < J Initial program 89.5%
Simplified89.5%
Taylor expanded in J around inf 70.8%
associate-*r*70.8%
Simplified70.8%
Final simplification40.9%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 5.4e-45) (+ (* -2.0 J) (* -0.25 (/ (* U_m U_m) J))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 5.4e-45) {
tmp = (-2.0 * J) + (-0.25 * ((U_m * U_m) / 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 <= 5.4d-45) then
tmp = ((-2.0d0) * j) + ((-0.25d0) * ((u_m * u_m) / 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 <= 5.4e-45) {
tmp = (-2.0 * J) + (-0.25 * ((U_m * 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 <= 5.4e-45: tmp = (-2.0 * J) + (-0.25 * ((U_m * 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 <= 5.4e-45) tmp = Float64(Float64(-2.0 * J) + Float64(-0.25 * Float64(Float64(U_m * 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 <= 5.4e-45) tmp = (-2.0 * J) + (-0.25 * ((U_m * 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, 5.4e-45], N[(N[(-2.0 * J), $MachinePrecision] + N[(-0.25 * N[(N[(U$95$m * U$95$m), $MachinePrecision] / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 5.4 \cdot 10^{-45}:\\
\;\;\;\;-2 \cdot J + -0.25 \cdot \frac{U\_m \cdot U\_m}{J}\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 5.3999999999999997e-45Initial program 77.3%
Simplified77.3%
Taylor expanded in J around inf 60.1%
Taylor expanded in K around 0 59.5%
*-commutative59.5%
Simplified59.5%
Taylor expanded in K around 0 34.5%
unpow234.5%
Applied egg-rr34.5%
if 5.3999999999999997e-45 < U Initial program 59.8%
Simplified59.8%
Taylor expanded in J around 0 27.8%
mul-1-neg27.8%
Simplified27.8%
Final simplification32.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= K 4.7e+61) (not (<= K 4.4e+169))) (- U_m) U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if ((K <= 4.7e+61) || !(K <= 4.4e+169)) {
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 <= 4.7d+61) .or. (.not. (k <= 4.4d+169))) 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 <= 4.7e+61) || !(K <= 4.4e+169)) {
tmp = -U_m;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if (K <= 4.7e+61) or not (K <= 4.4e+169): tmp = -U_m else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if ((K <= 4.7e+61) || !(K <= 4.4e+169)) 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 <= 4.7e+61) || ~((K <= 4.4e+169))) 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[Or[LessEqual[K, 4.7e+61], N[Not[LessEqual[K, 4.4e+169]], $MachinePrecision]], (-U$95$m), U$95$m]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 4.7 \cdot 10^{+61} \lor \neg \left(K \leq 4.4 \cdot 10^{+169}\right):\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if K < 4.6999999999999998e61 or 4.4e169 < K Initial program 73.1%
Simplified73.1%
Taylor expanded in J around 0 24.4%
mul-1-neg24.4%
Simplified24.4%
if 4.6999999999999998e61 < K < 4.4e169Initial program 65.6%
Simplified65.6%
Taylor expanded in U around -inf 44.3%
Final simplification25.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 1.95e-44) (* -2.0 J) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.95e-44) {
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 <= 1.95d-44) 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 <= 1.95e-44) {
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 <= 1.95e-44: 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 <= 1.95e-44) 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 <= 1.95e-44) 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, 1.95e-44], N[(-2.0 * J), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 1.95 \cdot 10^{-44}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1.9500000000000001e-44Initial program 77.3%
Simplified77.3%
Taylor expanded in J around inf 61.9%
associate-*r*61.9%
Simplified61.9%
Taylor expanded in K around 0 35.6%
*-commutative35.6%
Simplified35.6%
if 1.9500000000000001e-44 < U Initial program 59.8%
Simplified59.8%
Taylor expanded in J around 0 27.8%
mul-1-neg27.8%
Simplified27.8%
Final simplification33.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 72.6%
Simplified72.6%
Taylor expanded in U around -inf 28.0%
Final simplification28.0%
herbie shell --seed 2024036
(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)))))