
(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 7 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+303)
(* -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+303) {
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+303) {
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+303: 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+303) 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+303) 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+303], 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^{+303}:\\
\;\;\;\;-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.2%
Simplified5.2%
Taylor expanded in J around 0 42.6%
mul-1-neg42.6%
Simplified42.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)))) < 2e303Initial program 99.7%
associate-*l*99.7%
associate-*l*99.7%
unpow299.7%
sqr-neg99.7%
distribute-frac-neg99.7%
distribute-frac-neg99.7%
unpow299.7%
Simplified99.8%
if 2e303 < (*.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.5%
Simplified5.5%
Taylor expanded in U around -inf 48.9%
Final simplification84.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 5.2e+62) (* -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 <= 5.2e+62) {
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 <= 5.2e+62) {
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 <= 5.2e+62: 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 <= 5.2e+62) 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 <= 5.2e+62) 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, 5.2e+62], 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 5.2 \cdot 10^{+62}:\\
\;\;\;\;-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 < 5.19999999999999968e62Initial program 80.6%
associate-*l*80.6%
associate-*l*80.6%
unpow280.6%
sqr-neg80.6%
distribute-frac-neg80.6%
distribute-frac-neg80.6%
unpow280.6%
Simplified93.5%
Taylor expanded in K around 0 75.9%
if 5.19999999999999968e62 < U Initial program 44.0%
Simplified44.0%
Taylor expanded in J around 0 35.7%
mul-1-neg35.7%
Simplified35.7%
Final simplification68.2%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= U_m 7.6e-112) (and (not (<= U_m 7.8e-86)) (<= U_m 3.5e+62))) (* -2.0 (* J (cos (* K 0.5)))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if ((U_m <= 7.6e-112) || (!(U_m <= 7.8e-86) && (U_m <= 3.5e+62))) {
tmp = -2.0 * (J * 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 <= 7.6d-112) .or. (.not. (u_m <= 7.8d-86)) .and. (u_m <= 3.5d+62)) then
tmp = (-2.0d0) * (j * 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 <= 7.6e-112) || (!(U_m <= 7.8e-86) && (U_m <= 3.5e+62))) {
tmp = -2.0 * (J * 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 <= 7.6e-112) or (not (U_m <= 7.8e-86) and (U_m <= 3.5e+62)): tmp = -2.0 * (J * 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 <= 7.6e-112) || (!(U_m <= 7.8e-86) && (U_m <= 3.5e+62))) tmp = Float64(-2.0 * Float64(J * 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 <= 7.6e-112) || (~((U_m <= 7.8e-86)) && (U_m <= 3.5e+62))) tmp = -2.0 * (J * 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[Or[LessEqual[U$95$m, 7.6e-112], And[N[Not[LessEqual[U$95$m, 7.8e-86]], $MachinePrecision], LessEqual[U$95$m, 3.5e+62]]], N[(-2.0 * N[(J * 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 7.6 \cdot 10^{-112} \lor \neg \left(U_m \leq 7.8 \cdot 10^{-86}\right) \land U_m \leq 3.5 \cdot 10^{+62}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U_m\\
\end{array}
\end{array}
if U < 7.59999999999999989e-112 or 7.8000000000000003e-86 < U < 3.49999999999999984e62Initial program 80.3%
associate-*l*80.3%
associate-*l*80.3%
unpow280.3%
sqr-neg80.3%
distribute-frac-neg80.3%
distribute-frac-neg80.3%
unpow280.3%
Simplified93.4%
Taylor expanded in U around 0 57.8%
if 7.59999999999999989e-112 < U < 7.8000000000000003e-86 or 3.49999999999999984e62 < U Initial program 47.2%
Simplified47.2%
Taylor expanded in J around 0 33.8%
mul-1-neg33.8%
Simplified33.8%
Final simplification52.9%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 1.2e-118) (* -2.0 (* J (cos (* K 0.5)))) (if (<= U_m 6e+62) (* (* -2.0 J) (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.2e-118) {
tmp = -2.0 * (J * cos((K * 0.5)));
} else if (U_m <= 6e+62) {
tmp = (-2.0 * J) * 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.2e-118) {
tmp = -2.0 * (J * Math.cos((K * 0.5)));
} else if (U_m <= 6e+62) {
tmp = (-2.0 * J) * 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.2e-118: tmp = -2.0 * (J * math.cos((K * 0.5))) elif U_m <= 6e+62: tmp = (-2.0 * J) * 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.2e-118) tmp = Float64(-2.0 * Float64(J * cos(Float64(K * 0.5)))); elseif (U_m <= 6e+62) tmp = Float64(Float64(-2.0 * J) * 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.2e-118) tmp = -2.0 * (J * cos((K * 0.5))); elseif (U_m <= 6e+62) tmp = (-2.0 * J) * 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.2e-118], N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 6e+62], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], (-U$95$m)]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U_m \leq 1.2 \cdot 10^{-118}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{elif}\;U_m \leq 6 \cdot 10^{+62}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U_m}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;-U_m\\
\end{array}
\end{array}
if U < 1.2000000000000001e-118Initial program 78.2%
associate-*l*78.2%
associate-*l*78.2%
unpow278.2%
sqr-neg78.2%
distribute-frac-neg78.2%
distribute-frac-neg78.2%
unpow278.2%
Simplified92.4%
Taylor expanded in U around 0 56.5%
if 1.2000000000000001e-118 < U < 6e62Initial program 93.5%
Simplified93.5%
Taylor expanded in K around 0 51.2%
associate-*r*51.2%
associate-*r/51.2%
*-commutative51.2%
unpow251.2%
associate-/r*57.3%
unpow257.3%
metadata-eval57.3%
swap-sqr57.3%
associate-*r/57.3%
*-commutative57.3%
associate-*r/57.3%
associate-*l/57.3%
*-commutative57.3%
associate-*r/57.3%
unpow257.3%
Simplified57.3%
expm1-log1p-u38.7%
expm1-udef16.2%
*-commutative16.2%
associate-*l*16.2%
unpow216.2%
hypot-1-def16.4%
Applied egg-rr16.4%
expm1-def41.8%
expm1-log1p60.4%
associate-*r*60.4%
Simplified60.4%
if 6e62 < U Initial program 44.0%
Simplified44.0%
Taylor expanded in J around 0 35.7%
mul-1-neg35.7%
Simplified35.7%
Final simplification53.0%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 3.1e-119) (* -2.0 J) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 3.1e-119) {
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 <= 3.1d-119) 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 <= 3.1e-119) {
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 <= 3.1e-119: 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 <= 3.1e-119) 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 <= 3.1e-119) 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, 3.1e-119], N[(-2.0 * J), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U_m \leq 3.1 \cdot 10^{-119}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-U_m\\
\end{array}
\end{array}
if U < 3.09999999999999978e-119Initial program 78.2%
Simplified78.2%
Taylor expanded in K around 0 36.6%
associate-*r*36.6%
associate-*r/36.6%
*-commutative36.6%
unpow236.6%
associate-/r*40.7%
unpow240.7%
metadata-eval40.7%
swap-sqr40.7%
associate-*r/44.4%
*-commutative44.4%
associate-*r/44.4%
associate-*l/45.0%
*-commutative45.0%
associate-*r/45.0%
unpow245.0%
Simplified45.0%
Taylor expanded in J around inf 29.3%
*-commutative29.3%
Simplified29.3%
if 3.09999999999999978e-119 < U Initial program 63.6%
Simplified63.5%
Taylor expanded in J around 0 30.3%
mul-1-neg30.3%
Simplified30.3%
Final simplification29.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 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 73.6%
Simplified73.6%
Taylor expanded in J around 0 24.7%
mul-1-neg24.7%
Simplified24.7%
Final simplification24.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 73.6%
Simplified73.6%
Taylor expanded in U around -inf 29.3%
Final simplification29.3%
herbie shell --seed 2024021
(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)))))