
(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 10 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))))))
(if (<= t_1 (- INFINITY)) (- U_m) (if (<= t_1 1e+299) 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 = (t_0 * (-2.0 * J)) * 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+299) {
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 = (t_0 * (-2.0 * J)) * 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+299) {
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 = (t_0 * (-2.0 * J)) * 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+299: 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(t_0 * Float64(-2.0 * J)) * 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+299) 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 = (t_0 * (-2.0 * J)) * 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+299) 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[(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]}, If[LessEqual[t$95$1, (-Infinity)], (-U$95$m), If[LessEqual[t$95$1, 1e+299], 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(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}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_1 \leq 10^{+299}:\\
\;\;\;\;t\_1\\
\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 4.9%
Simplified70.5%
Taylor expanded in J around 0 40.6%
neg-mul-140.6%
Simplified40.6%
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.0000000000000001e299Initial program 99.8%
if 1.0000000000000001e299 < (*.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.7%
Simplified63.0%
Taylor expanded in U around -inf 28.4%
Taylor expanded in J around 0 49.2%
Final simplification81.3%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* -2.0 (* J (* t_0 (hypot 1.0 (* (/ U_m t_0) (/ 0.5 J))))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
return -2.0 * (J * (t_0 * hypot(1.0, ((U_m / t_0) * (0.5 / J)))));
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
return -2.0 * (J * (t_0 * Math.hypot(1.0, ((U_m / t_0) * (0.5 / J)))));
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) return -2.0 * (J * (t_0 * math.hypot(1.0, ((U_m / t_0) * (0.5 / J)))))
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) return Float64(-2.0 * Float64(J * Float64(t_0 * hypot(1.0, Float64(Float64(U_m / t_0) * Float64(0.5 / J)))))) end
U_m = abs(U); function tmp = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = -2.0 * (J * (t_0 * hypot(1.0, ((U_m / t_0) * (0.5 / J))))); 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]}, N[(-2.0 * N[(J * N[(t$95$0 * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / t$95$0), $MachinePrecision] * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(J \cdot \left(t\_0 \cdot \mathsf{hypot}\left(1, \frac{U\_m}{t\_0} \cdot \frac{0.5}{J}\right)\right)\right)
\end{array}
\end{array}
Initial program 68.4%
Simplified88.6%
Final simplification88.6%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* -2.0 (* (* J t_0) (hypot 1.0 (/ (/ U_m (* J 2.0)) t_0))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
return -2.0 * ((J * t_0) * hypot(1.0, ((U_m / (J * 2.0)) / t_0)));
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
return -2.0 * ((J * t_0) * Math.hypot(1.0, ((U_m / (J * 2.0)) / t_0)));
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) return -2.0 * ((J * t_0) * math.hypot(1.0, ((U_m / (J * 2.0)) / t_0)))
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) return Float64(-2.0 * Float64(Float64(J * t_0) * hypot(1.0, Float64(Float64(U_m / Float64(J * 2.0)) / t_0)))) end
U_m = abs(U); function tmp = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = -2.0 * ((J * t_0) * hypot(1.0, ((U_m / (J * 2.0)) / t_0))); 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]}, N[(-2.0 * N[(N[(J * 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]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(\left(J \cdot t\_0\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{J \cdot 2}}{t\_0}\right)\right)
\end{array}
\end{array}
Initial program 68.4%
Simplified88.7%
Final simplification88.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 8e+66) (* J (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ U_m (* J 2.0))))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 8e+66) {
tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, (U_m / (J * 2.0))));
} 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+66) {
tmp = J * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, (U_m / (J * 2.0))));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 8e+66: tmp = J * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, (U_m / (J * 2.0)))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 8e+66) tmp = Float64(J * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(U_m / Float64(J * 2.0))))); 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+66) tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, (U_m / (J * 2.0)))); 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+66], N[(J * N[(N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U$95$m / N[(J * 2.0), $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 8 \cdot 10^{+66}:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m}{J \cdot 2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 7.99999999999999956e66Initial program 73.5%
Simplified91.2%
Taylor expanded in K around 0 76.4%
*-commutative76.4%
Simplified76.4%
if 7.99999999999999956e66 < U Initial program 50.6%
Simplified80.0%
Taylor expanded in J around 0 37.0%
neg-mul-137.0%
Simplified37.0%
Final simplification67.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 1.75e-70) (* J (* -2.0 (cos (* K 0.5)))) (if (<= U_m 8e+66) (* J (* -2.0 (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 <= 1.75e-70) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else if (U_m <= 8e+66) {
tmp = J * (-2.0 * 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 <= 1.75e-70) {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
} else if (U_m <= 8e+66) {
tmp = J * (-2.0 * 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 <= 1.75e-70: tmp = J * (-2.0 * math.cos((K * 0.5))) elif U_m <= 8e+66: tmp = J * (-2.0 * 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 <= 1.75e-70) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); elseif (U_m <= 8e+66) tmp = Float64(J * Float64(-2.0 * 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 <= 1.75e-70) tmp = J * (-2.0 * cos((K * 0.5))); elseif (U_m <= 8e+66) tmp = J * (-2.0 * 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, 1.75e-70], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 8e+66], N[(J * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U$95$m / 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 1.75 \cdot 10^{-70}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{elif}\;U\_m \leq 8 \cdot 10^{+66}:\\
\;\;\;\;J \cdot \left(-2 \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U\_m}{J}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1.74999999999999987e-70Initial program 73.5%
Simplified90.7%
Taylor expanded in U around 0 55.9%
if 1.74999999999999987e-70 < U < 7.99999999999999956e66Initial program 73.5%
Simplified95.2%
expm1-log1p-u34.7%
associate-*l*34.7%
div-inv34.7%
metadata-eval34.7%
associate-/r*34.7%
div-inv34.7%
div-inv34.7%
metadata-eval34.7%
metadata-eval34.7%
div-inv34.7%
clear-num34.7%
Applied egg-rr34.7%
expm1-undefine34.7%
log1p-expm1-u34.7%
log1p-undefine34.7%
rem-exp-log34.8%
expm1-log1p-u95.3%
*-commutative95.3%
associate-*l*95.3%
frac-times95.3%
Applied egg-rr95.3%
Taylor expanded in K around 0 38.4%
metadata-eval38.4%
metadata-eval38.4%
unpow238.4%
unpow238.4%
times-frac38.4%
swap-sqr38.4%
hypot-undefine56.0%
Simplified56.0%
if 7.99999999999999956e66 < U Initial program 50.6%
Simplified80.0%
Taylor expanded in J around 0 37.0%
neg-mul-137.0%
Simplified37.0%
Final simplification51.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 9.6e+32) (* J (* -2.0 (cos (* K 0.5)))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 9.6e+32) {
tmp = J * (-2.0 * 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 <= 9.6d+32) then
tmp = j * ((-2.0d0) * 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 <= 9.6e+32) {
tmp = J * (-2.0 * 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 <= 9.6e+32: tmp = J * (-2.0 * 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 <= 9.6e+32) tmp = Float64(J * Float64(-2.0 * 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 <= 9.6e+32) tmp = J * (-2.0 * 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, 9.6e+32], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 9.6 \cdot 10^{+32}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 9.59999999999999965e32Initial program 74.1%
Simplified91.4%
Taylor expanded in U around 0 55.3%
if 9.59999999999999965e32 < U Initial program 50.7%
Simplified80.3%
Taylor expanded in J around 0 36.7%
neg-mul-136.7%
Simplified36.7%
Final simplification50.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 4.3e-71) (* -2.0 J) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 4.3e-71) {
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 <= 4.3d-71) 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 <= 4.3e-71) {
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 <= 4.3e-71: 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 <= 4.3e-71) 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 <= 4.3e-71) 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, 4.3e-71], N[(-2.0 * J), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 4.3 \cdot 10^{-71}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 4.2999999999999997e-71Initial program 73.5%
Simplified90.7%
expm1-log1p-u27.9%
associate-*l*27.9%
div-inv27.9%
metadata-eval27.9%
associate-/r*27.9%
div-inv27.9%
div-inv27.9%
metadata-eval27.9%
metadata-eval27.9%
div-inv27.9%
clear-num27.9%
Applied egg-rr27.9%
expm1-undefine27.9%
log1p-expm1-u27.9%
log1p-undefine27.9%
rem-exp-log27.9%
expm1-log1p-u90.6%
*-commutative90.6%
associate-*l*90.6%
frac-times90.6%
Applied egg-rr90.6%
Taylor expanded in K around 0 30.3%
metadata-eval30.3%
metadata-eval30.3%
unpow230.3%
unpow230.3%
times-frac40.4%
swap-sqr40.4%
hypot-undefine55.0%
Simplified55.0%
Taylor expanded in J around inf 30.9%
*-commutative30.9%
Simplified30.9%
if 4.2999999999999997e-71 < U Initial program 56.9%
Simplified84.2%
Taylor expanded in J around 0 35.9%
neg-mul-135.9%
Simplified35.9%
Final simplification32.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 1.65e-87) (* -2.0 J) (- J U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.65e-87) {
tmp = -2.0 * J;
} else {
tmp = J - 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.65d-87) then
tmp = (-2.0d0) * j
else
tmp = j - 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.65e-87) {
tmp = -2.0 * J;
} else {
tmp = J - U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 1.65e-87: tmp = -2.0 * J else: tmp = J - U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 1.65e-87) tmp = Float64(-2.0 * J); else tmp = Float64(J - 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.65e-87) tmp = -2.0 * J; else tmp = J - 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.65e-87], N[(-2.0 * J), $MachinePrecision], N[(J - U$95$m), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 1.65 \cdot 10^{-87}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;J - U\_m\\
\end{array}
\end{array}
if U < 1.65e-87Initial program 73.1%
Simplified90.6%
expm1-log1p-u27.1%
associate-*l*27.1%
div-inv27.1%
metadata-eval27.1%
associate-/r*27.1%
div-inv27.1%
div-inv27.1%
metadata-eval27.1%
metadata-eval27.1%
div-inv27.1%
clear-num27.1%
Applied egg-rr27.1%
expm1-undefine27.1%
log1p-expm1-u27.1%
log1p-undefine27.1%
rem-exp-log27.1%
expm1-log1p-u90.4%
*-commutative90.4%
associate-*l*90.4%
frac-times90.5%
Applied egg-rr90.5%
Taylor expanded in K around 0 30.6%
metadata-eval30.6%
metadata-eval30.6%
unpow230.6%
unpow230.6%
times-frac40.9%
swap-sqr40.9%
hypot-undefine55.6%
Simplified55.6%
Taylor expanded in J around inf 31.3%
*-commutative31.3%
Simplified31.3%
if 1.65e-87 < U Initial program 58.0%
Simplified84.6%
expm1-log1p-u24.9%
associate-*l*24.9%
div-inv24.9%
metadata-eval24.9%
associate-/r*24.9%
div-inv24.9%
div-inv24.9%
metadata-eval24.9%
metadata-eval24.9%
div-inv24.9%
clear-num24.9%
Applied egg-rr24.9%
expm1-undefine24.9%
log1p-expm1-u24.9%
log1p-undefine24.9%
rem-exp-log24.9%
expm1-log1p-u84.5%
*-commutative84.5%
associate-*l*84.5%
frac-times84.6%
Applied egg-rr84.6%
associate--l+84.6%
distribute-rgt-in84.4%
*-un-lft-identity84.4%
fma-neg84.4%
times-frac84.4%
metadata-eval84.4%
Applied egg-rr84.4%
Taylor expanded in U around inf 36.4%
neg-mul-136.4%
Simplified36.4%
Final simplification32.9%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= K 5.5e+40) (- U_m) U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (K <= 5.5e+40) {
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 <= 5.5d+40) 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 <= 5.5e+40) {
tmp = -U_m;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if K <= 5.5e+40: tmp = -U_m else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (K <= 5.5e+40) 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 <= 5.5e+40) 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, 5.5e+40], (-U$95$m), U$95$m]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 5.5 \cdot 10^{+40}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if K < 5.49999999999999974e40Initial program 65.8%
Simplified88.3%
Taylor expanded in J around 0 27.7%
neg-mul-127.7%
Simplified27.7%
if 5.49999999999999974e40 < K Initial program 79.0%
Simplified90.0%
Taylor expanded in U around -inf 24.1%
Taylor expanded in J around 0 27.5%
Final simplification27.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 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 68.4%
Simplified88.7%
Taylor expanded in U around -inf 23.7%
Taylor expanded in J around 0 30.6%
Final simplification30.6%
herbie shell --seed 2024050
(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)))))