
(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 8 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}
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY))
(- (* -2.0 (/ J (/ U J))) U)
(if (<= t_1 1e+305)
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ U (* J (* 2.0 t_0)))))
U))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (-2.0 * (J / (U / J))) - U;
} else if (t_1 <= 1e+305) {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = (-2.0 * (J / (U / J))) - U;
} else if (t_1 <= 1e+305) {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = (-2.0 * (J / (U / J))) - U elif t_1 <= 1e+305: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0)))) else: tmp = U return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / J))) - U); elseif (t_1 <= 1e+305) tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = (-2.0 * (J / (U / J))) - U; elseif (t_1 <= 1e+305) tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0)))); else tmp = U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[LessEqual[t$95$1, 1e+305], N[(N[(J * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], U]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\
\mathbf{elif}\;t_1 \leq 10^{+305}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot t_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\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 8.4%
*-commutative8.4%
associate-*l*8.4%
associate-*r*8.4%
*-commutative8.4%
associate-*l*8.4%
*-commutative8.4%
unpow28.4%
hypot-1-def60.4%
*-commutative60.4%
associate-*l*60.4%
Simplified60.4%
Taylor expanded in J around 0 61.0%
neg-mul-161.0%
unsub-neg61.0%
associate-/l*61.0%
associate-*r/61.0%
unpow261.0%
Simplified61.0%
*-commutative61.0%
pow261.0%
cos-mult61.0%
Applied egg-rr61.0%
+-commutative61.0%
+-inverses61.0%
cos-061.0%
distribute-lft-out61.0%
metadata-eval61.0%
*-rgt-identity61.0%
Simplified61.0%
Taylor expanded in K around inf 61.0%
mul-1-neg61.0%
associate-/l*61.0%
distribute-neg-frac61.0%
unpow261.0%
Simplified61.0%
Taylor expanded in K around 0 61.0%
unpow261.0%
associate-/l*61.0%
Simplified61.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)))) < 9.9999999999999994e304Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if 9.9999999999999994e304 < (*.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.6%
*-commutative7.6%
associate-*l*7.6%
associate-*r*7.6%
*-commutative7.6%
associate-*l*7.6%
*-commutative7.6%
unpow27.6%
hypot-1-def67.9%
*-commutative67.9%
associate-*l*67.9%
Simplified67.9%
Taylor expanded in U around -inf 47.8%
Final simplification87.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* J (* t_0 (* -2.0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return J * (t_0 * (-2.0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) return J * (t_0 * (-2.0 * math.hypot(1.0, (U / (J * (2.0 * t_0))))))
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(J * N[(t$95$0 * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
J \cdot \left(t_0 \cdot \left(-2 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)
\end{array}
\end{array}
Initial program 74.3%
*-commutative74.3%
associate-*l*74.3%
associate-*r*74.3%
*-commutative74.3%
associate-*l*74.3%
*-commutative74.3%
unpow274.3%
hypot-1-def89.9%
*-commutative89.9%
associate-*l*89.9%
Simplified89.9%
Final simplification89.9%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -8.5e-22)
t_0
(if (<= J -2e-313)
U
(if (or (<= J 1.8e-47) (and (not (<= J 1.1e+54)) (<= J 3.2e+68)))
(- (* (* J J) (/ (- -1.0 (cos K)) U)) U)
t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -8.5e-22) {
tmp = t_0;
} else if (J <= -2e-313) {
tmp = U;
} else if ((J <= 1.8e-47) || (!(J <= 1.1e+54) && (J <= 3.2e+68))) {
tmp = ((J * J) * ((-1.0 - cos(K)) / U)) - U;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: U should be positive before calling this function
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
real(8) :: tmp
t_0 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-8.5d-22)) then
tmp = t_0
else if (j <= (-2d-313)) then
tmp = u
else if ((j <= 1.8d-47) .or. (.not. (j <= 1.1d+54)) .and. (j <= 3.2d+68)) then
tmp = ((j * j) * (((-1.0d0) - cos(k)) / u)) - u
else
tmp = t_0
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (J <= -8.5e-22) {
tmp = t_0;
} else if (J <= -2e-313) {
tmp = U;
} else if ((J <= 1.8e-47) || (!(J <= 1.1e+54) && (J <= 3.2e+68))) {
tmp = ((J * J) * ((-1.0 - Math.cos(K)) / U)) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -8.5e-22: tmp = t_0 elif J <= -2e-313: tmp = U elif (J <= 1.8e-47) or (not (J <= 1.1e+54) and (J <= 3.2e+68)): tmp = ((J * J) * ((-1.0 - math.cos(K)) / U)) - U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -8.5e-22) tmp = t_0; elseif (J <= -2e-313) tmp = U; elseif ((J <= 1.8e-47) || (!(J <= 1.1e+54) && (J <= 3.2e+68))) tmp = Float64(Float64(Float64(J * J) * Float64(Float64(-1.0 - cos(K)) / U)) - U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (J <= -8.5e-22) tmp = t_0; elseif (J <= -2e-313) tmp = U; elseif ((J <= 1.8e-47) || (~((J <= 1.1e+54)) && (J <= 3.2e+68))) tmp = ((J * J) * ((-1.0 - cos(K)) / U)) - U; else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -8.5e-22], t$95$0, If[LessEqual[J, -2e-313], U, If[Or[LessEqual[J, 1.8e-47], And[N[Not[LessEqual[J, 1.1e+54]], $MachinePrecision], LessEqual[J, 3.2e+68]]], N[(N[(N[(J * J), $MachinePrecision] * N[(N[(-1.0 - N[Cos[K], $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -8.5 \cdot 10^{-22}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-313}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.8 \cdot 10^{-47} \lor \neg \left(J \leq 1.1 \cdot 10^{+54}\right) \land J \leq 3.2 \cdot 10^{+68}:\\
\;\;\;\;\left(J \cdot J\right) \cdot \frac{-1 - \cos K}{U} - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -8.5000000000000001e-22 or 1.79999999999999995e-47 < J < 1.09999999999999995e54 or 3.19999999999999994e68 < J Initial program 95.3%
*-commutative95.3%
associate-*l*95.3%
associate-*r*95.3%
*-commutative95.3%
associate-*l*95.2%
*-commutative95.2%
unpow295.2%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 78.5%
if -8.5000000000000001e-22 < J < -1.99999999998e-313Initial program 46.4%
*-commutative46.4%
associate-*l*46.4%
associate-*r*46.4%
*-commutative46.4%
associate-*l*46.3%
*-commutative46.3%
unpow246.3%
hypot-1-def75.9%
*-commutative75.9%
associate-*l*75.9%
Simplified75.9%
Taylor expanded in U around -inf 36.3%
if -1.99999999998e-313 < J < 1.79999999999999995e-47 or 1.09999999999999995e54 < J < 3.19999999999999994e68Initial program 48.4%
*-commutative48.4%
associate-*l*48.4%
associate-*r*48.4%
*-commutative48.4%
associate-*l*48.3%
*-commutative48.3%
unpow248.3%
hypot-1-def78.6%
*-commutative78.6%
associate-*l*78.6%
Simplified78.6%
Taylor expanded in J around 0 44.6%
neg-mul-144.6%
unsub-neg44.6%
associate-/l*44.6%
associate-*r/44.6%
unpow244.6%
Simplified44.6%
*-commutative44.6%
pow244.6%
cos-mult44.6%
Applied egg-rr44.6%
+-commutative44.6%
+-inverses44.6%
cos-044.6%
distribute-lft-out44.6%
metadata-eval44.6%
*-rgt-identity44.6%
Simplified44.6%
Taylor expanded in K around inf 44.6%
mul-1-neg44.6%
associate-/l*44.6%
distribute-neg-frac44.6%
unpow244.6%
Simplified44.6%
Taylor expanded in K around inf 44.6%
mul-1-neg44.6%
distribute-neg-frac44.6%
distribute-lft-neg-out44.6%
associate-*l/44.6%
*-commutative44.6%
unpow244.6%
distribute-neg-in44.6%
metadata-eval44.6%
unsub-neg44.6%
Simplified44.6%
Final simplification61.9%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -9.1e-29)
t_0
(if (<= J -2e-313)
U
(if (<= J 2.1e-46)
(- (* -2.0 (/ J (/ U J))) U)
(if (or (<= J 1.32e+54) (not (<= J 3.6e+68)))
t_0
(* J (/ (- U) J))))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -9.1e-29) {
tmp = t_0;
} else if (J <= -2e-313) {
tmp = U;
} else if (J <= 2.1e-46) {
tmp = (-2.0 * (J / (U / J))) - U;
} else if ((J <= 1.32e+54) || !(J <= 3.6e+68)) {
tmp = t_0;
} else {
tmp = J * (-U / J);
}
return tmp;
}
NOTE: U should be positive before calling this function
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
real(8) :: tmp
t_0 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-9.1d-29)) then
tmp = t_0
else if (j <= (-2d-313)) then
tmp = u
else if (j <= 2.1d-46) then
tmp = ((-2.0d0) * (j / (u / j))) - u
else if ((j <= 1.32d+54) .or. (.not. (j <= 3.6d+68))) then
tmp = t_0
else
tmp = j * (-u / j)
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (J <= -9.1e-29) {
tmp = t_0;
} else if (J <= -2e-313) {
tmp = U;
} else if (J <= 2.1e-46) {
tmp = (-2.0 * (J / (U / J))) - U;
} else if ((J <= 1.32e+54) || !(J <= 3.6e+68)) {
tmp = t_0;
} else {
tmp = J * (-U / J);
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -9.1e-29: tmp = t_0 elif J <= -2e-313: tmp = U elif J <= 2.1e-46: tmp = (-2.0 * (J / (U / J))) - U elif (J <= 1.32e+54) or not (J <= 3.6e+68): tmp = t_0 else: tmp = J * (-U / J) return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -9.1e-29) tmp = t_0; elseif (J <= -2e-313) tmp = U; elseif (J <= 2.1e-46) tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / J))) - U); elseif ((J <= 1.32e+54) || !(J <= 3.6e+68)) tmp = t_0; else tmp = Float64(J * Float64(Float64(-U) / J)); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (J <= -9.1e-29) tmp = t_0; elseif (J <= -2e-313) tmp = U; elseif (J <= 2.1e-46) tmp = (-2.0 * (J / (U / J))) - U; elseif ((J <= 1.32e+54) || ~((J <= 3.6e+68))) tmp = t_0; else tmp = J * (-U / J); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -9.1e-29], t$95$0, If[LessEqual[J, -2e-313], U, If[LessEqual[J, 2.1e-46], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[Or[LessEqual[J, 1.32e+54], N[Not[LessEqual[J, 3.6e+68]], $MachinePrecision]], t$95$0, N[(J * N[((-U) / J), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -9.1 \cdot 10^{-29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-313}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2.1 \cdot 10^{-46}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\
\mathbf{elif}\;J \leq 1.32 \cdot 10^{+54} \lor \neg \left(J \leq 3.6 \cdot 10^{+68}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;J \cdot \frac{-U}{J}\\
\end{array}
\end{array}
if J < -9.1000000000000002e-29 or 2.09999999999999987e-46 < J < 1.3200000000000001e54 or 3.5999999999999999e68 < J Initial program 95.3%
*-commutative95.3%
associate-*l*95.3%
associate-*r*95.3%
*-commutative95.3%
associate-*l*95.2%
*-commutative95.2%
unpow295.2%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 78.5%
if -9.1000000000000002e-29 < J < -1.99999999998e-313Initial program 46.4%
*-commutative46.4%
associate-*l*46.4%
associate-*r*46.4%
*-commutative46.4%
associate-*l*46.3%
*-commutative46.3%
unpow246.3%
hypot-1-def75.9%
*-commutative75.9%
associate-*l*75.9%
Simplified75.9%
Taylor expanded in U around -inf 36.3%
if -1.99999999998e-313 < J < 2.09999999999999987e-46Initial program 43.0%
*-commutative43.0%
associate-*l*43.0%
associate-*r*43.0%
*-commutative43.0%
associate-*l*43.0%
*-commutative43.0%
unpow243.0%
hypot-1-def75.7%
*-commutative75.7%
associate-*l*75.7%
Simplified75.7%
Taylor expanded in J around 0 47.2%
neg-mul-147.2%
unsub-neg47.2%
associate-/l*47.2%
associate-*r/47.2%
unpow247.2%
Simplified47.2%
*-commutative47.2%
pow247.2%
cos-mult47.2%
Applied egg-rr47.2%
+-commutative47.2%
+-inverses47.2%
cos-047.2%
distribute-lft-out47.2%
metadata-eval47.2%
*-rgt-identity47.2%
Simplified47.2%
Taylor expanded in K around inf 47.2%
mul-1-neg47.2%
associate-/l*47.2%
distribute-neg-frac47.2%
unpow247.2%
Simplified47.2%
Taylor expanded in K around 0 47.2%
unpow247.2%
associate-/l*47.2%
Simplified47.2%
if 1.3200000000000001e54 < J < 3.5999999999999999e68Initial program 87.2%
*-commutative87.2%
associate-*l*87.2%
associate-*r*87.2%
*-commutative87.2%
associate-*l*86.7%
*-commutative86.7%
unpow286.7%
hypot-1-def99.3%
*-commutative99.3%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in U around inf 21.8%
associate-*r/21.8%
neg-mul-121.8%
Simplified21.8%
Final simplification61.8%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -1.1e-23)
t_0
(if (<= J -2e-313)
U
(if (<= J 1.7e-46) (- (/ (- -1.0 (cos K)) (/ (/ U J) J)) U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -1.1e-23) {
tmp = t_0;
} else if (J <= -2e-313) {
tmp = U;
} else if (J <= 1.7e-46) {
tmp = ((-1.0 - cos(K)) / ((U / J) / J)) - U;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: U should be positive before calling this function
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
real(8) :: tmp
t_0 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-1.1d-23)) then
tmp = t_0
else if (j <= (-2d-313)) then
tmp = u
else if (j <= 1.7d-46) then
tmp = (((-1.0d0) - cos(k)) / ((u / j) / j)) - u
else
tmp = t_0
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (J <= -1.1e-23) {
tmp = t_0;
} else if (J <= -2e-313) {
tmp = U;
} else if (J <= 1.7e-46) {
tmp = ((-1.0 - Math.cos(K)) / ((U / J) / J)) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -1.1e-23: tmp = t_0 elif J <= -2e-313: tmp = U elif J <= 1.7e-46: tmp = ((-1.0 - math.cos(K)) / ((U / J) / J)) - U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -1.1e-23) tmp = t_0; elseif (J <= -2e-313) tmp = U; elseif (J <= 1.7e-46) tmp = Float64(Float64(Float64(-1.0 - cos(K)) / Float64(Float64(U / J) / J)) - U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (J <= -1.1e-23) tmp = t_0; elseif (J <= -2e-313) tmp = U; elseif (J <= 1.7e-46) tmp = ((-1.0 - cos(K)) / ((U / J) / J)) - U; else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.1e-23], t$95$0, If[LessEqual[J, -2e-313], U, If[LessEqual[J, 1.7e-46], N[(N[(N[(-1.0 - N[Cos[K], $MachinePrecision]), $MachinePrecision] / N[(N[(U / J), $MachinePrecision] / J), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -1.1 \cdot 10^{-23}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-313}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.7 \cdot 10^{-46}:\\
\;\;\;\;\frac{-1 - \cos K}{\frac{\frac{U}{J}}{J}} - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.1e-23 or 1.69999999999999998e-46 < J Initial program 94.9%
*-commutative94.9%
associate-*l*94.9%
associate-*r*94.9%
*-commutative94.9%
associate-*l*94.8%
*-commutative94.8%
unpow294.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 75.8%
if -1.1e-23 < J < -1.99999999998e-313Initial program 46.4%
*-commutative46.4%
associate-*l*46.4%
associate-*r*46.4%
*-commutative46.4%
associate-*l*46.3%
*-commutative46.3%
unpow246.3%
hypot-1-def75.9%
*-commutative75.9%
associate-*l*75.9%
Simplified75.9%
Taylor expanded in U around -inf 36.3%
if -1.99999999998e-313 < J < 1.69999999999999998e-46Initial program 43.0%
*-commutative43.0%
associate-*l*43.0%
associate-*r*43.0%
*-commutative43.0%
associate-*l*43.0%
*-commutative43.0%
unpow243.0%
hypot-1-def75.7%
*-commutative75.7%
associate-*l*75.7%
Simplified75.7%
Taylor expanded in J around 0 47.2%
neg-mul-147.2%
unsub-neg47.2%
associate-/l*47.2%
associate-*r/47.2%
unpow247.2%
Simplified47.2%
*-commutative47.2%
pow247.2%
cos-mult47.2%
Applied egg-rr47.2%
+-commutative47.2%
+-inverses47.2%
cos-047.2%
distribute-lft-out47.2%
metadata-eval47.2%
*-rgt-identity47.2%
Simplified47.2%
Taylor expanded in K around inf 47.2%
mul-1-neg47.2%
associate-/l*47.2%
distribute-neg-frac47.2%
unpow247.2%
Simplified47.2%
*-un-lft-identity47.2%
associate-/r*47.2%
Applied egg-rr47.2%
Final simplification61.7%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= J -4.8e-20)
(* -2.0 J)
(if (<= J -2e-313)
U
(if (or (<= J 9.5e-5) (and (not (<= J 4.2e+45)) (<= J 6.8e+107)))
(- U)
(* -2.0 J)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -4.8e-20) {
tmp = -2.0 * J;
} else if (J <= -2e-313) {
tmp = U;
} else if ((J <= 9.5e-5) || (!(J <= 4.2e+45) && (J <= 6.8e+107))) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-4.8d-20)) then
tmp = (-2.0d0) * j
else if (j <= (-2d-313)) then
tmp = u
else if ((j <= 9.5d-5) .or. (.not. (j <= 4.2d+45)) .and. (j <= 6.8d+107)) then
tmp = -u
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -4.8e-20) {
tmp = -2.0 * J;
} else if (J <= -2e-313) {
tmp = U;
} else if ((J <= 9.5e-5) || (!(J <= 4.2e+45) && (J <= 6.8e+107))) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -4.8e-20: tmp = -2.0 * J elif J <= -2e-313: tmp = U elif (J <= 9.5e-5) or (not (J <= 4.2e+45) and (J <= 6.8e+107)): tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -4.8e-20) tmp = Float64(-2.0 * J); elseif (J <= -2e-313) tmp = U; elseif ((J <= 9.5e-5) || (!(J <= 4.2e+45) && (J <= 6.8e+107))) tmp = Float64(-U); else tmp = Float64(-2.0 * J); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -4.8e-20) tmp = -2.0 * J; elseif (J <= -2e-313) tmp = U; elseif ((J <= 9.5e-5) || (~((J <= 4.2e+45)) && (J <= 6.8e+107))) tmp = -U; else tmp = -2.0 * J; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -4.8e-20], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -2e-313], U, If[Or[LessEqual[J, 9.5e-5], And[N[Not[LessEqual[J, 4.2e+45]], $MachinePrecision], LessEqual[J, 6.8e+107]]], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -4.8 \cdot 10^{-20}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-313}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 9.5 \cdot 10^{-5} \lor \neg \left(J \leq 4.2 \cdot 10^{+45}\right) \land J \leq 6.8 \cdot 10^{+107}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -4.79999999999999986e-20 or 9.5000000000000005e-5 < J < 4.1999999999999999e45 or 6.7999999999999994e107 < J Initial program 96.8%
*-commutative96.8%
associate-*l*96.8%
associate-*r*96.8%
*-commutative96.8%
associate-*l*96.8%
*-commutative96.8%
unpow296.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 50.2%
associate-*r*50.2%
unpow250.2%
unpow250.2%
Simplified50.2%
Taylor expanded in U around 0 49.8%
if -4.79999999999999986e-20 < J < -1.99999999998e-313Initial program 47.3%
*-commutative47.3%
associate-*l*47.3%
associate-*r*47.3%
*-commutative47.3%
associate-*l*47.2%
*-commutative47.2%
unpow247.2%
hypot-1-def76.3%
*-commutative76.3%
associate-*l*76.3%
Simplified76.3%
Taylor expanded in U around -inf 35.7%
if -1.99999999998e-313 < J < 9.5000000000000005e-5 or 4.1999999999999999e45 < J < 6.7999999999999994e107Initial program 58.1%
*-commutative58.1%
associate-*l*58.1%
associate-*r*58.1%
*-commutative58.1%
associate-*l*58.0%
*-commutative58.0%
unpow258.0%
hypot-1-def84.1%
*-commutative84.1%
associate-*l*84.1%
Simplified84.1%
Taylor expanded in J around 0 42.3%
neg-mul-142.3%
Simplified42.3%
Final simplification44.4%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2e-313) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2e-313) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-2d-313)) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -2e-313) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2e-313: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2e-313) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -2e-313) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -2e-313], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2 \cdot 10^{-313}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -1.99999999998e-313Initial program 74.5%
*-commutative74.5%
associate-*l*74.5%
associate-*r*74.5%
*-commutative74.5%
associate-*l*74.4%
*-commutative74.4%
unpow274.4%
hypot-1-def89.5%
*-commutative89.5%
associate-*l*89.5%
Simplified89.5%
Taylor expanded in U around -inf 22.3%
if -1.99999999998e-313 < J Initial program 74.2%
*-commutative74.2%
associate-*l*74.2%
associate-*r*74.2%
*-commutative74.2%
associate-*l*74.1%
*-commutative74.1%
unpow274.1%
hypot-1-def90.4%
*-commutative90.4%
associate-*l*90.4%
Simplified90.4%
Taylor expanded in J around 0 30.7%
neg-mul-130.7%
Simplified30.7%
Final simplification26.6%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 U)
U = abs(U);
double code(double J, double K, double U) {
return U;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
return U;
}
U = abs(U) def code(J, K, U): return U
U = abs(U) function code(J, K, U) return U end
U = abs(U) function tmp = code(J, K, U) tmp = U; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := U
\begin{array}{l}
U = |U|\\
\\
U
\end{array}
Initial program 74.3%
*-commutative74.3%
associate-*l*74.3%
associate-*r*74.3%
*-commutative74.3%
associate-*l*74.3%
*-commutative74.3%
unpow274.3%
hypot-1-def89.9%
*-commutative89.9%
associate-*l*89.9%
Simplified89.9%
Taylor expanded in U around -inf 23.4%
Final simplification23.4%
herbie shell --seed 2023258
(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)))))