
(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 10 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))
(- U)
(if (<= t_1 1e+302)
(* (* 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 = -U;
} else if (t_1 <= 1e+302) {
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 = -U;
} else if (t_1 <= 1e+302) {
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 = -U elif t_1 <= 1e+302: 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(-U); elseif (t_1 <= 1e+302) 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 = -U; elseif (t_1 <= 1e+302) 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)], (-U), If[LessEqual[t$95$1, 1e+302], 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:\\
\;\;\;\;-U\\
\mathbf{elif}\;t_1 \leq 10^{+302}:\\
\;\;\;\;\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 5.1%
*-commutative5.1%
associate-*l*5.1%
associate-*r*5.1%
*-commutative5.1%
associate-*l*5.1%
*-commutative5.1%
unpow25.1%
hypot-1-def64.9%
*-commutative64.9%
associate-*l*64.9%
Simplified64.9%
Taylor expanded in J around 0 30.1%
neg-mul-130.1%
Simplified30.1%
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)))) < 1.0000000000000001e302Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.9%
*-commutative99.9%
associate-*l*99.9%
Simplified99.9%
if 1.0000000000000001e302 < (*.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.4%
*-commutative7.4%
associate-*l*7.4%
associate-*r*7.4%
*-commutative7.4%
associate-*l*7.4%
*-commutative7.4%
unpow27.4%
hypot-1-def53.8%
*-commutative53.8%
associate-*l*53.8%
Simplified53.8%
Taylor expanded in U around -inf 54.0%
Final simplification85.1%
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 -3.7e-200) (not (<= J 6.5e-308)))
(* J (* t_0 (* -2.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 tmp;
if ((J <= -3.7e-200) || !(J <= 6.5e-308)) {
tmp = J * (t_0 * (-2.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 tmp;
if ((J <= -3.7e-200) || !(J <= 6.5e-308)) {
tmp = J * (t_0 * (-2.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)) tmp = 0 if (J <= -3.7e-200) or not (J <= 6.5e-308): tmp = J * (t_0 * (-2.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)) tmp = 0.0 if ((J <= -3.7e-200) || !(J <= 6.5e-308)) tmp = Float64(J * Float64(t_0 * Float64(-2.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)); tmp = 0.0; if ((J <= -3.7e-200) || ~((J <= 6.5e-308))) tmp = J * (t_0 * (-2.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]}, If[Or[LessEqual[J, -3.7e-200], N[Not[LessEqual[J, 6.5e-308]], $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], U]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;J \leq -3.7 \cdot 10^{-200} \lor \neg \left(J \leq 6.5 \cdot 10^{-308}\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)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if J < -3.70000000000000011e-200 or 6.4999999999999999e-308 < J Initial program 81.5%
*-commutative81.5%
associate-*l*81.5%
associate-*r*81.5%
*-commutative81.5%
associate-*l*81.5%
*-commutative81.5%
unpow281.5%
hypot-1-def94.3%
*-commutative94.3%
associate-*l*94.3%
Simplified94.3%
if -3.70000000000000011e-200 < J < 6.4999999999999999e-308Initial program 34.4%
*-commutative34.4%
associate-*l*34.4%
associate-*r*34.4%
*-commutative34.4%
associate-*l*34.4%
*-commutative34.4%
unpow234.4%
hypot-1-def53.8%
*-commutative53.8%
associate-*l*53.8%
Simplified53.8%
Taylor expanded in U around -inf 41.6%
Final simplification87.1%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (* U (/ 0.5 J))))))
(if (<= J -1.5e-198)
t_0
(if (<= J 6.5e-308)
U
(if (<= J 5.3e-87) (- (* -2.0 (/ J (/ U J))) U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U * (0.5 / J)));
double tmp;
if (J <= -1.5e-198) {
tmp = t_0;
} else if (J <= 6.5e-308) {
tmp = U;
} else if (J <= 5.3e-87) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = (J * (-2.0 * Math.cos((K / 2.0)))) * Math.hypot(1.0, (U * (0.5 / J)));
double tmp;
if (J <= -1.5e-198) {
tmp = t_0;
} else if (J <= 6.5e-308) {
tmp = U;
} else if (J <= 5.3e-87) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = (J * (-2.0 * math.cos((K / 2.0)))) * math.hypot(1.0, (U * (0.5 / J))) tmp = 0 if J <= -1.5e-198: tmp = t_0 elif J <= 6.5e-308: tmp = U elif J <= 5.3e-87: tmp = (-2.0 * (J / (U / J))) - U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(U * Float64(0.5 / J)))) tmp = 0.0 if (J <= -1.5e-198) tmp = t_0; elseif (J <= 6.5e-308) tmp = U; elseif (J <= 5.3e-87) tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / 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 / 2.0)))) * hypot(1.0, (U * (0.5 / J))); tmp = 0.0; if (J <= -1.5e-198) tmp = t_0; elseif (J <= 6.5e-308) tmp = U; elseif (J <= 5.3e-87) tmp = (-2.0 * (J / (U / 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[(N[(J * N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.5e-198], t$95$0, If[LessEqual[J, 6.5e-308], U, If[LessEqual[J, 5.3e-87], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\\
\mathbf{if}\;J \leq -1.5 \cdot 10^{-198}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 6.5 \cdot 10^{-308}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 5.3 \cdot 10^{-87}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.5000000000000001e-198 or 5.29999999999999986e-87 < J Initial program 86.8%
*-commutative86.8%
associate-*l*86.8%
unpow286.8%
hypot-1-def97.9%
*-commutative97.9%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in U around 0 97.9%
*-commutative97.9%
metadata-eval97.9%
times-frac97.9%
*-commutative97.9%
associate-*r*97.9%
associate-*r/97.8%
associate-*r*97.8%
*-commutative97.8%
*-commutative97.8%
associate-/r*97.8%
metadata-eval97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in K around 0 85.8%
if -1.5000000000000001e-198 < J < 6.4999999999999999e-308Initial program 34.4%
*-commutative34.4%
associate-*l*34.4%
associate-*r*34.4%
*-commutative34.4%
associate-*l*34.4%
*-commutative34.4%
unpow234.4%
hypot-1-def53.8%
*-commutative53.8%
associate-*l*53.8%
Simplified53.8%
Taylor expanded in U around -inf 41.6%
if 6.4999999999999999e-308 < J < 5.29999999999999986e-87Initial program 52.4%
*-commutative52.4%
associate-*l*52.4%
unpow252.4%
hypot-1-def75.0%
*-commutative75.0%
associate-*l*75.0%
Simplified75.0%
Taylor expanded in K around 0 44.6%
Taylor expanded in K around 0 58.9%
Taylor expanded in J around 0 33.7%
neg-mul-133.7%
unsub-neg33.7%
unpow233.7%
associate-/l*33.7%
Simplified33.7%
Final simplification72.8%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (/ U (* J 2.0))))))
(if (<= J -5.6e-198)
t_0
(if (<= J 6.5e-308)
U
(if (<= J 5.8e-87) (- (* -2.0 (/ J (/ U J))) U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0)));
double tmp;
if (J <= -5.6e-198) {
tmp = t_0;
} else if (J <= 6.5e-308) {
tmp = U;
} else if (J <= 5.8e-87) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = (J * (-2.0 * Math.cos((K / 2.0)))) * Math.hypot(1.0, (U / (J * 2.0)));
double tmp;
if (J <= -5.6e-198) {
tmp = t_0;
} else if (J <= 6.5e-308) {
tmp = U;
} else if (J <= 5.8e-87) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = (J * (-2.0 * math.cos((K / 2.0)))) * math.hypot(1.0, (U / (J * 2.0))) tmp = 0 if J <= -5.6e-198: tmp = t_0 elif J <= 6.5e-308: tmp = U elif J <= 5.8e-87: tmp = (-2.0 * (J / (U / J))) - U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(U / Float64(J * 2.0)))) tmp = 0.0 if (J <= -5.6e-198) tmp = t_0; elseif (J <= 6.5e-308) tmp = U; elseif (J <= 5.8e-87) tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / 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 / 2.0)))) * hypot(1.0, (U / (J * 2.0))); tmp = 0.0; if (J <= -5.6e-198) tmp = t_0; elseif (J <= 6.5e-308) tmp = U; elseif (J <= 5.8e-87) tmp = (-2.0 * (J / (U / 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[(N[(J * N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -5.6e-198], t$95$0, If[LessEqual[J, 6.5e-308], U, If[LessEqual[J, 5.8e-87], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\\
\mathbf{if}\;J \leq -5.6 \cdot 10^{-198}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 6.5 \cdot 10^{-308}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 5.8 \cdot 10^{-87}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -5.5999999999999998e-198 or 5.7999999999999998e-87 < J Initial program 86.8%
*-commutative86.8%
associate-*l*86.8%
unpow286.8%
hypot-1-def97.9%
*-commutative97.9%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in K around 0 85.9%
if -5.5999999999999998e-198 < J < 6.4999999999999999e-308Initial program 34.4%
*-commutative34.4%
associate-*l*34.4%
associate-*r*34.4%
*-commutative34.4%
associate-*l*34.4%
*-commutative34.4%
unpow234.4%
hypot-1-def53.8%
*-commutative53.8%
associate-*l*53.8%
Simplified53.8%
Taylor expanded in U around -inf 41.6%
if 6.4999999999999999e-308 < J < 5.7999999999999998e-87Initial program 52.4%
*-commutative52.4%
associate-*l*52.4%
unpow252.4%
hypot-1-def75.0%
*-commutative75.0%
associate-*l*75.0%
Simplified75.0%
Taylor expanded in K around 0 44.6%
Taylor expanded in K around 0 58.9%
Taylor expanded in J around 0 33.7%
neg-mul-133.7%
unsub-neg33.7%
unpow233.7%
associate-/l*33.7%
Simplified33.7%
Final simplification72.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 -3e-10)
t_0
(if (<= J 6.5e-308) U (if (<= J 5.2e-70) (- 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 <= -3e-10) {
tmp = t_0;
} else if (J <= 6.5e-308) {
tmp = U;
} else if (J <= 5.2e-70) {
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 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-3d-10)) then
tmp = t_0
else if (j <= 6.5d-308) then
tmp = u
else if (j <= 5.2d-70) 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 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (J <= -3e-10) {
tmp = t_0;
} else if (J <= 6.5e-308) {
tmp = U;
} else if (J <= 5.2e-70) {
tmp = -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 <= -3e-10: tmp = t_0 elif J <= 6.5e-308: tmp = U elif J <= 5.2e-70: tmp = -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 <= -3e-10) tmp = t_0; elseif (J <= 6.5e-308) tmp = U; elseif (J <= 5.2e-70) tmp = Float64(-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 <= -3e-10) tmp = t_0; elseif (J <= 6.5e-308) tmp = U; elseif (J <= 5.2e-70) 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[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -3e-10], t$95$0, If[LessEqual[J, 6.5e-308], U, If[LessEqual[J, 5.2e-70], (-U), 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 -3 \cdot 10^{-10}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 6.5 \cdot 10^{-308}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 5.2 \cdot 10^{-70}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -3e-10 or 5.20000000000000004e-70 < J Initial program 92.0%
*-commutative92.0%
associate-*l*92.0%
associate-*r*92.0%
*-commutative92.0%
associate-*l*91.9%
*-commutative91.9%
unpow291.9%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 75.6%
if -3e-10 < J < 6.4999999999999999e-308Initial program 47.2%
*-commutative47.2%
associate-*l*47.2%
associate-*r*47.2%
*-commutative47.2%
associate-*l*47.2%
*-commutative47.2%
unpow247.2%
hypot-1-def70.8%
*-commutative70.8%
associate-*l*70.8%
Simplified70.8%
Taylor expanded in U around -inf 40.3%
if 6.4999999999999999e-308 < J < 5.20000000000000004e-70Initial program 52.4%
*-commutative52.4%
associate-*l*52.4%
associate-*r*52.4%
*-commutative52.4%
associate-*l*52.4%
*-commutative52.4%
unpow252.4%
hypot-1-def73.8%
*-commutative73.8%
associate-*l*73.8%
Simplified73.8%
Taylor expanded in J around 0 32.0%
neg-mul-132.0%
Simplified32.0%
Final simplification60.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= K 0.0065) (* (* -2.0 J) (hypot 1.0 (/ U (* J 2.0)))) (* J (* -2.0 (cos (* K 0.5))))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (K <= 0.0065) {
tmp = (-2.0 * J) * hypot(1.0, (U / (J * 2.0)));
} else {
tmp = J * (-2.0 * cos((K * 0.5)));
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (K <= 0.0065) {
tmp = (-2.0 * J) * Math.hypot(1.0, (U / (J * 2.0)));
} else {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if K <= 0.0065: tmp = (-2.0 * J) * math.hypot(1.0, (U / (J * 2.0))) else: tmp = J * (-2.0 * math.cos((K * 0.5))) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (K <= 0.0065) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(U / Float64(J * 2.0)))); else tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (K <= 0.0065) tmp = (-2.0 * J) * hypot(1.0, (U / (J * 2.0))); else tmp = J * (-2.0 * cos((K * 0.5))); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[K, 0.0065], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;K \leq 0.0065:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if K < 0.0064999999999999997Initial program 72.8%
*-commutative72.8%
associate-*l*72.8%
unpow272.8%
hypot-1-def85.4%
*-commutative85.4%
associate-*l*85.4%
Simplified85.4%
Taylor expanded in K around 0 76.0%
Taylor expanded in K around 0 62.9%
if 0.0064999999999999997 < K Initial program 81.3%
*-commutative81.3%
associate-*l*81.3%
associate-*r*81.3%
*-commutative81.3%
associate-*l*81.3%
*-commutative81.3%
unpow281.3%
hypot-1-def98.2%
*-commutative98.2%
associate-*l*98.2%
Simplified98.2%
Taylor expanded in U around 0 60.3%
Final simplification62.2%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= J -1.15e+82)
(* -2.0 J)
(if (<= J 6.5e-308)
U
(if (<= J 4.3e+16) (- (* -2.0 (/ J (/ U J))) U) (* -2.0 J)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.15e+82) {
tmp = -2.0 * J;
} else if (J <= 6.5e-308) {
tmp = U;
} else if (J <= 4.3e+16) {
tmp = (-2.0 * (J / (U / J))) - 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.15d+82)) then
tmp = (-2.0d0) * j
else if (j <= 6.5d-308) then
tmp = u
else if (j <= 4.3d+16) then
tmp = ((-2.0d0) * (j / (u / j))) - 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.15e+82) {
tmp = -2.0 * J;
} else if (J <= 6.5e-308) {
tmp = U;
} else if (J <= 4.3e+16) {
tmp = (-2.0 * (J / (U / J))) - U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.15e+82: tmp = -2.0 * J elif J <= 6.5e-308: tmp = U elif J <= 4.3e+16: tmp = (-2.0 * (J / (U / J))) - U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.15e+82) tmp = Float64(-2.0 * J); elseif (J <= 6.5e-308) tmp = U; elseif (J <= 4.3e+16) tmp = Float64(Float64(-2.0 * Float64(J / Float64(U / J))) - 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.15e+82) tmp = -2.0 * J; elseif (J <= 6.5e-308) tmp = U; elseif (J <= 4.3e+16) tmp = (-2.0 * (J / (U / J))) - 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.15e+82], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, 6.5e-308], U, If[LessEqual[J, 4.3e+16], N[(N[(-2.0 * N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.15 \cdot 10^{+82}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq 6.5 \cdot 10^{-308}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 4.3 \cdot 10^{+16}:\\
\;\;\;\;-2 \cdot \frac{J}{\frac{U}{J}} - U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -1.14999999999999994e82 or 4.3e16 < J Initial program 98.2%
*-commutative98.2%
associate-*l*98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*l*98.2%
*-commutative98.2%
unpow298.2%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 82.9%
Taylor expanded in K around 0 43.2%
if -1.14999999999999994e82 < J < 6.4999999999999999e-308Initial program 54.7%
*-commutative54.7%
associate-*l*54.7%
associate-*r*54.7%
*-commutative54.7%
associate-*l*54.7%
*-commutative54.7%
unpow254.7%
hypot-1-def76.8%
*-commutative76.8%
associate-*l*76.8%
Simplified76.8%
Taylor expanded in U around -inf 38.6%
if 6.4999999999999999e-308 < J < 4.3e16Initial program 57.4%
*-commutative57.4%
associate-*l*57.4%
unpow257.4%
hypot-1-def83.7%
*-commutative83.7%
associate-*l*83.7%
Simplified83.7%
Taylor expanded in K around 0 57.6%
Taylor expanded in K around 0 62.3%
Taylor expanded in J around 0 29.0%
neg-mul-129.0%
unsub-neg29.0%
unpow229.0%
associate-/l*29.0%
Simplified29.0%
Final simplification38.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -1.2e+83) (* -2.0 J) (if (<= J 6.5e-308) U (if (<= J 3.8e+16) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.2e+83) {
tmp = -2.0 * J;
} else if (J <= 6.5e-308) {
tmp = U;
} else if (J <= 3.8e+16) {
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.2d+83)) then
tmp = (-2.0d0) * j
else if (j <= 6.5d-308) then
tmp = u
else if (j <= 3.8d+16) 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.2e+83) {
tmp = -2.0 * J;
} else if (J <= 6.5e-308) {
tmp = U;
} else if (J <= 3.8e+16) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.2e+83: tmp = -2.0 * J elif J <= 6.5e-308: tmp = U elif J <= 3.8e+16: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.2e+83) tmp = Float64(-2.0 * J); elseif (J <= 6.5e-308) tmp = U; elseif (J <= 3.8e+16) 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.2e+83) tmp = -2.0 * J; elseif (J <= 6.5e-308) tmp = U; elseif (J <= 3.8e+16) 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.2e+83], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, 6.5e-308], U, If[LessEqual[J, 3.8e+16], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.2 \cdot 10^{+83}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq 6.5 \cdot 10^{-308}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 3.8 \cdot 10^{+16}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -1.19999999999999996e83 or 3.8e16 < J Initial program 98.2%
*-commutative98.2%
associate-*l*98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*l*98.2%
*-commutative98.2%
unpow298.2%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 82.9%
Taylor expanded in K around 0 43.2%
if -1.19999999999999996e83 < J < 6.4999999999999999e-308Initial program 54.7%
*-commutative54.7%
associate-*l*54.7%
associate-*r*54.7%
*-commutative54.7%
associate-*l*54.7%
*-commutative54.7%
unpow254.7%
hypot-1-def76.8%
*-commutative76.8%
associate-*l*76.8%
Simplified76.8%
Taylor expanded in U around -inf 38.6%
if 6.4999999999999999e-308 < J < 3.8e16Initial program 57.4%
*-commutative57.4%
associate-*l*57.4%
associate-*r*57.4%
*-commutative57.4%
associate-*l*57.4%
*-commutative57.4%
unpow257.4%
hypot-1-def83.6%
*-commutative83.6%
associate-*l*83.6%
Simplified83.6%
Taylor expanded in J around 0 29.1%
neg-mul-129.1%
Simplified29.1%
Final simplification38.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J 6.5e-308) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= 6.5e-308) {
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 <= 6.5d-308) 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 <= 6.5e-308) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= 6.5e-308: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= 6.5e-308) 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 <= 6.5e-308) 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, 6.5e-308], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq 6.5 \cdot 10^{-308}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < 6.4999999999999999e-308Initial program 70.0%
*-commutative70.0%
associate-*l*70.0%
associate-*r*70.0%
*-commutative70.0%
associate-*l*70.0%
*-commutative70.0%
unpow270.0%
hypot-1-def84.9%
*-commutative84.9%
associate-*l*84.9%
Simplified84.9%
Taylor expanded in U around -inf 29.5%
if 6.4999999999999999e-308 < J Initial program 80.0%
*-commutative80.0%
associate-*l*80.0%
associate-*r*80.0%
*-commutative80.0%
associate-*l*80.0%
*-commutative80.0%
unpow280.0%
hypot-1-def92.6%
*-commutative92.6%
associate-*l*92.6%
Simplified92.6%
Taylor expanded in J around 0 18.4%
neg-mul-118.4%
Simplified18.4%
Final simplification23.9%
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 75.0%
*-commutative75.0%
associate-*l*75.0%
associate-*r*75.0%
*-commutative75.0%
associate-*l*75.0%
*-commutative75.0%
unpow275.0%
hypot-1-def88.8%
*-commutative88.8%
associate-*l*88.8%
Simplified88.8%
Taylor expanded in U around -inf 27.8%
Final simplification27.8%
herbie shell --seed 2023200
(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)))))