
(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
(*
(* 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 1e+291) t_1 U))))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 <= 1e+291) {
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 = (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 <= 1e+291) {
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 = (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 <= 1e+291: 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(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 <= 1e+291) 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 = (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 <= 1e+291) 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[(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, 1e+291], t$95$1, U]]]]
\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 10^{+291}:\\
\;\;\;\;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 5.8%
Taylor expanded in J around 0 60.7%
neg-mul-160.7%
Simplified60.7%
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.9999999999999996e290Initial program 99.8%
if 9.9999999999999996e290 < (*.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.9%
Taylor expanded in U around -inf 48.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.2e-180) (not (<= J -2.7e-301)))
(* -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 <= -3.2e-180) || !(J <= -2.7e-301)) {
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 <= -3.2e-180) || !(J <= -2.7e-301)) {
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 <= -3.2e-180) or not (J <= -2.7e-301): 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 <= -3.2e-180) || !(J <= -2.7e-301)) 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 <= -3.2e-180) || ~((J <= -2.7e-301))) 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, -3.2e-180], N[Not[LessEqual[J, -2.7e-301]], $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 -3.2 \cdot 10^{-180} \lor \neg \left(J \leq -2.7 \cdot 10^{-301}\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 < -3.20000000000000015e-180 or -2.7e-301 < J Initial program 74.2%
Simplified92.1%
if -3.20000000000000015e-180 < J < -2.7e-301Initial program 32.2%
Taylor expanded in U around -inf 40.5%
Final simplification86.5%
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 -2.3e-180)
(* -2.0 (* t_0 (* J t_1)))
(if (<= J -2.7e-301) 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 <= -2.3e-180) {
tmp = -2.0 * (t_0 * (J * t_1));
} else if (J <= -2.7e-301) {
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 <= -2.3e-180) {
tmp = -2.0 * (t_0 * (J * t_1));
} else if (J <= -2.7e-301) {
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 <= -2.3e-180: tmp = -2.0 * (t_0 * (J * t_1)) elif J <= -2.7e-301: 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 <= -2.3e-180) tmp = Float64(-2.0 * Float64(t_0 * Float64(J * t_1))); elseif (J <= -2.7e-301) 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 <= -2.3e-180) tmp = -2.0 * (t_0 * (J * t_1)); elseif (J <= -2.7e-301) 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, -2.3e-180], N[(-2.0 * N[(t$95$0 * N[(J * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, -2.7e-301], 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 -2.3 \cdot 10^{-180}:\\
\;\;\;\;-2 \cdot \left(t_0 \cdot \left(J \cdot t_1\right)\right)\\
\mathbf{elif}\;J \leq -2.7 \cdot 10^{-301}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(t_1 \cdot \left(J \cdot t_0\right)\right)\\
\end{array}
\end{array}
if J < -2.29999999999999996e-180Initial program 81.7%
Simplified91.8%
if -2.29999999999999996e-180 < J < -2.7e-301Initial program 32.2%
Taylor expanded in U around -inf 40.5%
if -2.7e-301 < J Initial program 69.1%
associate-*l*69.1%
associate-*l*69.1%
unpow269.1%
hypot-1-def92.3%
associate-/r*92.3%
cos-neg92.3%
distribute-frac-neg92.3%
associate-/r*92.3%
associate-/r*92.3%
distribute-frac-neg92.3%
cos-neg92.3%
Simplified92.3%
Final simplification86.5%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* J (* (cos (* K 0.5)) (hypot 1.0 (* U (/ 0.5 J))))))))
(if (<= J -1.45e-69)
t_0
(if (<= J -4e-310) U (if (<= J 2e-124) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * (J * (cos((K * 0.5)) * hypot(1.0, (U * (0.5 / J)))));
double tmp;
if (J <= -1.45e-69) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 2e-124) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = -2.0 * (J * (Math.cos((K * 0.5)) * Math.hypot(1.0, (U * (0.5 / J)))));
double tmp;
if (J <= -1.45e-69) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 2e-124) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * (J * (math.cos((K * 0.5)) * math.hypot(1.0, (U * (0.5 / J))))) tmp = 0 if J <= -1.45e-69: tmp = t_0 elif J <= -4e-310: tmp = U elif J <= 2e-124: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(J * Float64(cos(Float64(K * 0.5)) * hypot(1.0, Float64(U * Float64(0.5 / J)))))) tmp = 0.0 if (J <= -1.45e-69) tmp = t_0; elseif (J <= -4e-310) tmp = U; elseif (J <= 2e-124) 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 * 0.5)) * hypot(1.0, (U * (0.5 / J))))); tmp = 0.0; if (J <= -1.45e-69) tmp = t_0; elseif (J <= -4e-310) tmp = U; elseif (J <= 2e-124) 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[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.45e-69], t$95$0, If[LessEqual[J, -4e-310], U, If[LessEqual[J, 2e-124], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\right)\right)\\
\mathbf{if}\;J \leq -1.45 \cdot 10^{-69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2 \cdot 10^{-124}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.4499999999999999e-69 or 1.99999999999999987e-124 < J Initial program 87.6%
associate-*l*87.6%
associate-*l*87.6%
unpow287.6%
hypot-1-def98.2%
associate-/r*98.1%
cos-neg98.1%
distribute-frac-neg98.1%
associate-/r*98.2%
associate-/r*98.1%
distribute-frac-neg98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in K around 0 85.6%
associate-*r/85.6%
Simplified85.6%
expm1-log1p-u52.4%
expm1-udef39.8%
Applied egg-rr39.8%
expm1-def52.4%
expm1-log1p85.6%
*-commutative85.6%
*-commutative85.6%
associate-/r/85.5%
Simplified85.5%
if -1.4499999999999999e-69 < J < -3.999999999999988e-310Initial program 37.9%
Taylor expanded in U around -inf 39.3%
if -3.999999999999988e-310 < J < 1.99999999999999987e-124Initial program 43.6%
Taylor expanded in J around 0 52.5%
neg-mul-152.5%
Simplified52.5%
Final simplification70.0%
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))) (hypot 1.0 (/ (* U 0.5) J))))))
(if (<= J -1.45e-69)
t_0
(if (<= J 6e-309) U (if (<= J 1.5e-124) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, ((U * 0.5) / J)));
double tmp;
if (J <= -1.45e-69) {
tmp = t_0;
} else if (J <= 6e-309) {
tmp = U;
} else if (J <= 1.5e-124) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
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))) * Math.hypot(1.0, ((U * 0.5) / J)));
double tmp;
if (J <= -1.45e-69) {
tmp = t_0;
} else if (J <= 6e-309) {
tmp = U;
} else if (J <= 1.5e-124) {
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))) * math.hypot(1.0, ((U * 0.5) / J))) tmp = 0 if J <= -1.45e-69: tmp = t_0 elif J <= 6e-309: tmp = U elif J <= 1.5e-124: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(Float64(J * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U * 0.5) / J)))) tmp = 0.0 if (J <= -1.45e-69) tmp = t_0; elseif (J <= 6e-309) tmp = U; elseif (J <= 1.5e-124) 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))) * hypot(1.0, ((U * 0.5) / J))); tmp = 0.0; if (J <= -1.45e-69) tmp = t_0; elseif (J <= 6e-309) tmp = U; elseif (J <= 1.5e-124) 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[(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[J, -1.45e-69], t$95$0, If[LessEqual[J, 6e-309], U, If[LessEqual[J, 1.5e-124], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -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{if}\;J \leq -1.45 \cdot 10^{-69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 6 \cdot 10^{-309}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.5 \cdot 10^{-124}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.4499999999999999e-69 or 1.5e-124 < J Initial program 87.6%
associate-*l*87.6%
associate-*l*87.6%
unpow287.6%
hypot-1-def98.2%
associate-/r*98.1%
cos-neg98.1%
distribute-frac-neg98.1%
associate-/r*98.2%
associate-/r*98.1%
distribute-frac-neg98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in K around 0 85.6%
associate-*r/85.6%
Simplified85.6%
if -1.4499999999999999e-69 < J < 6.000000000000001e-309Initial program 37.9%
Taylor expanded in U around -inf 39.3%
if 6.000000000000001e-309 < J < 1.5e-124Initial program 43.6%
Taylor expanded in J around 0 52.5%
neg-mul-152.5%
Simplified52.5%
Final simplification70.1%
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 -1.7e-69)
t_0
(if (<= J -4e-310)
U
(if (<= J 2.9e-95)
(- U)
(if (or (<= J 2.15e-6) (not (<= J 4.5e+23)))
t_0
(* (* -2.0 J) (+ (/ J U) (* 0.5 (/ U J))))))))))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 <= -1.7e-69) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 2.9e-95) {
tmp = -U;
} else if ((J <= 2.15e-6) || !(J <= 4.5e+23)) {
tmp = t_0;
} else {
tmp = (-2.0 * J) * ((J / U) + (0.5 * (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 = cos((k * 0.5d0)) * ((-2.0d0) * j)
if (j <= (-1.7d-69)) then
tmp = t_0
else if (j <= (-4d-310)) then
tmp = u
else if (j <= 2.9d-95) then
tmp = -u
else if ((j <= 2.15d-6) .or. (.not. (j <= 4.5d+23))) then
tmp = t_0
else
tmp = ((-2.0d0) * j) * ((j / u) + (0.5d0 * (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 = Math.cos((K * 0.5)) * (-2.0 * J);
double tmp;
if (J <= -1.7e-69) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 2.9e-95) {
tmp = -U;
} else if ((J <= 2.15e-6) || !(J <= 4.5e+23)) {
tmp = t_0;
} else {
tmp = (-2.0 * J) * ((J / U) + (0.5 * (U / J)));
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K * 0.5)) * (-2.0 * J) tmp = 0 if J <= -1.7e-69: tmp = t_0 elif J <= -4e-310: tmp = U elif J <= 2.9e-95: tmp = -U elif (J <= 2.15e-6) or not (J <= 4.5e+23): tmp = t_0 else: tmp = (-2.0 * J) * ((J / U) + (0.5 * (U / J))) 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 <= -1.7e-69) tmp = t_0; elseif (J <= -4e-310) tmp = U; elseif (J <= 2.9e-95) tmp = Float64(-U); elseif ((J <= 2.15e-6) || !(J <= 4.5e+23)) tmp = t_0; else tmp = Float64(Float64(-2.0 * J) * Float64(Float64(J / U) + Float64(0.5 * Float64(U / J)))); 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 <= -1.7e-69) tmp = t_0; elseif (J <= -4e-310) tmp = U; elseif (J <= 2.9e-95) tmp = -U; elseif ((J <= 2.15e-6) || ~((J <= 4.5e+23))) tmp = t_0; else tmp = (-2.0 * J) * ((J / U) + (0.5 * (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[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.7e-69], t$95$0, If[LessEqual[J, -4e-310], U, If[LessEqual[J, 2.9e-95], (-U), If[Or[LessEqual[J, 2.15e-6], N[Not[LessEqual[J, 4.5e+23]], $MachinePrecision]], t$95$0, N[(N[(-2.0 * J), $MachinePrecision] * N[(N[(J / U), $MachinePrecision] + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\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 -1.7 \cdot 10^{-69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2.9 \cdot 10^{-95}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq 2.15 \cdot 10^{-6} \lor \neg \left(J \leq 4.5 \cdot 10^{+23}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \left(\frac{J}{U} + 0.5 \cdot \frac{U}{J}\right)\\
\end{array}
\end{array}
if J < -1.70000000000000004e-69 or 2.90000000000000002e-95 < J < 2.15000000000000017e-6 or 4.49999999999999979e23 < J Initial program 93.3%
Taylor expanded in J around inf 76.3%
associate-*r*76.3%
*-commutative76.3%
Simplified76.3%
if -1.70000000000000004e-69 < J < -3.999999999999988e-310Initial program 37.9%
Taylor expanded in U around -inf 39.3%
if -3.999999999999988e-310 < J < 2.90000000000000002e-95Initial program 44.2%
Taylor expanded in J around 0 53.5%
neg-mul-153.5%
Simplified53.5%
if 2.15000000000000017e-6 < J < 4.49999999999999979e23Initial program 28.2%
Taylor expanded in K around 0 26.8%
associate-*r*26.8%
*-commutative26.8%
metadata-eval26.8%
unpow226.8%
unpow226.8%
times-frac26.8%
swap-sqr26.8%
associate-*r/26.8%
*-commutative26.8%
associate-*r/26.8%
associate-*r/26.8%
*-commutative26.8%
associate-*r/26.8%
unpow226.8%
associate-*r/26.8%
*-commutative26.8%
associate-*r/26.8%
Simplified26.8%
Taylor expanded in U around inf 45.0%
Final simplification62.7%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 1.66e-91) (* (cos (* K 0.5)) (* -2.0 J)) (if (<= U 1.46e+169) (* (* -2.0 J) (hypot 1.0 (/ 0.5 (/ J U)))) (- U))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 1.66e-91) {
tmp = cos((K * 0.5)) * (-2.0 * J);
} else if (U <= 1.46e+169) {
tmp = (-2.0 * J) * hypot(1.0, (0.5 / (J / U)));
} else {
tmp = -U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 1.66e-91) {
tmp = Math.cos((K * 0.5)) * (-2.0 * J);
} else if (U <= 1.46e+169) {
tmp = (-2.0 * J) * Math.hypot(1.0, (0.5 / (J / U)));
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 1.66e-91: tmp = math.cos((K * 0.5)) * (-2.0 * J) elif U <= 1.46e+169: tmp = (-2.0 * J) * math.hypot(1.0, (0.5 / (J / U))) else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 1.66e-91) tmp = Float64(cos(Float64(K * 0.5)) * Float64(-2.0 * J)); elseif (U <= 1.46e+169) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(0.5 / Float64(J / U)))); else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 1.66e-91) tmp = cos((K * 0.5)) * (-2.0 * J); elseif (U <= 1.46e+169) tmp = (-2.0 * J) * hypot(1.0, (0.5 / (J / 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, 1.66e-91], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 1.46e+169], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 / N[(J / U), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], (-U)]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 1.66 \cdot 10^{-91}:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(-2 \cdot J\right)\\
\mathbf{elif}\;U \leq 1.46 \cdot 10^{+169}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{0.5}{\frac{J}{U}}\right)\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < 1.66e-91Initial program 79.2%
Taylor expanded in J around inf 61.5%
associate-*r*61.5%
*-commutative61.5%
Simplified61.5%
if 1.66e-91 < U < 1.45999999999999992e169Initial program 60.5%
Taylor expanded in K around 0 34.7%
associate-*r*34.7%
*-commutative34.7%
metadata-eval34.7%
unpow234.7%
unpow234.7%
times-frac36.7%
swap-sqr36.7%
associate-*r/36.7%
*-commutative36.7%
associate-*r/36.7%
associate-*r/36.7%
*-commutative36.7%
associate-*r/36.6%
unpow236.6%
associate-*r/36.7%
*-commutative36.7%
associate-*r/36.7%
Simplified36.7%
metadata-eval36.7%
unpow236.7%
associate-*r/36.7%
associate-*r/36.7%
hypot-udef62.4%
associate-/l*62.3%
Applied egg-rr62.3%
if 1.45999999999999992e169 < U Initial program 33.0%
Taylor expanded in J around 0 55.4%
neg-mul-155.4%
Simplified55.4%
Final simplification60.8%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2.6e-69) (* -2.0 J) (if (<= J -4e-310) U (if (<= J 3.2e+22) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2.6e-69) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 3.2e+22) {
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 <= (-2.6d-69)) then
tmp = (-2.0d0) * j
else if (j <= (-4d-310)) then
tmp = u
else if (j <= 3.2d+22) 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 <= -2.6e-69) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 3.2e+22) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2.6e-69: tmp = -2.0 * J elif J <= -4e-310: tmp = U elif J <= 3.2e+22: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2.6e-69) tmp = Float64(-2.0 * J); elseif (J <= -4e-310) tmp = U; elseif (J <= 3.2e+22) 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 <= -2.6e-69) tmp = -2.0 * J; elseif (J <= -4e-310) tmp = U; elseif (J <= 3.2e+22) 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, -2.6e-69], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -4e-310], U, If[LessEqual[J, 3.2e+22], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.6 \cdot 10^{-69}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 3.2 \cdot 10^{+22}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -2.6000000000000002e-69 or 3.2e22 < J Initial program 96.0%
Taylor expanded in J around inf 78.5%
associate-*r*78.5%
*-commutative78.5%
Simplified78.5%
Taylor expanded in K around 0 49.4%
*-commutative49.4%
Simplified49.4%
if -2.6000000000000002e-69 < J < -3.999999999999988e-310Initial program 37.9%
Taylor expanded in U around -inf 39.3%
if -3.999999999999988e-310 < J < 3.2e22Initial program 51.5%
Taylor expanded in J around 0 42.4%
neg-mul-142.4%
Simplified42.4%
Final simplification45.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -4e-310) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -4e-310) {
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 <= (-4d-310)) 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 <= -4e-310) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -4e-310: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -4e-310) 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 <= -4e-310) 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, -4e-310], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -3.999999999999988e-310Initial program 68.8%
Taylor expanded in U around -inf 27.4%
if -3.999999999999988e-310 < J Initial program 70.4%
Taylor expanded in J around 0 30.9%
neg-mul-130.9%
Simplified30.9%
Final simplification29.2%
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 69.6%
Taylor expanded in U around -inf 25.6%
Final simplification25.6%
herbie shell --seed 2023313
(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)))))