
(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}
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 (/ (pow J 2.0) U)) U)
(if (<= t_1 5e+307) t_1 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 * (pow(J, 2.0) / U)) - U;
} else if (t_1 <= 5e+307) {
tmp = t_1;
} 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 * (Math.pow(J, 2.0) / U)) - U;
} else if (t_1 <= 5e+307) {
tmp = t_1;
} 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 * (math.pow(J, 2.0) / U)) - U elif t_1 <= 5e+307: tmp = t_1 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 ^ 2.0) / U)) - U); elseif (t_1 <= 5e+307) tmp = t_1; 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 ^ 2.0) / U)) - U; elseif (t_1 <= 5e+307) tmp = t_1; 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[(N[Power[J, 2.0], $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[LessEqual[t$95$1, 5e+307], t$95$1, 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}^{2}}{U} - U\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;t_1\\
\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 6.0%
Taylor expanded in J around 0 34.8%
neg-mul-134.8%
unsub-neg34.8%
unpow234.8%
*-commutative34.8%
unpow234.8%
swap-sqr34.8%
unpow234.8%
*-commutative34.8%
Simplified34.8%
Taylor expanded in K around 0 34.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)))) < 5e307Initial program 99.8%
if 5e307 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) Initial program 5.0%
Taylor expanded in U around -inf 49.3%
Final simplification83.6%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (or (<= J -1.8e-245) (not (<= J 1.7e-292)))
(* -2.0 (* t_0 (* J (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 tmp;
if ((J <= -1.8e-245) || !(J <= 1.7e-292)) {
tmp = -2.0 * (t_0 * (J * 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 tmp;
if ((J <= -1.8e-245) || !(J <= 1.7e-292)) {
tmp = -2.0 * (t_0 * (J * 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)) tmp = 0 if (J <= -1.8e-245) or not (J <= 1.7e-292): tmp = -2.0 * (t_0 * (J * 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)) tmp = 0.0 if ((J <= -1.8e-245) || !(J <= 1.7e-292)) tmp = Float64(-2.0 * Float64(t_0 * Float64(J * hypot(1.0, Float64(Float64(U / Float64(J * 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)); tmp = 0.0; if ((J <= -1.8e-245) || ~((J <= 1.7e-292))) tmp = -2.0 * (t_0 * (J * 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]}, If[Or[LessEqual[J, -1.8e-245], N[Not[LessEqual[J, 1.7e-292]], $MachinePrecision]], N[(-2.0 * N[(t$95$0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], U]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;J \leq -1.8 \cdot 10^{-245} \lor \neg \left(J \leq 1.7 \cdot 10^{-292}\right):\\
\;\;\;\;-2 \cdot \left(t_0 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{t_0}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if J < -1.8e-245 or 1.70000000000000009e-292 < J Initial program 76.5%
Simplified90.6%
if -1.8e-245 < J < 1.70000000000000009e-292Initial program 35.1%
Taylor expanded in U around -inf 29.1%
Final simplification85.3%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (hypot 1.0 (/ (/ U (* J 2.0)) t_0))))
(if (<= J -1.8e-245)
(* -2.0 (* t_0 (* J t_1)))
(if (<= J 2.6e-294) U (* -2.0 (* t_1 (* J t_0)))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = hypot(1.0, ((U / (J * 2.0)) / t_0));
double tmp;
if (J <= -1.8e-245) {
tmp = -2.0 * (t_0 * (J * t_1));
} else if (J <= 2.6e-294) {
tmp = U;
} else {
tmp = -2.0 * (t_1 * (J * t_0));
}
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 = Math.hypot(1.0, ((U / (J * 2.0)) / t_0));
double tmp;
if (J <= -1.8e-245) {
tmp = -2.0 * (t_0 * (J * t_1));
} else if (J <= 2.6e-294) {
tmp = U;
} else {
tmp = -2.0 * (t_1 * (J * t_0));
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.hypot(1.0, ((U / (J * 2.0)) / t_0)) tmp = 0 if J <= -1.8e-245: tmp = -2.0 * (t_0 * (J * t_1)) elif J <= 2.6e-294: tmp = U else: tmp = -2.0 * (t_1 * (J * t_0)) return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = hypot(1.0, Float64(Float64(U / Float64(J * 2.0)) / t_0)) tmp = 0.0 if (J <= -1.8e-245) tmp = Float64(-2.0 * Float64(t_0 * Float64(J * t_1))); elseif (J <= 2.6e-294) tmp = U; else tmp = Float64(-2.0 * Float64(t_1 * Float64(J * t_0))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = hypot(1.0, ((U / (J * 2.0)) / t_0)); tmp = 0.0; if (J <= -1.8e-245) tmp = -2.0 * (t_0 * (J * t_1)); elseif (J <= 2.6e-294) tmp = U; else tmp = -2.0 * (t_1 * (J * 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[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[1.0 ^ 2 + N[(N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[J, -1.8e-245], N[(-2.0 * N[(t$95$0 * N[(J * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 2.6e-294], U, N[(-2.0 * N[(t$95$1 * N[(J * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{t_0}\right)\\
\mathbf{if}\;J \leq -1.8 \cdot 10^{-245}:\\
\;\;\;\;-2 \cdot \left(t_0 \cdot \left(J \cdot t_1\right)\right)\\
\mathbf{elif}\;J \leq 2.6 \cdot 10^{-294}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(t_1 \cdot \left(J \cdot t_0\right)\right)\\
\end{array}
\end{array}
if J < -1.8e-245Initial program 77.0%
Simplified89.4%
if -1.8e-245 < J < 2.5999999999999999e-294Initial program 35.1%
Taylor expanded in U around -inf 29.1%
if 2.5999999999999999e-294 < J Initial program 76.0%
associate-*l*76.7%
associate-*l*76.7%
unpow276.7%
hypot-1-def91.9%
associate-/r*91.8%
cos-neg91.8%
distribute-frac-neg91.8%
associate-/r*91.9%
associate-/r*91.8%
distribute-frac-neg91.8%
cos-neg91.8%
Simplified91.8%
Final simplification85.3%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 8.5e+197) (* -2.0 (* (* J (cos (/ K 2.0))) (hypot 1.0 (/ (* U 0.5) J)))) (if (<= U 8.6e+250) (- U) U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 8.5e+197) {
tmp = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, ((U * 0.5) / J)));
} else if (U <= 8.6e+250) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 8.5e+197) {
tmp = -2.0 * ((J * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U * 0.5) / J)));
} else if (U <= 8.6e+250) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 8.5e+197: tmp = -2.0 * ((J * math.cos((K / 2.0))) * math.hypot(1.0, ((U * 0.5) / J))) elif U <= 8.6e+250: tmp = -U else: tmp = U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 8.5e+197) tmp = Float64(-2.0 * Float64(Float64(J * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U * 0.5) / J)))); elseif (U <= 8.6e+250) tmp = Float64(-U); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 8.5e+197) tmp = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, ((U * 0.5) / J))); elseif (U <= 8.6e+250) 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[U, 8.5e+197], N[(-2.0 * N[(N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 8.6e+250], (-U), U]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 8.5 \cdot 10^{+197}:\\
\;\;\;\;-2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U \cdot 0.5}{J}\right)\right)\\
\mathbf{elif}\;U \leq 8.6 \cdot 10^{+250}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if U < 8.5000000000000001e197Initial program 76.3%
associate-*l*76.7%
associate-*l*76.7%
unpow276.7%
hypot-1-def89.0%
associate-/r*88.9%
cos-neg88.9%
distribute-frac-neg88.9%
associate-/r*89.0%
associate-/r*88.9%
distribute-frac-neg88.9%
cos-neg88.9%
Simplified88.9%
Taylor expanded in K around 0 75.5%
associate-*r/75.5%
Simplified75.5%
if 8.5000000000000001e197 < U < 8.6e250Initial program 53.0%
Taylor expanded in J around 0 63.5%
neg-mul-163.5%
Simplified63.5%
if 8.6e250 < U Initial program 27.6%
Taylor expanded in U around -inf 72.1%
Final simplification75.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= (/ K 2.0) 1e+32) (* -2.0 (* J (hypot 1.0 (* 0.5 (/ U J))))) (* -2.0 (* J (cos (/ K 2.0))))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if ((K / 2.0) <= 1e+32) {
tmp = -2.0 * (J * hypot(1.0, (0.5 * (U / J))));
} else {
tmp = -2.0 * (J * cos((K / 2.0)));
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if ((K / 2.0) <= 1e+32) {
tmp = -2.0 * (J * Math.hypot(1.0, (0.5 * (U / J))));
} else {
tmp = -2.0 * (J * Math.cos((K / 2.0)));
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if (K / 2.0) <= 1e+32: tmp = -2.0 * (J * math.hypot(1.0, (0.5 * (U / J)))) else: tmp = -2.0 * (J * math.cos((K / 2.0))) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 1e+32) tmp = Float64(-2.0 * Float64(J * hypot(1.0, Float64(0.5 * Float64(U / J))))); else tmp = Float64(-2.0 * Float64(J * cos(Float64(K / 2.0)))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if ((K / 2.0) <= 1e+32) tmp = -2.0 * (J * hypot(1.0, (0.5 * (U / J)))); else tmp = -2.0 * (J * cos((K / 2.0))); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 1e+32], N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 10^{+32}:\\
\;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\
\end{array}
\end{array}
if (/.f64 K 2) < 1.00000000000000005e32Initial program 71.9%
Simplified86.4%
associate-*r*86.4%
*-commutative86.4%
add-cube-cbrt84.9%
pow384.9%
Applied egg-rr84.9%
rem-cube-cbrt86.3%
*-commutative86.3%
add-cube-cbrt85.4%
associate-*l*85.5%
Applied egg-rr85.5%
Taylor expanded in K around 0 37.2%
metadata-eval37.2%
unpow237.2%
unpow237.2%
times-frac53.7%
swap-sqr53.7%
unpow253.7%
unpow253.7%
hypot-1-def64.4%
Simplified64.4%
if 1.00000000000000005e32 < (/.f64 K 2) Initial program 76.1%
Simplified88.8%
Taylor expanded in J around inf 60.1%
Final simplification63.4%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* J (cos (/ K 2.0))))))
(if (<= J -1.18e-7)
t_0
(if (<= J 2.6e-294) U (if (<= J 9.5e-22) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * (J * cos((K / 2.0)));
double tmp;
if (J <= -1.18e-7) {
tmp = t_0;
} else if (J <= 2.6e-294) {
tmp = U;
} else if (J <= 9.5e-22) {
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 * cos((k / 2.0d0)))
if (j <= (-1.18d-7)) then
tmp = t_0
else if (j <= 2.6d-294) then
tmp = u
else if (j <= 9.5d-22) 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 * Math.cos((K / 2.0)));
double tmp;
if (J <= -1.18e-7) {
tmp = t_0;
} else if (J <= 2.6e-294) {
tmp = U;
} else if (J <= 9.5e-22) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * (J * math.cos((K / 2.0))) tmp = 0 if J <= -1.18e-7: tmp = t_0 elif J <= 2.6e-294: tmp = U elif J <= 9.5e-22: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(J * cos(Float64(K / 2.0)))) tmp = 0.0 if (J <= -1.18e-7) tmp = t_0; elseif (J <= 2.6e-294) tmp = U; elseif (J <= 9.5e-22) 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 * cos((K / 2.0))); tmp = 0.0; if (J <= -1.18e-7) tmp = t_0; elseif (J <= 2.6e-294) tmp = U; elseif (J <= 9.5e-22) 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[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.18e-7], t$95$0, If[LessEqual[J, 2.6e-294], U, If[LessEqual[J, 9.5e-22], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\
\mathbf{if}\;J \leq -1.18 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 2.6 \cdot 10^{-294}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 9.5 \cdot 10^{-22}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.18e-7 or 9.4999999999999994e-22 < J Initial program 95.0%
Simplified99.8%
Taylor expanded in J around inf 83.5%
if -1.18e-7 < J < 2.5999999999999999e-294Initial program 45.9%
Taylor expanded in U around -inf 41.8%
if 2.5999999999999999e-294 < J < 9.4999999999999994e-22Initial program 54.8%
Taylor expanded in J around 0 36.4%
neg-mul-136.4%
Simplified36.4%
Final simplification62.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -0.9) (* -2.0 J) (if (<= J 2.6e-294) U (if (<= J 340000000.0) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -0.9) {
tmp = -2.0 * J;
} else if (J <= 2.6e-294) {
tmp = U;
} else if (J <= 340000000.0) {
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 <= (-0.9d0)) then
tmp = (-2.0d0) * j
else if (j <= 2.6d-294) then
tmp = u
else if (j <= 340000000.0d0) 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 <= -0.9) {
tmp = -2.0 * J;
} else if (J <= 2.6e-294) {
tmp = U;
} else if (J <= 340000000.0) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -0.9: tmp = -2.0 * J elif J <= 2.6e-294: tmp = U elif J <= 340000000.0: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -0.9) tmp = Float64(-2.0 * J); elseif (J <= 2.6e-294) tmp = U; elseif (J <= 340000000.0) 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 <= -0.9) tmp = -2.0 * J; elseif (J <= 2.6e-294) tmp = U; elseif (J <= 340000000.0) 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, -0.9], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, 2.6e-294], U, If[LessEqual[J, 340000000.0], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -0.9:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq 2.6 \cdot 10^{-294}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 340000000:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -0.900000000000000022 or 3.4e8 < J Initial program 96.3%
Simplified99.9%
Taylor expanded in J around inf 84.4%
Taylor expanded in K around 0 47.0%
if -0.900000000000000022 < J < 2.5999999999999999e-294Initial program 45.9%
Taylor expanded in U around -inf 41.8%
if 2.5999999999999999e-294 < J < 3.4e8Initial program 55.4%
Taylor expanded in J around 0 33.5%
neg-mul-133.5%
Simplified33.5%
Final simplification42.4%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J 2.6e-294) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= 2.6e-294) {
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 <= 2.6d-294) 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 <= 2.6e-294) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= 2.6e-294: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= 2.6e-294) 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 <= 2.6e-294) 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, 2.6e-294], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq 2.6 \cdot 10^{-294}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < 2.5999999999999999e-294Initial program 70.2%
Taylor expanded in U around -inf 26.8%
if 2.5999999999999999e-294 < J Initial program 76.0%
Taylor expanded in J around 0 21.9%
neg-mul-121.9%
Simplified21.9%
Final simplification24.5%
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 72.9%
Taylor expanded in U around -inf 26.2%
Final simplification26.2%
herbie shell --seed 2023306
(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)))))