
(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 11 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
(*
(* t_0 (* -2.0 J))
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY))
(- U)
(if (<= t_1 6e+307) t_1 (* -2.0 (- (* U -0.5) (/ J (/ U J))))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = (t_0 * (-2.0 * J)) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U;
} else if (t_1 <= 6e+307) {
tmp = t_1;
} else {
tmp = -2.0 * ((U * -0.5) - (J / (U / J)));
}
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 = (t_0 * (-2.0 * J)) * Math.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U;
} else if (t_1 <= 6e+307) {
tmp = t_1;
} else {
tmp = -2.0 * ((U * -0.5) - (J / (U / J)));
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = (t_0 * (-2.0 * J)) * math.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U elif t_1 <= 6e+307: tmp = t_1 else: tmp = -2.0 * ((U * -0.5) - (J / (U / J))) return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(t_0 * Float64(-2.0 * J)) * 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(-U); elseif (t_1 <= 6e+307) tmp = t_1; else tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(J / Float64(U / J)))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = (t_0 * (-2.0 * J)) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U; elseif (t_1 <= 6e+307) tmp = t_1; else tmp = -2.0 * ((U * -0.5) - (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[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 / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U), If[LessEqual[t$95$1, 6e+307], t$95$1, N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
U = |U|\\
\\
\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}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-U\\
\mathbf{elif}\;t_1 \leq 6 \cdot 10^{+307}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J}{\frac{U}{J}}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < -inf.0Initial program 4.8%
Taylor expanded in J around 0 40.6%
neg-mul-140.6%
Simplified40.6%
if -inf.0 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < 5.9999999999999997e307Initial program 99.9%
if 5.9999999999999997e307 < (*.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 13.1%
Taylor expanded in K around 0 7.0%
*-commutative7.0%
unpow27.0%
unpow27.0%
Simplified7.0%
Taylor expanded in U around -inf 52.7%
+-commutative52.7%
mul-1-neg52.7%
unsub-neg52.7%
*-commutative52.7%
unpow252.7%
associate-/l*52.7%
Simplified52.7%
Final simplification86.7%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* -2.0 (* J (* t_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 -2.0 * (J * (t_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 -2.0 * (J * (t_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 -2.0 * (J * (t_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(-2.0 * Float64(J * Float64(t_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 = -2.0 * (J * (t_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[(-2.0 * N[(J * N[(t$95$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)\\
-2 \cdot \left(J \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)
\end{array}
\end{array}
Initial program 77.0%
Simplified89.5%
Final simplification89.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (* J (cos (/ K 2.0))))) (* -2.0 (* t_0 (hypot 1.0 (/ U (* 2.0 t_0)))))))
U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * cos((K / 2.0));
return -2.0 * (t_0 * hypot(1.0, (U / (2.0 * t_0))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = J * Math.cos((K / 2.0));
return -2.0 * (t_0 * Math.hypot(1.0, (U / (2.0 * t_0))));
}
U = abs(U) def code(J, K, U): t_0 = J * math.cos((K / 2.0)) return -2.0 * (t_0 * math.hypot(1.0, (U / (2.0 * t_0))))
U = abs(U) function code(J, K, U) t_0 = Float64(J * cos(Float64(K / 2.0))) return Float64(-2.0 * Float64(t_0 * hypot(1.0, Float64(U / Float64(2.0 * t_0))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = J * cos((K / 2.0)); tmp = -2.0 * (t_0 * hypot(1.0, (U / (2.0 * t_0)))); end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(-2.0 * N[(t$95$0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{U}{2 \cdot t_0}\right)\right)
\end{array}
\end{array}
Initial program 77.0%
associate-*l*77.0%
associate-*l*77.0%
unpow277.0%
sqr-neg77.0%
distribute-frac-neg77.0%
distribute-frac-neg77.0%
unpow277.0%
Simplified89.6%
Final simplification89.6%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 1.5e+181) (* -2.0 (* J (* (cos (/ K 2.0)) (hypot 1.0 (/ (* U 0.5) J))))) (* -2.0 (- (* U -0.5) (/ J (/ U J))))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 1.5e+181) {
tmp = -2.0 * (J * (cos((K / 2.0)) * hypot(1.0, ((U * 0.5) / J))));
} else {
tmp = -2.0 * ((U * -0.5) - (J / (U / J)));
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 1.5e+181) {
tmp = -2.0 * (J * (Math.cos((K / 2.0)) * Math.hypot(1.0, ((U * 0.5) / J))));
} else {
tmp = -2.0 * ((U * -0.5) - (J / (U / J)));
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 1.5e+181: tmp = -2.0 * (J * (math.cos((K / 2.0)) * math.hypot(1.0, ((U * 0.5) / J)))) else: tmp = -2.0 * ((U * -0.5) - (J / (U / J))) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 1.5e+181) tmp = Float64(-2.0 * Float64(J * Float64(cos(Float64(K / 2.0)) * hypot(1.0, Float64(Float64(U * 0.5) / J))))); else tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(J / Float64(U / J)))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 1.5e+181) tmp = -2.0 * (J * (cos((K / 2.0)) * hypot(1.0, ((U * 0.5) / J)))); else tmp = -2.0 * ((U * -0.5) - (J / (U / J))); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 1.5e+181], N[(-2.0 * N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 1.5 \cdot 10^{+181}:\\
\;\;\;\;-2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, \frac{U \cdot 0.5}{J}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J}{\frac{U}{J}}\right)\\
\end{array}
\end{array}
if U < 1.50000000000000006e181Initial program 79.9%
Simplified91.7%
Taylor expanded in K around 0 76.4%
associate-*r/76.4%
Simplified76.4%
if 1.50000000000000006e181 < U Initial program 48.1%
Taylor expanded in K around 0 4.4%
*-commutative4.4%
unpow24.4%
unpow24.4%
Simplified4.4%
Taylor expanded in U around -inf 61.9%
+-commutative61.9%
mul-1-neg61.9%
unsub-neg61.9%
*-commutative61.9%
unpow261.9%
associate-/l*66.3%
Simplified66.3%
Final simplification75.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 1.28e+181) (* -2.0 (* (cos (/ K 2.0)) (* J (hypot 1.0 (* (/ U J) 0.5))))) (* -2.0 (- (* U -0.5) (/ J (/ U J))))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 1.28e+181) {
tmp = -2.0 * (cos((K / 2.0)) * (J * hypot(1.0, ((U / J) * 0.5))));
} else {
tmp = -2.0 * ((U * -0.5) - (J / (U / J)));
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 1.28e+181) {
tmp = -2.0 * (Math.cos((K / 2.0)) * (J * Math.hypot(1.0, ((U / J) * 0.5))));
} else {
tmp = -2.0 * ((U * -0.5) - (J / (U / J)));
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 1.28e+181: tmp = -2.0 * (math.cos((K / 2.0)) * (J * math.hypot(1.0, ((U / J) * 0.5)))) else: tmp = -2.0 * ((U * -0.5) - (J / (U / J))) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 1.28e+181) tmp = Float64(-2.0 * Float64(cos(Float64(K / 2.0)) * Float64(J * hypot(1.0, Float64(Float64(U / J) * 0.5))))); else tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(J / Float64(U / J)))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 1.28e+181) tmp = -2.0 * (cos((K / 2.0)) * (J * hypot(1.0, ((U / J) * 0.5)))); else tmp = -2.0 * ((U * -0.5) - (J / (U / J))); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 1.28e+181], N[(-2.0 * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U / J), $MachinePrecision] * 0.5), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 1.28 \cdot 10^{+181}:\\
\;\;\;\;-2 \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{U}{J} \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J}{\frac{U}{J}}\right)\\
\end{array}
\end{array}
if U < 1.27999999999999997e181Initial program 79.9%
associate-*l*79.9%
associate-*l*79.9%
*-commutative79.9%
unpow279.9%
sqr-neg79.9%
distribute-frac-neg79.9%
distribute-frac-neg79.9%
unpow279.9%
Simplified91.7%
Taylor expanded in K around 0 76.4%
if 1.27999999999999997e181 < U Initial program 48.1%
Taylor expanded in K around 0 4.4%
*-commutative4.4%
unpow24.4%
unpow24.4%
Simplified4.4%
Taylor expanded in U around -inf 61.9%
+-commutative61.9%
mul-1-neg61.9%
unsub-neg61.9%
*-commutative61.9%
unpow261.9%
associate-/l*66.3%
Simplified66.3%
Final simplification75.5%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= U 3.95e-134)
(* (cos (* K 0.5)) (* -2.0 J))
(if (<= U 6.5e+179)
(* -2.0 (* J (hypot 1.0 (* U (/ 0.5 J)))))
(* -2.0 (- (* U -0.5) (/ J (/ U J)))))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 3.95e-134) {
tmp = cos((K * 0.5)) * (-2.0 * J);
} else if (U <= 6.5e+179) {
tmp = -2.0 * (J * hypot(1.0, (U * (0.5 / J))));
} else {
tmp = -2.0 * ((U * -0.5) - (J / (U / J)));
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 3.95e-134) {
tmp = Math.cos((K * 0.5)) * (-2.0 * J);
} else if (U <= 6.5e+179) {
tmp = -2.0 * (J * Math.hypot(1.0, (U * (0.5 / J))));
} else {
tmp = -2.0 * ((U * -0.5) - (J / (U / J)));
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 3.95e-134: tmp = math.cos((K * 0.5)) * (-2.0 * J) elif U <= 6.5e+179: tmp = -2.0 * (J * math.hypot(1.0, (U * (0.5 / J)))) else: tmp = -2.0 * ((U * -0.5) - (J / (U / J))) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 3.95e-134) tmp = Float64(cos(Float64(K * 0.5)) * Float64(-2.0 * J)); elseif (U <= 6.5e+179) tmp = Float64(-2.0 * Float64(J * hypot(1.0, Float64(U * Float64(0.5 / J))))); else tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(J / Float64(U / J)))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 3.95e-134) tmp = cos((K * 0.5)) * (-2.0 * J); elseif (U <= 6.5e+179) tmp = -2.0 * (J * hypot(1.0, (U * (0.5 / J)))); else tmp = -2.0 * ((U * -0.5) - (J / (U / J))); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 3.95e-134], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 6.5e+179], N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(U * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 3.95 \cdot 10^{-134}:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(-2 \cdot J\right)\\
\mathbf{elif}\;U \leq 6.5 \cdot 10^{+179}:\\
\;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J}{\frac{U}{J}}\right)\\
\end{array}
\end{array}
if U < 3.9499999999999999e-134Initial program 80.9%
Taylor expanded in J around inf 61.4%
associate-*r*61.4%
Simplified61.4%
if 3.9499999999999999e-134 < U < 6.50000000000000052e179Initial program 77.2%
Taylor expanded in K around 0 43.8%
*-commutative43.8%
unpow243.8%
unpow243.8%
Simplified43.8%
add-sqr-sqrt43.8%
hypot-1-def43.8%
sqrt-prod43.8%
metadata-eval43.8%
times-frac55.5%
sqrt-prod41.9%
add-sqr-sqrt68.3%
*-commutative68.3%
expm1-log1p-u43.8%
expm1-udef28.2%
*-commutative28.2%
Applied egg-rr28.2%
expm1-def43.8%
expm1-log1p68.3%
associate-*r/68.3%
*-commutative68.3%
associate-*r/68.2%
Simplified68.2%
if 6.50000000000000052e179 < U Initial program 50.3%
Taylor expanded in K around 0 4.2%
*-commutative4.2%
unpow24.2%
unpow24.2%
Simplified4.2%
Taylor expanded in U around -inf 59.4%
+-commutative59.4%
mul-1-neg59.4%
unsub-neg59.4%
*-commutative59.4%
unpow259.4%
associate-/l*63.5%
Simplified63.5%
Final simplification63.4%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (cos (* K 0.5)) (* -2.0 J))))
(if (<= J -5.6e-98)
t_0
(if (<= J -5.5e-306) U (if (<= J 1.05e-82) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K * 0.5)) * (-2.0 * J);
double tmp;
if (J <= -5.6e-98) {
tmp = t_0;
} else if (J <= -5.5e-306) {
tmp = U;
} else if (J <= 1.05e-82) {
tmp = -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 = cos((k * 0.5d0)) * ((-2.0d0) * j)
if (j <= (-5.6d-98)) then
tmp = t_0
else if (j <= (-5.5d-306)) then
tmp = u
else if (j <= 1.05d-82) then
tmp = -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 = Math.cos((K * 0.5)) * (-2.0 * J);
double tmp;
if (J <= -5.6e-98) {
tmp = t_0;
} else if (J <= -5.5e-306) {
tmp = U;
} else if (J <= 1.05e-82) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K * 0.5)) * (-2.0 * J) tmp = 0 if J <= -5.6e-98: tmp = t_0 elif J <= -5.5e-306: tmp = U elif J <= 1.05e-82: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(cos(Float64(K * 0.5)) * Float64(-2.0 * J)) tmp = 0.0 if (J <= -5.6e-98) tmp = t_0; elseif (J <= -5.5e-306) tmp = U; elseif (J <= 1.05e-82) tmp = Float64(-U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K * 0.5)) * (-2.0 * J); tmp = 0.0; if (J <= -5.6e-98) tmp = t_0; elseif (J <= -5.5e-306) tmp = U; elseif (J <= 1.05e-82) tmp = -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[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -5.6e-98], t$95$0, If[LessEqual[J, -5.5e-306], U, If[LessEqual[J, 1.05e-82], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right) \cdot \left(-2 \cdot J\right)\\
\mathbf{if}\;J \leq -5.6 \cdot 10^{-98}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -5.5 \cdot 10^{-306}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.05 \cdot 10^{-82}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -5.5999999999999998e-98 or 1.05e-82 < J Initial program 90.2%
Taylor expanded in J around inf 71.9%
associate-*r*71.9%
Simplified71.9%
if -5.5999999999999998e-98 < J < -5.49999999999999992e-306Initial program 52.5%
Taylor expanded in U around -inf 43.9%
if -5.49999999999999992e-306 < J < 1.05e-82Initial program 47.0%
Taylor expanded in J around 0 30.8%
neg-mul-130.8%
Simplified30.8%
Final simplification60.5%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (+ J (* 0.125 (* U (/ U J)))))))
(if (<= J -1.3e+121)
t_0
(if (<= J -5.5e-306) U (if (<= J 5.5e-54) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * (J + (0.125 * (U * (U / J))));
double tmp;
if (J <= -1.3e+121) {
tmp = t_0;
} else if (J <= -5.5e-306) {
tmp = U;
} else if (J <= 5.5e-54) {
tmp = -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 = (-2.0d0) * (j + (0.125d0 * (u * (u / j))))
if (j <= (-1.3d+121)) then
tmp = t_0
else if (j <= (-5.5d-306)) then
tmp = u
else if (j <= 5.5d-54) then
tmp = -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 = -2.0 * (J + (0.125 * (U * (U / J))));
double tmp;
if (J <= -1.3e+121) {
tmp = t_0;
} else if (J <= -5.5e-306) {
tmp = U;
} else if (J <= 5.5e-54) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * (J + (0.125 * (U * (U / J)))) tmp = 0 if J <= -1.3e+121: tmp = t_0 elif J <= -5.5e-306: tmp = U elif J <= 5.5e-54: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(J + Float64(0.125 * Float64(U * Float64(U / J))))) tmp = 0.0 if (J <= -1.3e+121) tmp = t_0; elseif (J <= -5.5e-306) tmp = U; elseif (J <= 5.5e-54) tmp = Float64(-U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = -2.0 * (J + (0.125 * (U * (U / J)))); tmp = 0.0; if (J <= -1.3e+121) tmp = t_0; elseif (J <= -5.5e-306) tmp = U; elseif (J <= 5.5e-54) tmp = -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[(-2.0 * N[(J + N[(0.125 * N[(U * N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.3e+121], t$95$0, If[LessEqual[J, -5.5e-306], U, If[LessEqual[J, 5.5e-54], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J + 0.125 \cdot \left(U \cdot \frac{U}{J}\right)\right)\\
\mathbf{if}\;J \leq -1.3 \cdot 10^{+121}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -5.5 \cdot 10^{-306}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 5.5 \cdot 10^{-54}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.2999999999999999e121 or 5.50000000000000046e-54 < J Initial program 98.2%
Taylor expanded in K around 0 51.6%
*-commutative51.6%
unpow251.6%
unpow251.6%
Simplified51.6%
Taylor expanded in J around inf 48.7%
+-commutative48.7%
fma-def48.7%
unpow248.7%
associate-*r/54.5%
Simplified54.5%
fma-udef54.5%
Applied egg-rr54.5%
if -1.2999999999999999e121 < J < -5.49999999999999992e-306Initial program 67.8%
Taylor expanded in U around -inf 33.7%
if -5.49999999999999992e-306 < J < 5.50000000000000046e-54Initial program 47.9%
Taylor expanded in J around 0 34.2%
neg-mul-134.2%
Simplified34.2%
Final simplification42.9%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -1.76e+121) (* -2.0 J) (if (<= J -5.5e-306) U (if (<= J 8.4e-54) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.76e+121) {
tmp = -2.0 * J;
} else if (J <= -5.5e-306) {
tmp = U;
} else if (J <= 8.4e-54) {
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 <= (-1.76d+121)) then
tmp = (-2.0d0) * j
else if (j <= (-5.5d-306)) then
tmp = u
else if (j <= 8.4d-54) 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 <= -1.76e+121) {
tmp = -2.0 * J;
} else if (J <= -5.5e-306) {
tmp = U;
} else if (J <= 8.4e-54) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.76e+121: tmp = -2.0 * J elif J <= -5.5e-306: tmp = U elif J <= 8.4e-54: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.76e+121) tmp = Float64(-2.0 * J); elseif (J <= -5.5e-306) tmp = U; elseif (J <= 8.4e-54) 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 <= -1.76e+121) tmp = -2.0 * J; elseif (J <= -5.5e-306) tmp = U; elseif (J <= 8.4e-54) 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, -1.76e+121], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -5.5e-306], U, If[LessEqual[J, 8.4e-54], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.76 \cdot 10^{+121}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -5.5 \cdot 10^{-306}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 8.4 \cdot 10^{-54}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -1.7600000000000001e121 or 8.4e-54 < J Initial program 98.2%
Taylor expanded in K around 0 51.6%
*-commutative51.6%
unpow251.6%
unpow251.6%
Simplified51.6%
Taylor expanded in J around inf 54.3%
if -1.7600000000000001e121 < J < -5.49999999999999992e-306Initial program 67.8%
Taylor expanded in U around -inf 33.7%
if -5.49999999999999992e-306 < J < 8.4e-54Initial program 47.9%
Taylor expanded in J around 0 34.2%
neg-mul-134.2%
Simplified34.2%
Final simplification42.8%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -7.6e-306) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -7.6e-306) {
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 <= (-7.6d-306)) 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 <= -7.6e-306) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -7.6e-306: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -7.6e-306) 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 <= -7.6e-306) 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, -7.6e-306], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -7.6 \cdot 10^{-306}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -7.6e-306Initial program 77.3%
Taylor expanded in U around -inf 26.2%
if -7.6e-306 < J Initial program 76.7%
Taylor expanded in J around 0 20.9%
neg-mul-120.9%
Simplified20.9%
Final simplification23.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 77.0%
Taylor expanded in U around -inf 27.8%
Final simplification27.8%
herbie shell --seed 2023275
(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)))))