
(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+299)
(* -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+299) {
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+299) {
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+299: 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+299) 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+299) 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+299], 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^{+299}:\\
\;\;\;\;-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%
Taylor expanded in J around 0 57.8%
neg-mul-157.8%
Simplified57.8%
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)))) < 2.0000000000000001e299Initial 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.7%
if 2.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.8%
Taylor expanded in U around -inf 50.3%
Final simplification85.8%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= J 4e-179)
(- U_m)
(*
-2.0
(*
(cos (/ K 2.0))
(* J (hypot 1.0 (* (/ U_m J) (/ 0.5 (cos (* K 0.5))))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 4e-179) {
tmp = -U_m;
} else {
tmp = -2.0 * (cos((K / 2.0)) * (J * hypot(1.0, ((U_m / J) * (0.5 / 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 <= 4e-179) {
tmp = -U_m;
} else {
tmp = -2.0 * (Math.cos((K / 2.0)) * (J * Math.hypot(1.0, ((U_m / J) * (0.5 / Math.cos((K * 0.5)))))));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 4e-179: tmp = -U_m else: tmp = -2.0 * (math.cos((K / 2.0)) * (J * math.hypot(1.0, ((U_m / J) * (0.5 / math.cos((K * 0.5))))))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 4e-179) tmp = Float64(-U_m); else tmp = Float64(-2.0 * Float64(cos(Float64(K / 2.0)) * Float64(J * hypot(1.0, Float64(Float64(U_m / J) * Float64(0.5 / 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 <= 4e-179) tmp = -U_m; else tmp = -2.0 * (cos((K / 2.0)) * (J * hypot(1.0, ((U_m / J) * (0.5 / cos((K * 0.5))))))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 4e-179], (-U$95$m), N[(-2.0 * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / J), $MachinePrecision] * N[(0.5 / N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 4 \cdot 10^{-179}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{U_m}{J} \cdot \frac{0.5}{\cos \left(K \cdot 0.5\right)}\right)\right)\right)\\
\end{array}
\end{array}
if J < 4.0000000000000001e-179Initial program 64.8%
Taylor expanded in J around 0 28.7%
neg-mul-128.7%
Simplified28.7%
if 4.0000000000000001e-179 < J Initial program 83.2%
associate-*l*83.2%
associate-*l*83.2%
*-commutative83.2%
unpow283.2%
sqr-neg83.2%
distribute-frac-neg83.2%
distribute-frac-neg83.2%
unpow283.2%
Simplified94.6%
div-inv94.6%
metadata-eval94.6%
times-frac94.7%
div-inv94.7%
metadata-eval94.7%
Applied egg-rr94.7%
Final simplification52.2%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 1.05e-162) (- U_m) (* -2.0 (* (cos (/ K 2.0)) (* J (hypot 1.0 (* (/ U_m J) 0.5)))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 1.05e-162) {
tmp = -U_m;
} else {
tmp = -2.0 * (cos((K / 2.0)) * (J * hypot(1.0, ((U_m / J) * 0.5))));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 1.05e-162) {
tmp = -U_m;
} else {
tmp = -2.0 * (Math.cos((K / 2.0)) * (J * Math.hypot(1.0, ((U_m / J) * 0.5))));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 1.05e-162: tmp = -U_m else: tmp = -2.0 * (math.cos((K / 2.0)) * (J * math.hypot(1.0, ((U_m / J) * 0.5)))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 1.05e-162) tmp = Float64(-U_m); else tmp = Float64(-2.0 * Float64(cos(Float64(K / 2.0)) * Float64(J * hypot(1.0, Float64(Float64(U_m / J) * 0.5))))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 1.05e-162) tmp = -U_m; else tmp = -2.0 * (cos((K / 2.0)) * (J * hypot(1.0, ((U_m / J) * 0.5)))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 1.05e-162], (-U$95$m), N[(-2.0 * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / J), $MachinePrecision] * 0.5), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 1.05 \cdot 10^{-162}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{U_m}{J} \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if J < 1.05e-162Initial program 64.3%
Taylor expanded in J around 0 29.0%
neg-mul-129.0%
Simplified29.0%
if 1.05e-162 < J Initial program 85.5%
associate-*l*85.5%
associate-*l*85.5%
*-commutative85.5%
unpow285.5%
sqr-neg85.5%
distribute-frac-neg85.5%
distribute-frac-neg85.5%
unpow285.5%
Simplified95.4%
Taylor expanded in K around 0 86.3%
Final simplification48.0%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= J 1.9e-58)
(- U_m)
(if (or (<= J 2.7e+17) (not (<= J 2.1e+38)))
(* (* -2.0 J) (cos (* K 0.5)))
(- (* -2.0 (/ (pow J 2.0) U_m)) U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 1.9e-58) {
tmp = -U_m;
} else if ((J <= 2.7e+17) || !(J <= 2.1e+38)) {
tmp = (-2.0 * J) * cos((K * 0.5));
} else {
tmp = (-2.0 * (pow(J, 2.0) / U_m)) - 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 (j <= 1.9d-58) then
tmp = -u_m
else if ((j <= 2.7d+17) .or. (.not. (j <= 2.1d+38))) then
tmp = ((-2.0d0) * j) * cos((k * 0.5d0))
else
tmp = ((-2.0d0) * ((j ** 2.0d0) / u_m)) - 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 (J <= 1.9e-58) {
tmp = -U_m;
} else if ((J <= 2.7e+17) || !(J <= 2.1e+38)) {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
} else {
tmp = (-2.0 * (Math.pow(J, 2.0) / U_m)) - U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 1.9e-58: tmp = -U_m elif (J <= 2.7e+17) or not (J <= 2.1e+38): tmp = (-2.0 * J) * math.cos((K * 0.5)) else: tmp = (-2.0 * (math.pow(J, 2.0) / U_m)) - U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 1.9e-58) tmp = Float64(-U_m); elseif ((J <= 2.7e+17) || !(J <= 2.1e+38)) tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))); else tmp = Float64(Float64(-2.0 * Float64((J ^ 2.0) / U_m)) - U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 1.9e-58) tmp = -U_m; elseif ((J <= 2.7e+17) || ~((J <= 2.1e+38))) tmp = (-2.0 * J) * cos((K * 0.5)); else tmp = (-2.0 * ((J ^ 2.0) / U_m)) - U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 1.9e-58], (-U$95$m), If[Or[LessEqual[J, 2.7e+17], N[Not[LessEqual[J, 2.1e+38]], $MachinePrecision]], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(N[Power[J, 2.0], $MachinePrecision] / U$95$m), $MachinePrecision]), $MachinePrecision] - U$95$m), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 1.9 \cdot 10^{-58}:\\
\;\;\;\;-U_m\\
\mathbf{elif}\;J \leq 2.7 \cdot 10^{+17} \lor \neg \left(J \leq 2.1 \cdot 10^{+38}\right):\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{J}^{2}}{U_m} - U_m\\
\end{array}
\end{array}
if J < 1.8999999999999999e-58Initial program 63.6%
Taylor expanded in J around 0 30.8%
neg-mul-130.8%
Simplified30.8%
if 1.8999999999999999e-58 < J < 2.7e17 or 2.1e38 < J Initial program 93.9%
Taylor expanded in J around inf 80.9%
associate-*r*80.9%
*-commutative80.9%
Simplified80.9%
if 2.7e17 < J < 2.1e38Initial program 69.0%
Taylor expanded in J around 0 67.0%
neg-mul-167.0%
unsub-neg67.0%
unpow267.0%
*-commutative67.0%
unpow267.0%
swap-sqr67.0%
unpow267.0%
*-commutative67.0%
Simplified67.0%
Taylor expanded in K around 0 67.0%
Final simplification43.9%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= U_m 1.45e-55)
(* (* -2.0 J) (cos (* K 0.5)))
(if (<= U_m 5.6e+101)
(* -2.0 (* J (hypot 1.0 (/ 0.5 (/ J U_m)))))
(- U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.45e-55) {
tmp = (-2.0 * J) * cos((K * 0.5));
} else if (U_m <= 5.6e+101) {
tmp = -2.0 * (J * hypot(1.0, (0.5 / (J / U_m))));
} 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.45e-55) {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
} else if (U_m <= 5.6e+101) {
tmp = -2.0 * (J * Math.hypot(1.0, (0.5 / (J / U_m))));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 1.45e-55: tmp = (-2.0 * J) * math.cos((K * 0.5)) elif U_m <= 5.6e+101: tmp = -2.0 * (J * math.hypot(1.0, (0.5 / (J / U_m)))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 1.45e-55) tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))); elseif (U_m <= 5.6e+101) tmp = Float64(-2.0 * Float64(J * hypot(1.0, Float64(0.5 / Float64(J / U_m))))); 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.45e-55) tmp = (-2.0 * J) * cos((K * 0.5)); elseif (U_m <= 5.6e+101) tmp = -2.0 * (J * hypot(1.0, (0.5 / (J / 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[U$95$m, 1.45e-55], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 5.6e+101], N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(0.5 / N[(J / U$95$m), $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.45 \cdot 10^{-55}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{elif}\;U_m \leq 5.6 \cdot 10^{+101}:\\
\;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{0.5}{\frac{J}{U_m}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U_m\\
\end{array}
\end{array}
if U < 1.45e-55Initial program 80.2%
Taylor expanded in J around inf 62.6%
associate-*r*62.6%
*-commutative62.6%
Simplified62.6%
if 1.45e-55 < U < 5.59999999999999962e101Initial program 78.0%
Taylor expanded in K around 0 50.2%
add-sqr-sqrt50.2%
hypot-1-def50.2%
sqrt-prod50.2%
metadata-eval50.2%
sqrt-div53.3%
unpow253.3%
sqrt-prod53.2%
add-sqr-sqrt53.3%
unpow253.3%
sqrt-prod31.9%
add-sqr-sqrt62.7%
clear-num62.6%
un-div-inv62.6%
Applied egg-rr62.6%
if 5.59999999999999962e101 < U Initial program 32.3%
Taylor expanded in J around 0 50.6%
neg-mul-150.6%
Simplified50.6%
Final simplification60.4%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= J 2.4e-57) (and (not (<= J 2.7e+17)) (<= J 2.75e+38))) (- 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 <= 2.4e-57) || (!(J <= 2.7e+17) && (J <= 2.75e+38))) {
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 <= 2.4d-57) .or. (.not. (j <= 2.7d+17)) .and. (j <= 2.75d+38)) 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 <= 2.4e-57) || (!(J <= 2.7e+17) && (J <= 2.75e+38))) {
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 <= 2.4e-57) or (not (J <= 2.7e+17) and (J <= 2.75e+38)): 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 <= 2.4e-57) || (!(J <= 2.7e+17) && (J <= 2.75e+38))) tmp = Float64(-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 <= 2.4e-57) || (~((J <= 2.7e+17)) && (J <= 2.75e+38))) 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[Or[LessEqual[J, 2.4e-57], And[N[Not[LessEqual[J, 2.7e+17]], $MachinePrecision], LessEqual[J, 2.75e+38]]], (-U$95$m), 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 2.4 \cdot 10^{-57} \lor \neg \left(J \leq 2.7 \cdot 10^{+17}\right) \land J \leq 2.75 \cdot 10^{+38}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\end{array}
\end{array}
if J < 2.40000000000000006e-57 or 2.7e17 < J < 2.7500000000000002e38Initial program 63.7%
Taylor expanded in J around 0 31.3%
neg-mul-131.3%
Simplified31.3%
if 2.40000000000000006e-57 < J < 2.7e17 or 2.7500000000000002e38 < J Initial program 93.9%
Taylor expanded in J around inf 80.9%
associate-*r*80.9%
*-commutative80.9%
Simplified80.9%
Final simplification43.9%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 1.45e+42) (- U_m) (* -2.0 J)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 1.45e+42) {
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.45d+42) 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.45e+42) {
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.45e+42: 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.45e+42) 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.45e+42) 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.45e+42], (-U$95$m), N[(-2.0 * J), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 1.45 \cdot 10^{+42}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 1.4499999999999999e42Initial program 64.7%
Taylor expanded in J around 0 31.4%
neg-mul-131.4%
Simplified31.4%
if 1.4499999999999999e42 < J Initial program 96.2%
Taylor expanded in J around inf 83.9%
associate-*r*83.9%
*-commutative83.9%
Simplified83.9%
Taylor expanded in K around 0 49.1%
*-commutative49.1%
Simplified49.1%
Final simplification35.1%
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 71.3%
Taylor expanded in J around 0 27.4%
neg-mul-127.4%
Simplified27.4%
Final simplification27.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 71.3%
Taylor expanded in U around -inf 23.9%
Final simplification23.9%
herbie shell --seed 2023322
(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)))))