
(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 6 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 5e+301)
(* -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 <= 5e+301) {
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 <= 5e+301) {
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 <= 5e+301: 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 <= 5e+301) 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 <= 5e+301) 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, 5e+301], 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 5 \cdot 10^{+301}:\\
\;\;\;\;-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.9%
Simplified5.9%
Taylor expanded in J around 0 67.0%
neg-mul-167.0%
Simplified67.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)))) < 5.0000000000000004e301Initial 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 5.0000000000000004e301 < (*.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 56.2%
Final simplification88.6%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (cos (/ K 2.0)))
(t_2 (* -2.0 (- (* U_m -0.5) (/ (pow (* J t_0) 2.0) U_m))))
(t_3 (* t_0 (* -2.0 J))))
(if (<= t_1 -0.8)
t_2
(if (<= t_1 -0.42)
t_3
(if (<= t_1 -0.012)
t_2
(if (<= t_1 0.999)
t_3
(* (* -2.0 J) (hypot 1.0 (/ (/ U_m (* J 2.0)) t_1)))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K * 0.5));
double t_1 = cos((K / 2.0));
double t_2 = -2.0 * ((U_m * -0.5) - (pow((J * t_0), 2.0) / U_m));
double t_3 = t_0 * (-2.0 * J);
double tmp;
if (t_1 <= -0.8) {
tmp = t_2;
} else if (t_1 <= -0.42) {
tmp = t_3;
} else if (t_1 <= -0.012) {
tmp = t_2;
} else if (t_1 <= 0.999) {
tmp = t_3;
} else {
tmp = (-2.0 * J) * hypot(1.0, ((U_m / (J * 2.0)) / t_1));
}
return tmp;
}
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 t_1 = Math.cos((K / 2.0));
double t_2 = -2.0 * ((U_m * -0.5) - (Math.pow((J * t_0), 2.0) / U_m));
double t_3 = t_0 * (-2.0 * J);
double tmp;
if (t_1 <= -0.8) {
tmp = t_2;
} else if (t_1 <= -0.42) {
tmp = t_3;
} else if (t_1 <= -0.012) {
tmp = t_2;
} else if (t_1 <= 0.999) {
tmp = t_3;
} else {
tmp = (-2.0 * J) * Math.hypot(1.0, ((U_m / (J * 2.0)) / t_1));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K * 0.5)) t_1 = math.cos((K / 2.0)) t_2 = -2.0 * ((U_m * -0.5) - (math.pow((J * t_0), 2.0) / U_m)) t_3 = t_0 * (-2.0 * J) tmp = 0 if t_1 <= -0.8: tmp = t_2 elif t_1 <= -0.42: tmp = t_3 elif t_1 <= -0.012: tmp = t_2 elif t_1 <= 0.999: tmp = t_3 else: tmp = (-2.0 * J) * math.hypot(1.0, ((U_m / (J * 2.0)) / t_1)) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K * 0.5)) t_1 = cos(Float64(K / 2.0)) t_2 = Float64(-2.0 * Float64(Float64(U_m * -0.5) - Float64((Float64(J * t_0) ^ 2.0) / U_m))) t_3 = Float64(t_0 * Float64(-2.0 * J)) tmp = 0.0 if (t_1 <= -0.8) tmp = t_2; elseif (t_1 <= -0.42) tmp = t_3; elseif (t_1 <= -0.012) tmp = t_2; elseif (t_1 <= 0.999) tmp = t_3; else tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(Float64(U_m / Float64(J * 2.0)) / t_1))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K * 0.5)); t_1 = cos((K / 2.0)); t_2 = -2.0 * ((U_m * -0.5) - (((J * t_0) ^ 2.0) / U_m)); t_3 = t_0 * (-2.0 * J); tmp = 0.0; if (t_1 <= -0.8) tmp = t_2; elseif (t_1 <= -0.42) tmp = t_3; elseif (t_1 <= -0.012) tmp = t_2; elseif (t_1 <= 0.999) tmp = t_3; else tmp = (-2.0 * J) * hypot(1.0, ((U_m / (J * 2.0)) / t_1)); 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]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(-2.0 * N[(N[(U$95$m * -0.5), $MachinePrecision] - N[(N[Power[N[(J * t$95$0), $MachinePrecision], 2.0], $MachinePrecision] / U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.8], t$95$2, If[LessEqual[t$95$1, -0.42], t$95$3, If[LessEqual[t$95$1, -0.012], t$95$2, If[LessEqual[t$95$1, 0.999], t$95$3, N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := \cos \left(\frac{K}{2}\right)\\
t_2 := -2 \cdot \left(U_m \cdot -0.5 - \frac{{\left(J \cdot t_0\right)}^{2}}{U_m}\right)\\
t_3 := t_0 \cdot \left(-2 \cdot J\right)\\
\mathbf{if}\;t_1 \leq -0.8:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq -0.42:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_1 \leq -0.012:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 0.999:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U_m}{J \cdot 2}}{t_1}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.80000000000000004 or -0.419999999999999984 < (cos.f64 (/.f64 K 2)) < -0.012Initial program 62.5%
associate-*l*62.5%
associate-*l*62.5%
unpow262.5%
sqr-neg62.5%
distribute-frac-neg62.5%
distribute-frac-neg62.5%
unpow262.5%
Simplified88.1%
Taylor expanded in U around -inf 32.0%
+-commutative32.0%
*-commutative32.0%
mul-1-neg32.0%
unsub-neg32.0%
*-commutative32.0%
unpow232.0%
unpow232.0%
swap-sqr32.0%
unpow232.0%
*-commutative32.0%
Simplified32.0%
if -0.80000000000000004 < (cos.f64 (/.f64 K 2)) < -0.419999999999999984 or -0.012 < (cos.f64 (/.f64 K 2)) < 0.998999999999999999Initial program 81.8%
Simplified81.8%
Taylor expanded in J around inf 64.9%
associate-*r*64.9%
*-commutative64.9%
Simplified64.9%
if 0.998999999999999999 < (cos.f64 (/.f64 K 2)) Initial program 73.0%
unpow273.0%
hypot-1-def86.9%
associate-/r*86.9%
cos-neg86.9%
distribute-frac-neg86.9%
associate-/r*86.9%
associate-/r*86.9%
*-commutative86.9%
distribute-frac-neg86.9%
cos-neg86.9%
Simplified86.9%
Taylor expanded in K around 0 85.5%
*-commutative85.5%
Simplified85.5%
Final simplification67.5%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= J 2.65e-228)
(- U_m)
(if (<= J 1.55e-202)
U_m
(if (or (<= J 7.2e-41) (and (not (<= J 3.6e-19)) (<= J 2e+25)))
(- U_m)
(* (cos (* K 0.5)) (* -2.0 J))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 2.65e-228) {
tmp = -U_m;
} else if (J <= 1.55e-202) {
tmp = U_m;
} else if ((J <= 7.2e-41) || (!(J <= 3.6e-19) && (J <= 2e+25))) {
tmp = -U_m;
} else {
tmp = cos((K * 0.5)) * (-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 <= 2.65d-228) then
tmp = -u_m
else if (j <= 1.55d-202) then
tmp = u_m
else if ((j <= 7.2d-41) .or. (.not. (j <= 3.6d-19)) .and. (j <= 2d+25)) then
tmp = -u_m
else
tmp = cos((k * 0.5d0)) * ((-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 <= 2.65e-228) {
tmp = -U_m;
} else if (J <= 1.55e-202) {
tmp = U_m;
} else if ((J <= 7.2e-41) || (!(J <= 3.6e-19) && (J <= 2e+25))) {
tmp = -U_m;
} else {
tmp = Math.cos((K * 0.5)) * (-2.0 * J);
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 2.65e-228: tmp = -U_m elif J <= 1.55e-202: tmp = U_m elif (J <= 7.2e-41) or (not (J <= 3.6e-19) and (J <= 2e+25)): tmp = -U_m else: tmp = math.cos((K * 0.5)) * (-2.0 * J) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 2.65e-228) tmp = Float64(-U_m); elseif (J <= 1.55e-202) tmp = U_m; elseif ((J <= 7.2e-41) || (!(J <= 3.6e-19) && (J <= 2e+25))) tmp = Float64(-U_m); else tmp = Float64(cos(Float64(K * 0.5)) * 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 <= 2.65e-228) tmp = -U_m; elseif (J <= 1.55e-202) tmp = U_m; elseif ((J <= 7.2e-41) || (~((J <= 3.6e-19)) && (J <= 2e+25))) tmp = -U_m; else tmp = cos((K * 0.5)) * (-2.0 * J); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 2.65e-228], (-U$95$m), If[LessEqual[J, 1.55e-202], U$95$m, If[Or[LessEqual[J, 7.2e-41], And[N[Not[LessEqual[J, 3.6e-19]], $MachinePrecision], LessEqual[J, 2e+25]]], (-U$95$m), N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 2.65 \cdot 10^{-228}:\\
\;\;\;\;-U_m\\
\mathbf{elif}\;J \leq 1.55 \cdot 10^{-202}:\\
\;\;\;\;U_m\\
\mathbf{elif}\;J \leq 7.2 \cdot 10^{-41} \lor \neg \left(J \leq 3.6 \cdot 10^{-19}\right) \land J \leq 2 \cdot 10^{+25}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(-2 \cdot J\right)\\
\end{array}
\end{array}
if J < 2.64999999999999992e-228 or 1.55e-202 < J < 7.2e-41 or 3.6000000000000001e-19 < J < 2.00000000000000018e25Initial program 66.1%
Simplified66.1%
Taylor expanded in J around 0 33.4%
neg-mul-133.4%
Simplified33.4%
if 2.64999999999999992e-228 < J < 1.55e-202Initial program 39.3%
Simplified39.3%
Taylor expanded in U around -inf 37.9%
if 7.2e-41 < J < 3.6000000000000001e-19 or 2.00000000000000018e25 < J Initial program 97.4%
Simplified97.4%
Taylor expanded in J around inf 85.1%
associate-*r*85.1%
*-commutative85.1%
Simplified85.1%
Final simplification47.5%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= J 1.3e-228)
(- U_m)
(if (<= J 1.55e-202)
U_m
(if (or (<= J 2.8e-40) (and (not (<= J 1.5e-19)) (<= J 1.6e+40)))
(- U_m)
(* -2.0 J)))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 1.3e-228) {
tmp = -U_m;
} else if (J <= 1.55e-202) {
tmp = U_m;
} else if ((J <= 2.8e-40) || (!(J <= 1.5e-19) && (J <= 1.6e+40))) {
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 <= 1.3d-228) then
tmp = -u_m
else if (j <= 1.55d-202) then
tmp = u_m
else if ((j <= 2.8d-40) .or. (.not. (j <= 1.5d-19)) .and. (j <= 1.6d+40)) 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 <= 1.3e-228) {
tmp = -U_m;
} else if (J <= 1.55e-202) {
tmp = U_m;
} else if ((J <= 2.8e-40) || (!(J <= 1.5e-19) && (J <= 1.6e+40))) {
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 <= 1.3e-228: tmp = -U_m elif J <= 1.55e-202: tmp = U_m elif (J <= 2.8e-40) or (not (J <= 1.5e-19) and (J <= 1.6e+40)): 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 <= 1.3e-228) tmp = Float64(-U_m); elseif (J <= 1.55e-202) tmp = U_m; elseif ((J <= 2.8e-40) || (!(J <= 1.5e-19) && (J <= 1.6e+40))) 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 <= 1.3e-228) tmp = -U_m; elseif (J <= 1.55e-202) tmp = U_m; elseif ((J <= 2.8e-40) || (~((J <= 1.5e-19)) && (J <= 1.6e+40))) 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, 1.3e-228], (-U$95$m), If[LessEqual[J, 1.55e-202], U$95$m, If[Or[LessEqual[J, 2.8e-40], And[N[Not[LessEqual[J, 1.5e-19]], $MachinePrecision], LessEqual[J, 1.6e+40]]], (-U$95$m), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 1.3 \cdot 10^{-228}:\\
\;\;\;\;-U_m\\
\mathbf{elif}\;J \leq 1.55 \cdot 10^{-202}:\\
\;\;\;\;U_m\\
\mathbf{elif}\;J \leq 2.8 \cdot 10^{-40} \lor \neg \left(J \leq 1.5 \cdot 10^{-19}\right) \land J \leq 1.6 \cdot 10^{+40}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 1.3e-228 or 1.55e-202 < J < 2.8e-40 or 1.49999999999999996e-19 < J < 1.5999999999999999e40Initial program 66.7%
Simplified66.7%
Taylor expanded in J around 0 32.9%
neg-mul-132.9%
Simplified32.9%
if 1.3e-228 < J < 1.55e-202Initial program 39.3%
Simplified39.3%
Taylor expanded in U around -inf 37.9%
if 2.8e-40 < J < 1.49999999999999996e-19 or 1.5999999999999999e40 < J Initial program 97.2%
Simplified97.2%
Taylor expanded in J around inf 85.9%
associate-*r*85.9%
*-commutative85.9%
Simplified85.9%
Taylor expanded in K around 0 50.5%
*-commutative50.5%
Simplified50.5%
Final simplification37.6%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= K 13000.0) (and (not (<= K 4.9e+210)) (<= K 3e+237))) (- U_m) U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if ((K <= 13000.0) || (!(K <= 4.9e+210) && (K <= 3e+237))) {
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 <= 13000.0d0) .or. (.not. (k <= 4.9d+210)) .and. (k <= 3d+237)) 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 <= 13000.0) || (!(K <= 4.9e+210) && (K <= 3e+237))) {
tmp = -U_m;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if (K <= 13000.0) or (not (K <= 4.9e+210) and (K <= 3e+237)): tmp = -U_m else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if ((K <= 13000.0) || (!(K <= 4.9e+210) && (K <= 3e+237))) 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 <= 13000.0) || (~((K <= 4.9e+210)) && (K <= 3e+237))) 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, 13000.0], And[N[Not[LessEqual[K, 4.9e+210]], $MachinePrecision], LessEqual[K, 3e+237]]], (-U$95$m), U$95$m]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 13000 \lor \neg \left(K \leq 4.9 \cdot 10^{+210}\right) \land K \leq 3 \cdot 10^{+237}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;U_m\\
\end{array}
\end{array}
if K < 13000 or 4.90000000000000007e210 < K < 3e237Initial program 70.6%
Simplified70.6%
Taylor expanded in J around 0 27.7%
neg-mul-127.7%
Simplified27.7%
if 13000 < K < 4.90000000000000007e210 or 3e237 < K Initial program 82.5%
Simplified82.5%
Taylor expanded in U around -inf 22.1%
Final simplification26.4%
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.4%
Simplified73.4%
Taylor expanded in U around -inf 26.4%
Final simplification26.4%
herbie shell --seed 2024019
(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)))))