
(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
(*
(* t_0 (* -2.0 J))
(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 2e+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 = (t_0 * (-2.0 * J)) * 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 <= 2e+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 = (t_0 * (-2.0 * J)) * 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 <= 2e+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 = (t_0 * (-2.0 * J)) * 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 <= 2e+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(t_0 * Float64(-2.0 * J)) * 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 <= 2e+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 = (t_0 * (-2.0 * J)) * 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 <= 2e+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[(t$95$0 * N[(-2.0 * J), $MachinePrecision]), $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, 2e+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(t_0 \cdot \left(-2 \cdot J\right)\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 2 \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 5.4%
Simplified5.4%
Taylor expanded in J around 0 52.0%
mul-1-neg52.0%
Simplified52.0%
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.9999999999999999e305Initial program 99.8%
associate-*l*99.8%
associate-*l*99.8%
unpow299.8%
sqr-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg99.8%
unpow299.8%
Simplified99.8%
if 1.9999999999999999e305 < (*.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 5.0%
Simplified5.0%
Taylor expanded in U around -inf 46.0%
Final simplification85.1%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= J 4.1e-225)
(- U_m)
(*
-2.0
(*
(* J (cos (/ K 2.0)))
(hypot 1.0 (* (/ U_m (cos (* K 0.5))) (/ 0.5 J)))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 4.1e-225) {
tmp = -U_m;
} else {
tmp = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, ((U_m / cos((K * 0.5))) * (0.5 / J))));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 4.1e-225) {
tmp = -U_m;
} else {
tmp = -2.0 * ((J * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / Math.cos((K * 0.5))) * (0.5 / J))));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 4.1e-225: tmp = -U_m else: tmp = -2.0 * ((J * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / math.cos((K * 0.5))) * (0.5 / J)))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 4.1e-225) tmp = Float64(-U_m); else tmp = Float64(-2.0 * Float64(Float64(J * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / cos(Float64(K * 0.5))) * Float64(0.5 / J))))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 4.1e-225) tmp = -U_m; else tmp = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, ((U_m / cos((K * 0.5))) * (0.5 / J)))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 4.1e-225], (-U$95$m), N[(-2.0 * N[(N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 4.1 \cdot 10^{-225}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U_m}{\cos \left(K \cdot 0.5\right)} \cdot \frac{0.5}{J}\right)\right)\\
\end{array}
\end{array}
if J < 4.10000000000000022e-225Initial program 63.8%
Simplified63.8%
Taylor expanded in J around 0 29.3%
mul-1-neg29.3%
Simplified29.3%
if 4.10000000000000022e-225 < J Initial program 86.2%
associate-*l*86.2%
associate-*l*86.2%
unpow286.2%
sqr-neg86.2%
distribute-frac-neg86.2%
distribute-frac-neg86.2%
unpow286.2%
Simplified92.7%
div-inv92.7%
metadata-eval92.7%
*-commutative92.7%
times-frac92.6%
div-inv92.6%
metadata-eval92.6%
Applied egg-rr92.6%
Final simplification54.8%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 5.8e+97) (* -2.0 (* (* J (cos (/ K 2.0))) (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 <= 5.8e+97) {
tmp = -2.0 * ((J * cos((K / 2.0))) * 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 <= 5.8e+97) {
tmp = -2.0 * ((J * Math.cos((K / 2.0))) * 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 <= 5.8e+97: tmp = -2.0 * ((J * math.cos((K / 2.0))) * 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 <= 5.8e+97) tmp = Float64(-2.0 * Float64(Float64(J * cos(Float64(K / 2.0))) * 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 <= 5.8e+97) tmp = -2.0 * ((J * cos((K / 2.0))) * 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, 5.8e+97], N[(-2.0 * N[(N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U$95$m * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U_m \leq 5.8 \cdot 10^{+97}:\\
\;\;\;\;-2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, U_m \cdot \frac{0.5}{J}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U_m\\
\end{array}
\end{array}
if U < 5.79999999999999974e97Initial program 77.2%
associate-*l*77.2%
associate-*l*77.2%
unpow277.2%
sqr-neg77.2%
distribute-frac-neg77.2%
distribute-frac-neg77.2%
unpow277.2%
Simplified92.0%
div-inv92.0%
metadata-eval92.0%
*-commutative92.0%
times-frac91.9%
div-inv91.9%
metadata-eval91.9%
Applied egg-rr91.9%
Taylor expanded in K around 0 77.7%
if 5.79999999999999974e97 < U Initial program 38.7%
Simplified38.7%
Taylor expanded in J around 0 51.9%
mul-1-neg51.9%
Simplified51.9%
Final simplification74.8%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 7.5e+97) (* -2.0 (* (* J (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 <= 7.5e+97) {
tmp = -2.0 * ((J * 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 <= 7.5e+97) {
tmp = -2.0 * ((J * 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 <= 7.5e+97: tmp = -2.0 * ((J * 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 <= 7.5e+97) tmp = Float64(-2.0 * Float64(Float64(J * 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 <= 7.5e+97) tmp = -2.0 * ((J * 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, 7.5e+97], N[(-2.0 * N[(N[(J * 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 7.5 \cdot 10^{+97}:\\
\;\;\;\;-2 \cdot \left(\left(J \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.5000000000000004e97Initial program 77.2%
associate-*l*77.2%
associate-*l*77.2%
unpow277.2%
sqr-neg77.2%
distribute-frac-neg77.2%
distribute-frac-neg77.2%
unpow277.2%
Simplified92.0%
Taylor expanded in K around 0 77.8%
if 7.5000000000000004e97 < U Initial program 38.7%
Simplified38.7%
Taylor expanded in J around 0 51.9%
mul-1-neg51.9%
Simplified51.9%
Final simplification74.8%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= J 4.2e-130)
(- U_m)
(if (<= J 1e-16)
(* -2.0 (* J (hypot 1.0 (* U_m (/ -0.5 J)))))
(if (<= J 1.85e-14) (- 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 <= 4.2e-130) {
tmp = -U_m;
} else if (J <= 1e-16) {
tmp = -2.0 * (J * hypot(1.0, (U_m * (-0.5 / J))));
} else if (J <= 1.85e-14) {
tmp = -U_m;
} else {
tmp = -2.0 * (J * cos((K * 0.5)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 4.2e-130) {
tmp = -U_m;
} else if (J <= 1e-16) {
tmp = -2.0 * (J * Math.hypot(1.0, (U_m * (-0.5 / J))));
} else if (J <= 1.85e-14) {
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 <= 4.2e-130: tmp = -U_m elif J <= 1e-16: tmp = -2.0 * (J * math.hypot(1.0, (U_m * (-0.5 / J)))) elif J <= 1.85e-14: 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 <= 4.2e-130) tmp = Float64(-U_m); elseif (J <= 1e-16) tmp = Float64(-2.0 * Float64(J * hypot(1.0, Float64(U_m * Float64(-0.5 / J))))); elseif (J <= 1.85e-14) tmp = Float64(-U_m); else tmp = Float64(-2.0 * Float64(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 <= 4.2e-130) tmp = -U_m; elseif (J <= 1e-16) tmp = -2.0 * (J * hypot(1.0, (U_m * (-0.5 / J)))); elseif (J <= 1.85e-14) 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, 4.2e-130], (-U$95$m), If[LessEqual[J, 1e-16], N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(U$95$m * N[(-0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.85e-14], (-U$95$m), N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 4.2 \cdot 10^{-130}:\\
\;\;\;\;-U_m\\
\mathbf{elif}\;J \leq 10^{-16}:\\
\;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, U_m \cdot \frac{-0.5}{J}\right)\right)\\
\mathbf{elif}\;J \leq 1.85 \cdot 10^{-14}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if J < 4.20000000000000004e-130 or 9.9999999999999998e-17 < J < 1.85000000000000001e-14Initial program 63.3%
Simplified63.3%
Taylor expanded in J around 0 31.7%
mul-1-neg31.7%
Simplified31.7%
if 4.20000000000000004e-130 < J < 9.9999999999999998e-17Initial program 71.9%
associate-*l*71.9%
associate-*l*71.9%
unpow271.9%
sqr-neg71.9%
distribute-frac-neg71.9%
distribute-frac-neg71.9%
unpow271.9%
Simplified90.9%
add-cbrt-cube66.8%
pow366.8%
div-inv66.8%
metadata-eval66.8%
Applied egg-rr66.8%
rem-cbrt-cube90.9%
add-cube-cbrt89.9%
associate-*r*90.1%
pow290.1%
Applied egg-rr90.1%
Taylor expanded in K around 0 50.5%
unpow250.5%
unpow250.5%
times-frac50.5%
unpow250.5%
*-commutative50.5%
*-commutative50.5%
metadata-eval50.5%
unpow250.5%
swap-sqr50.5%
*-commutative50.5%
associate-*l/50.5%
associate-*r/50.5%
associate-*l/50.5%
*-commutative50.5%
associate-*r/50.3%
hypot-1-def64.7%
Simplified64.7%
if 1.85000000000000001e-14 < J Initial program 99.8%
associate-*l*99.8%
associate-*l*99.8%
unpow299.8%
sqr-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in U around 0 86.3%
Final simplification47.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 5.2e-51) (- 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 <= 5.2e-51) {
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 <= 5.2d-51) 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 <= 5.2e-51) {
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 <= 5.2e-51: 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 <= 5.2e-51) tmp = Float64(-U_m); else tmp = Float64(-2.0 * Float64(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 <= 5.2e-51) 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, 5.2e-51], (-U$95$m), N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 5.2 \cdot 10^{-51}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if J < 5.2e-51Initial program 63.9%
Simplified63.8%
Taylor expanded in J around 0 31.2%
mul-1-neg31.2%
Simplified31.2%
if 5.2e-51 < J Initial program 97.1%
associate-*l*97.1%
associate-*l*97.1%
unpow297.1%
sqr-neg97.1%
distribute-frac-neg97.1%
distribute-frac-neg97.1%
unpow297.1%
Simplified98.5%
Taylor expanded in U around 0 82.1%
Final simplification45.0%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 3e-13) (- U_m) (* -2.0 J)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 3e-13) {
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 <= 3d-13) 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 <= 3e-13) {
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 <= 3e-13: 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 <= 3e-13) 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 <= 3e-13) 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, 3e-13], (-U$95$m), N[(-2.0 * J), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 3 \cdot 10^{-13}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 2.99999999999999984e-13Initial program 64.2%
Simplified64.2%
Taylor expanded in J around 0 30.7%
mul-1-neg30.7%
Simplified30.7%
if 2.99999999999999984e-13 < J Initial program 99.8%
Simplified99.7%
Taylor expanded in K around 0 48.3%
associate-*r*48.3%
metadata-eval48.3%
unpow248.3%
associate-/r*48.5%
unpow248.5%
associate-*r/59.2%
associate-*l/60.7%
swap-sqr60.7%
unpow260.7%
Simplified60.7%
Taylor expanded in J around inf 47.2%
*-commutative47.2%
Simplified47.2%
Final simplification34.7%
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 72.8%
Simplified72.8%
Taylor expanded in J around 0 25.8%
mul-1-neg25.8%
Simplified25.8%
Final simplification25.8%
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.8%
Simplified72.8%
Taylor expanded in U around -inf 26.1%
Final simplification26.1%
herbie shell --seed 2024011
(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)))))