
(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)) (- 0.0 U_m) (if (<= t_1 1e+306) 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 = 0.0 - U_m;
} else if (t_1 <= 1e+306) {
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 = 0.0 - U_m;
} else if (t_1 <= 1e+306) {
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 = 0.0 - U_m elif t_1 <= 1e+306: 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(0.0 - U_m); elseif (t_1 <= 1e+306) 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 = 0.0 - U_m; elseif (t_1 <= 1e+306) 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)], N[(0.0 - U$95$m), $MachinePrecision], If[LessEqual[t$95$1, 1e+306], 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:\\
\;\;\;\;0 - U\_m\\
\mathbf{elif}\;t\_1 \leq 10^{+306}:\\
\;\;\;\;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%
Taylor expanded in J around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6444.5%
Simplified44.5%
sub0-negN/A
neg-lowering-neg.f6444.5%
Applied egg-rr44.5%
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.00000000000000002e306Initial program 99.8%
if 1.00000000000000002e306 < (*.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.3%
Taylor expanded in U around -inf
Simplified42.9%
Final simplification86.7%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.6555)
(+ U_m (* J (* J (/ 2.0 U_m))))
(if (<= t_0 0.785)
(* (* -2.0 J) (cos (* K 0.5)))
(* (* -2.0 J) (hypot 1.0 (* 0.5 (/ U_m J))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.6555) {
tmp = U_m + (J * (J * (2.0 / U_m)));
} else if (t_0 <= 0.785) {
tmp = (-2.0 * J) * cos((K * 0.5));
} else {
tmp = (-2.0 * J) * hypot(1.0, (0.5 * (U_m / J)));
}
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 (t_0 <= -0.6555) {
tmp = U_m + (J * (J * (2.0 / U_m)));
} else if (t_0 <= 0.785) {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
} else {
tmp = (-2.0 * J) * Math.hypot(1.0, (0.5 * (U_m / J)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= -0.6555: tmp = U_m + (J * (J * (2.0 / U_m))) elif t_0 <= 0.785: tmp = (-2.0 * J) * math.cos((K * 0.5)) else: tmp = (-2.0 * J) * math.hypot(1.0, (0.5 * (U_m / J))) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.6555) tmp = Float64(U_m + Float64(J * Float64(J * Float64(2.0 / U_m)))); elseif (t_0 <= 0.785) tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))); else tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(0.5 * Float64(U_m / J)))); 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 (t_0 <= -0.6555) tmp = U_m + (J * (J * (2.0 / U_m))); elseif (t_0 <= 0.785) tmp = (-2.0 * J) * cos((K * 0.5)); else tmp = (-2.0 * J) * hypot(1.0, (0.5 * (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 / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.6555], N[(U$95$m + N[(J * N[(J * N[(2.0 / U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.785], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.6555:\\
\;\;\;\;U\_m + J \cdot \left(J \cdot \frac{2}{U\_m}\right)\\
\mathbf{elif}\;t\_0 \leq 0.785:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U\_m}{J}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.6555Initial program 84.3%
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
unpow2N/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f6493.1%
Simplified93.1%
Taylor expanded in K around 0
*-lowering-*.f64N/A
/-lowering-/.f6452.6%
Simplified52.6%
Taylor expanded in K around 0
*-lowering-*.f641.5%
Simplified1.5%
Taylor expanded in U around -inf
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6421.2%
Simplified21.2%
Taylor expanded in J around 0
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f6435.0%
Simplified35.0%
if -0.6555 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.785000000000000031Initial program 82.1%
Taylor expanded in J around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6468.6%
Simplified68.6%
if 0.785000000000000031 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 73.9%
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
unpow2N/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f6488.6%
Simplified88.6%
Taylor expanded in K around 0
*-lowering-*.f64N/A
/-lowering-/.f6482.0%
Simplified82.0%
Taylor expanded in K around 0
*-lowering-*.f6483.7%
Simplified83.7%
Final simplification71.9%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U_m 1.4e+212)
(* (* (* -2.0 J) t_0) (hypot 1.0 (/ (/ U_m (* J 2.0)) t_0)))
(- 0.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 <= 1.4e+212) {
tmp = ((-2.0 * J) * t_0) * hypot(1.0, ((U_m / (J * 2.0)) / t_0));
} else {
tmp = 0.0 - 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 <= 1.4e+212) {
tmp = ((-2.0 * J) * t_0) * Math.hypot(1.0, ((U_m / (J * 2.0)) / t_0));
} else {
tmp = 0.0 - 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 <= 1.4e+212: tmp = ((-2.0 * J) * t_0) * math.hypot(1.0, ((U_m / (J * 2.0)) / t_0)) else: tmp = 0.0 - 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 <= 1.4e+212) tmp = Float64(Float64(Float64(-2.0 * J) * t_0) * hypot(1.0, Float64(Float64(U_m / Float64(J * 2.0)) / t_0))); else tmp = Float64(0.0 - 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 <= 1.4e+212) tmp = ((-2.0 * J) * t_0) * hypot(1.0, ((U_m / (J * 2.0)) / t_0)); else tmp = 0.0 - 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, 1.4e+212], N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(0.0 - U$95$m), $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 1.4 \cdot 10^{+212}:\\
\;\;\;\;\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{J \cdot 2}}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;0 - U\_m\\
\end{array}
\end{array}
if U < 1.39999999999999999e212Initial program 80.8%
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
unpow2N/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f6491.9%
Simplified91.9%
if 1.39999999999999999e212 < U Initial program 30.5%
Taylor expanded in J around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6438.6%
Simplified38.6%
sub0-negN/A
neg-lowering-neg.f6438.6%
Applied egg-rr38.6%
Final simplification88.6%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 4e-100) (- 0.0 U_m) (* (* (* -2.0 J) (cos (/ K 2.0))) (hypot 1.0 (* 0.5 (/ U_m J))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 4e-100) {
tmp = 0.0 - U_m;
} else {
tmp = ((-2.0 * J) * cos((K / 2.0))) * hypot(1.0, (0.5 * (U_m / J)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 4e-100) {
tmp = 0.0 - U_m;
} else {
tmp = ((-2.0 * J) * Math.cos((K / 2.0))) * Math.hypot(1.0, (0.5 * (U_m / J)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 4e-100: tmp = 0.0 - U_m else: tmp = ((-2.0 * J) * math.cos((K / 2.0))) * math.hypot(1.0, (0.5 * (U_m / J))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 4e-100) tmp = Float64(0.0 - U_m); else tmp = Float64(Float64(Float64(-2.0 * J) * cos(Float64(K / 2.0))) * hypot(1.0, Float64(0.5 * 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 <= 4e-100) tmp = 0.0 - U_m; else tmp = ((-2.0 * J) * cos((K / 2.0))) * hypot(1.0, (0.5 * (U_m / J))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 4e-100], N[(0.0 - U$95$m), $MachinePrecision], N[(N[(N[(-2.0 * J), $MachinePrecision] * 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]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 4 \cdot 10^{-100}:\\
\;\;\;\;0 - U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U\_m}{J}\right)\\
\end{array}
\end{array}
if J < 4.0000000000000001e-100Initial program 71.1%
Taylor expanded in J around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6431.1%
Simplified31.1%
sub0-negN/A
neg-lowering-neg.f6431.1%
Applied egg-rr31.1%
if 4.0000000000000001e-100 < J Initial program 91.8%
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
unpow2N/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f6497.5%
Simplified97.5%
Taylor expanded in K around 0
*-lowering-*.f64N/A
/-lowering-/.f6490.0%
Simplified90.0%
Final simplification49.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 3.8e-79) (- 0.0 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 <= 3.8e-79) {
tmp = 0.0 - 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 <= 3.8d-79) then
tmp = 0.0d0 - 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 <= 3.8e-79) {
tmp = 0.0 - 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 <= 3.8e-79: tmp = 0.0 - 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 <= 3.8e-79) tmp = Float64(0.0 - 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 <= 3.8e-79) tmp = 0.0 - 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, 3.8e-79], N[(0.0 - U$95$m), $MachinePrecision], 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 3.8 \cdot 10^{-79}:\\
\;\;\;\;0 - U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\end{array}
\end{array}
if J < 3.8000000000000001e-79Initial program 70.9%
Taylor expanded in J around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6431.3%
Simplified31.3%
sub0-negN/A
neg-lowering-neg.f6431.3%
Applied egg-rr31.3%
if 3.8000000000000001e-79 < J Initial program 92.8%
Taylor expanded in J around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6475.4%
Simplified75.4%
Final simplification44.9%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 5.1e-110) (* -2.0 J) (- 0.0 U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 5.1e-110) {
tmp = -2.0 * J;
} else {
tmp = 0.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 <= 5.1d-110) then
tmp = (-2.0d0) * j
else
tmp = 0.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 <= 5.1e-110) {
tmp = -2.0 * J;
} else {
tmp = 0.0 - U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 5.1e-110: tmp = -2.0 * J else: tmp = 0.0 - U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 5.1e-110) tmp = Float64(-2.0 * J); else tmp = Float64(0.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 <= 5.1e-110) tmp = -2.0 * J; else tmp = 0.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, 5.1e-110], N[(-2.0 * J), $MachinePrecision], N[(0.0 - U$95$m), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 5.1 \cdot 10^{-110}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;0 - U\_m\\
\end{array}
\end{array}
if U < 5.1000000000000002e-110Initial program 81.4%
Taylor expanded in J around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6460.7%
Simplified60.7%
Taylor expanded in K around 0
*-lowering-*.f6434.9%
Simplified34.9%
if 5.1000000000000002e-110 < U Initial program 69.6%
Taylor expanded in J around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6437.5%
Simplified37.5%
sub0-negN/A
neg-lowering-neg.f6437.5%
Applied egg-rr37.5%
Final simplification35.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (- 0.0 U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
return 0.0 - 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 = 0.0d0 - u_m
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
return 0.0 - U_m;
}
U_m = math.fabs(U) def code(J, K, U_m): return 0.0 - U_m
U_m = abs(U) function code(J, K, U_m) return Float64(0.0 - U_m) end
U_m = abs(U); function tmp = code(J, K, U_m) tmp = 0.0 - U_m; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := N[(0.0 - U$95$m), $MachinePrecision]
\begin{array}{l}
U_m = \left|U\right|
\\
0 - U\_m
\end{array}
Initial program 77.7%
Taylor expanded in J around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6425.6%
Simplified25.6%
sub0-negN/A
neg-lowering-neg.f6425.6%
Applied egg-rr25.6%
Final simplification25.6%
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 77.7%
Taylor expanded in U around -inf
Simplified25.3%
herbie shell --seed 2024139
(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)))))