
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t_0}\right)}^{2}}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t_0}\right)}^{2}}
\end{array}
\end{array}
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY)) (- U) (if (<= t_1 1e+303) 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 = -U;
} else if (t_1 <= 1e+303) {
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 = -U;
} else if (t_1 <= 1e+303) {
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 = -U elif t_1 <= 1e+303: 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(-U); elseif (t_1 <= 1e+303) 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 = -U; elseif (t_1 <= 1e+303) 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)], (-U), If[LessEqual[t$95$1, 1e+303], 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:\\
\;\;\;\;-U\\
\mathbf{elif}\;t_1 \leq 10^{+303}:\\
\;\;\;\;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.7%
Taylor expanded in J around 0 44.4%
neg-mul-144.4%
Simplified44.4%
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)))) < 1e303Initial program 99.7%
if 1e303 < (*.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.4%
Taylor expanded in U around -inf 46.5%
Final simplification82.8%
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 (* t_0 (* J (hypot 1.0 (/ (/ U (* J 2.0)) t_0)))))))
(if (<= J -6.9e-161)
t_1
(if (<= J -2e-310) U (if (<= J 6.2e-234) (- U) t_1)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = -2.0 * (t_0 * (J * hypot(1.0, ((U / (J * 2.0)) / t_0))));
double tmp;
if (J <= -6.9e-161) {
tmp = t_1;
} else if (J <= -2e-310) {
tmp = U;
} else if (J <= 6.2e-234) {
tmp = -U;
} else {
tmp = t_1;
}
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 * (t_0 * (J * Math.hypot(1.0, ((U / (J * 2.0)) / t_0))));
double tmp;
if (J <= -6.9e-161) {
tmp = t_1;
} else if (J <= -2e-310) {
tmp = U;
} else if (J <= 6.2e-234) {
tmp = -U;
} else {
tmp = t_1;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = -2.0 * (t_0 * (J * math.hypot(1.0, ((U / (J * 2.0)) / t_0)))) tmp = 0 if J <= -6.9e-161: tmp = t_1 elif J <= -2e-310: tmp = U elif J <= 6.2e-234: tmp = -U else: tmp = t_1 return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(-2.0 * Float64(t_0 * Float64(J * hypot(1.0, Float64(Float64(U / Float64(J * 2.0)) / t_0))))) tmp = 0.0 if (J <= -6.9e-161) tmp = t_1; elseif (J <= -2e-310) tmp = U; elseif (J <= 6.2e-234) tmp = Float64(-U); else tmp = t_1; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = -2.0 * (t_0 * (J * hypot(1.0, ((U / (J * 2.0)) / t_0)))); tmp = 0.0; if (J <= -6.9e-161) tmp = t_1; elseif (J <= -2e-310) tmp = U; elseif (J <= 6.2e-234) tmp = -U; else tmp = t_1; 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[(-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]}, If[LessEqual[J, -6.9e-161], t$95$1, If[LessEqual[J, -2e-310], U, If[LessEqual[J, 6.2e-234], (-U), t$95$1]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := -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{if}\;J \leq -6.9 \cdot 10^{-161}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 6.2 \cdot 10^{-234}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if J < -6.90000000000000002e-161 or 6.2000000000000003e-234 < J Initial program 81.6%
Simplified93.0%
if -6.90000000000000002e-161 < J < -1.999999999999994e-310Initial program 26.5%
Taylor expanded in U around -inf 46.1%
if -1.999999999999994e-310 < J < 6.2000000000000003e-234Initial program 19.3%
Taylor expanded in J around 0 38.4%
neg-mul-138.4%
Simplified38.4%
Final simplification83.2%
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 -1e-156)
t_0
(if (<= J -7e-308) U (if (<= J 1.05e-49) (- 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 <= -1e-156) {
tmp = t_0;
} else if (J <= -7e-308) {
tmp = U;
} else if (J <= 1.05e-49) {
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 <= -1e-156) {
tmp = t_0;
} else if (J <= -7e-308) {
tmp = U;
} else if (J <= 1.05e-49) {
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 <= -1e-156: tmp = t_0 elif J <= -7e-308: tmp = U elif J <= 1.05e-49: 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(U * Float64(0.5 / J))))) tmp = 0.0 if (J <= -1e-156) tmp = t_0; elseif (J <= -7e-308) tmp = U; elseif (J <= 1.05e-49) 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 <= -1e-156) tmp = t_0; elseif (J <= -7e-308) tmp = U; elseif (J <= 1.05e-49) 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[(U * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1e-156], t$95$0, If[LessEqual[J, -7e-308], U, If[LessEqual[J, 1.05e-49], (-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, U \cdot \frac{0.5}{J}\right)\right)\\
\mathbf{if}\;J \leq -1 \cdot 10^{-156}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -7 \cdot 10^{-308}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.05 \cdot 10^{-49}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.00000000000000004e-156 or 1.0499999999999999e-49 < J Initial program 85.3%
associate-*l*85.3%
associate-*l*85.3%
unpow285.3%
hypot-1-def95.7%
associate-/r*95.6%
cos-neg95.6%
distribute-frac-neg95.6%
associate-/r*95.7%
associate-/r*95.6%
distribute-frac-neg95.6%
cos-neg95.6%
Simplified95.6%
Taylor expanded in K around 0 82.0%
associate-*r/82.0%
*-commutative82.0%
associate-*r/81.9%
Simplified81.9%
if -1.00000000000000004e-156 < J < -7e-308Initial program 26.5%
Taylor expanded in U around -inf 46.1%
if -7e-308 < J < 1.0499999999999999e-49Initial program 40.6%
Taylor expanded in J around 0 41.6%
neg-mul-141.6%
Simplified41.6%
Final simplification70.5%
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 -2.75e-18)
t_0
(if (<= J -2e-310)
U
(if (<= J 8.5e-21)
(- U)
(if (<= J 1.85e+149)
(* (* -2.0 J) (hypot 1.0 (* U (/ 0.5 J))))
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 <= -2.75e-18) {
tmp = t_0;
} else if (J <= -2e-310) {
tmp = U;
} else if (J <= 8.5e-21) {
tmp = -U;
} else if (J <= 1.85e+149) {
tmp = (-2.0 * J) * hypot(1.0, (U * (0.5 / J)));
} 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 * 0.5)));
double tmp;
if (J <= -2.75e-18) {
tmp = t_0;
} else if (J <= -2e-310) {
tmp = U;
} else if (J <= 8.5e-21) {
tmp = -U;
} else if (J <= 1.85e+149) {
tmp = (-2.0 * J) * Math.hypot(1.0, (U * (0.5 / J)));
} 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 <= -2.75e-18: tmp = t_0 elif J <= -2e-310: tmp = U elif J <= 8.5e-21: tmp = -U elif J <= 1.85e+149: tmp = (-2.0 * J) * math.hypot(1.0, (U * (0.5 / J))) 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 <= -2.75e-18) tmp = t_0; elseif (J <= -2e-310) tmp = U; elseif (J <= 8.5e-21) tmp = Float64(-U); elseif (J <= 1.85e+149) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(U * Float64(0.5 / J)))); 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 <= -2.75e-18) tmp = t_0; elseif (J <= -2e-310) tmp = U; elseif (J <= 8.5e-21) tmp = -U; elseif (J <= 1.85e+149) tmp = (-2.0 * J) * hypot(1.0, (U * (0.5 / J))); 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, -2.75e-18], t$95$0, If[LessEqual[J, -2e-310], U, If[LessEqual[J, 8.5e-21], (-U), If[LessEqual[J, 1.85e+149], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -2.75 \cdot 10^{-18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 8.5 \cdot 10^{-21}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq 1.85 \cdot 10^{+149}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -2.75e-18 or 1.84999999999999989e149 < J Initial program 96.1%
Taylor expanded in J around inf 86.7%
associate-*r*86.7%
*-commutative86.7%
*-commutative86.7%
associate-*r*86.7%
*-commutative86.7%
Simplified86.7%
if -2.75e-18 < J < -1.999999999999994e-310Initial program 43.2%
Taylor expanded in U around -inf 42.2%
if -1.999999999999994e-310 < J < 8.4999999999999993e-21Initial program 41.5%
Taylor expanded in J around 0 40.3%
neg-mul-140.3%
Simplified40.3%
if 8.4999999999999993e-21 < J < 1.84999999999999989e149Initial program 94.3%
expm1-log1p-u23.4%
expm1-udef20.8%
Applied egg-rr20.8%
expm1-def23.4%
expm1-log1p99.6%
*-commutative99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in K around 0 78.3%
Taylor expanded in K around 0 67.6%
Final simplification62.8%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -7.6e-17)
t_0
(if (<= J -2e-310)
U
(if (or (<= J 9.2e-48) (and (not (<= J 1.4e+22)) (<= J 2.3e+57)))
(- 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 <= -7.6e-17) {
tmp = t_0;
} else if (J <= -2e-310) {
tmp = U;
} else if ((J <= 9.2e-48) || (!(J <= 1.4e+22) && (J <= 2.3e+57))) {
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 <= (-7.6d-17)) then
tmp = t_0
else if (j <= (-2d-310)) then
tmp = u
else if ((j <= 9.2d-48) .or. (.not. (j <= 1.4d+22)) .and. (j <= 2.3d+57)) 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 <= -7.6e-17) {
tmp = t_0;
} else if (J <= -2e-310) {
tmp = U;
} else if ((J <= 9.2e-48) || (!(J <= 1.4e+22) && (J <= 2.3e+57))) {
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 <= -7.6e-17: tmp = t_0 elif J <= -2e-310: tmp = U elif (J <= 9.2e-48) or (not (J <= 1.4e+22) and (J <= 2.3e+57)): 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 <= -7.6e-17) tmp = t_0; elseif (J <= -2e-310) tmp = U; elseif ((J <= 9.2e-48) || (!(J <= 1.4e+22) && (J <= 2.3e+57))) 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 <= -7.6e-17) tmp = t_0; elseif (J <= -2e-310) tmp = U; elseif ((J <= 9.2e-48) || (~((J <= 1.4e+22)) && (J <= 2.3e+57))) 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, -7.6e-17], t$95$0, If[LessEqual[J, -2e-310], U, If[Or[LessEqual[J, 9.2e-48], And[N[Not[LessEqual[J, 1.4e+22]], $MachinePrecision], LessEqual[J, 2.3e+57]]], (-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 -7.6 \cdot 10^{-17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 9.2 \cdot 10^{-48} \lor \neg \left(J \leq 1.4 \cdot 10^{+22}\right) \land J \leq 2.3 \cdot 10^{+57}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -7.6000000000000002e-17 or 9.2000000000000003e-48 < J < 1.4e22 or 2.2999999999999999e57 < J Initial program 94.0%
Taylor expanded in J around inf 79.9%
associate-*r*79.9%
*-commutative79.9%
*-commutative79.9%
associate-*r*79.9%
*-commutative79.9%
Simplified79.9%
if -7.6000000000000002e-17 < J < -1.999999999999994e-310Initial program 43.2%
Taylor expanded in U around -inf 42.2%
if -1.999999999999994e-310 < J < 9.2000000000000003e-48 or 1.4e22 < J < 2.2999999999999999e57Initial program 49.5%
Taylor expanded in J around 0 44.8%
neg-mul-144.8%
Simplified44.8%
Final simplification61.9%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -1.05e+68) (* -2.0 J) (if (<= J -2e-310) U (if (<= J 1.36e+159) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.05e+68) {
tmp = -2.0 * J;
} else if (J <= -2e-310) {
tmp = U;
} else if (J <= 1.36e+159) {
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.05d+68)) then
tmp = (-2.0d0) * j
else if (j <= (-2d-310)) then
tmp = u
else if (j <= 1.36d+159) 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.05e+68) {
tmp = -2.0 * J;
} else if (J <= -2e-310) {
tmp = U;
} else if (J <= 1.36e+159) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.05e+68: tmp = -2.0 * J elif J <= -2e-310: tmp = U elif J <= 1.36e+159: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.05e+68) tmp = Float64(-2.0 * J); elseif (J <= -2e-310) tmp = U; elseif (J <= 1.36e+159) 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.05e+68) tmp = -2.0 * J; elseif (J <= -2e-310) tmp = U; elseif (J <= 1.36e+159) 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.05e+68], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -2e-310], U, If[LessEqual[J, 1.36e+159], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.05 \cdot 10^{+68}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.36 \cdot 10^{+159}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -1.05e68 or 1.36e159 < J Initial program 99.7%
Taylor expanded in J around inf 93.7%
associate-*r*93.7%
*-commutative93.7%
*-commutative93.7%
associate-*r*93.7%
*-commutative93.7%
Simplified93.7%
Taylor expanded in K around 0 51.7%
if -1.05e68 < J < -1.999999999999994e-310Initial program 52.4%
Taylor expanded in U around -inf 40.2%
if -1.999999999999994e-310 < J < 1.36e159Initial program 62.8%
Taylor expanded in J around 0 37.0%
neg-mul-137.0%
Simplified37.0%
Final simplification42.8%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2e-310) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2e-310: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2e-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 <= -2e-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, -2e-310], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -1.999999999999994e-310Initial program 67.4%
Taylor expanded in U around -inf 29.7%
if -1.999999999999994e-310 < J Initial program 73.8%
Taylor expanded in J around 0 27.5%
neg-mul-127.5%
Simplified27.5%
Final simplification28.7%
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 70.3%
Taylor expanded in U around -inf 28.1%
Final simplification28.1%
herbie shell --seed 2023299
(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)))))