
(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))
(- U)
(if (<= t_1 2e+299)
(* (* 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 <= 2e+299) {
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 <= 2e+299) {
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 <= 2e+299: 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 <= 2e+299) 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 <= 2e+299) 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, 2e+299], 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 2 \cdot 10^{+299}:\\
\;\;\;\;\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.7%
*-commutative5.7%
associate-*l*5.7%
associate-*r*5.7%
*-commutative5.7%
associate-*l*5.7%
*-commutative5.7%
unpow25.7%
hypot-1-def64.8%
*-commutative64.8%
associate-*l*64.8%
Simplified64.8%
Taylor expanded in J around 0 48.9%
neg-mul-148.9%
Simplified48.9%
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)))) < 2.0000000000000001e299Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if 2.0000000000000001e299 < (*.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 9.8%
*-commutative9.8%
associate-*l*9.8%
associate-*r*9.8%
*-commutative9.8%
associate-*l*9.8%
*-commutative9.8%
unpow29.8%
hypot-1-def55.4%
*-commutative55.4%
associate-*l*55.4%
Simplified55.4%
Taylor expanded in U around -inf 57.4%
Final simplification87.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* J (* t_0 (* -2.0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return J * (t_0 * (-2.0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) return J * (t_0 * (-2.0 * math.hypot(1.0, (U / (J * (2.0 * t_0))))))
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(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]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\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)
\end{array}
\end{array}
Initial program 74.6%
*-commutative74.6%
associate-*l*74.6%
associate-*r*74.6%
*-commutative74.6%
associate-*l*74.6%
*-commutative74.6%
unpow274.6%
hypot-1-def88.9%
*-commutative88.9%
associate-*l*88.9%
Simplified88.9%
Final simplification88.9%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 1.35e+224) (* J (* (cos (/ K 2.0)) (* -2.0 (hypot 1.0 (/ U (* J 2.0)))))) (if (<= U 2e+270) (- U) U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 1.35e+224) {
tmp = J * (cos((K / 2.0)) * (-2.0 * hypot(1.0, (U / (J * 2.0)))));
} else if (U <= 2e+270) {
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 <= 1.35e+224) {
tmp = J * (Math.cos((K / 2.0)) * (-2.0 * Math.hypot(1.0, (U / (J * 2.0)))));
} else if (U <= 2e+270) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 1.35e+224: tmp = J * (math.cos((K / 2.0)) * (-2.0 * math.hypot(1.0, (U / (J * 2.0))))) elif U <= 2e+270: tmp = -U else: tmp = U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 1.35e+224) tmp = Float64(J * Float64(cos(Float64(K / 2.0)) * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * 2.0)))))); elseif (U <= 2e+270) 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 <= 1.35e+224) tmp = J * (cos((K / 2.0)) * (-2.0 * hypot(1.0, (U / (J * 2.0))))); elseif (U <= 2e+270) 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, 1.35e+224], N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 2e+270], (-U), U]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 1.35 \cdot 10^{+224}:\\
\;\;\;\;J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\right)\right)\\
\mathbf{elif}\;U \leq 2 \cdot 10^{+270}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if U < 1.3499999999999999e224Initial program 79.4%
*-commutative79.4%
associate-*l*79.4%
associate-*r*79.4%
*-commutative79.4%
associate-*l*79.3%
*-commutative79.3%
unpow279.3%
hypot-1-def92.5%
*-commutative92.5%
associate-*l*92.5%
Simplified92.5%
Taylor expanded in K around 0 74.9%
if 1.3499999999999999e224 < U < 2.0000000000000001e270Initial program 28.5%
*-commutative28.5%
associate-*l*28.5%
associate-*r*28.5%
*-commutative28.5%
associate-*l*28.6%
*-commutative28.6%
unpow228.6%
hypot-1-def56.8%
*-commutative56.8%
associate-*l*56.8%
Simplified56.8%
Taylor expanded in J around 0 61.6%
neg-mul-161.6%
Simplified61.6%
if 2.0000000000000001e270 < U Initial program 32.4%
*-commutative32.4%
associate-*l*32.4%
associate-*r*32.4%
*-commutative32.4%
associate-*l*32.5%
*-commutative32.5%
unpow232.5%
hypot-1-def54.9%
*-commutative54.9%
associate-*l*54.9%
Simplified54.9%
Taylor expanded in U around -inf 83.3%
Final simplification74.6%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (hypot 1.0 (* 0.5 (/ U J))))))
(t_1 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= U 2.4e-112)
t_1
(if (<= U 3.15e-87)
t_0
(if (<= U 9.5e-25)
t_1
(if (<= U 9.5e+222) t_0 (if (<= U 1.9e+270) (- U) U)))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * hypot(1.0, (0.5 * (U / J))));
double t_1 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (U <= 2.4e-112) {
tmp = t_1;
} else if (U <= 3.15e-87) {
tmp = t_0;
} else if (U <= 9.5e-25) {
tmp = t_1;
} else if (U <= 9.5e+222) {
tmp = t_0;
} else if (U <= 1.9e+270) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = J * (-2.0 * Math.hypot(1.0, (0.5 * (U / J))));
double t_1 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (U <= 2.4e-112) {
tmp = t_1;
} else if (U <= 3.15e-87) {
tmp = t_0;
} else if (U <= 9.5e-25) {
tmp = t_1;
} else if (U <= 9.5e+222) {
tmp = t_0;
} else if (U <= 1.9e+270) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.hypot(1.0, (0.5 * (U / J)))) t_1 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if U <= 2.4e-112: tmp = t_1 elif U <= 3.15e-87: tmp = t_0 elif U <= 9.5e-25: tmp = t_1 elif U <= 9.5e+222: tmp = t_0 elif U <= 1.9e+270: tmp = -U else: tmp = U return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * hypot(1.0, Float64(0.5 * Float64(U / J))))) t_1 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (U <= 2.4e-112) tmp = t_1; elseif (U <= 3.15e-87) tmp = t_0; elseif (U <= 9.5e-25) tmp = t_1; elseif (U <= 9.5e+222) tmp = t_0; elseif (U <= 1.9e+270) tmp = Float64(-U); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * hypot(1.0, (0.5 * (U / J)))); t_1 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (U <= 2.4e-112) tmp = t_1; elseif (U <= 3.15e-87) tmp = t_0; elseif (U <= 9.5e-25) tmp = t_1; elseif (U <= 9.5e+222) tmp = t_0; elseif (U <= 1.9e+270) tmp = -U; 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[(J * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U, 2.4e-112], t$95$1, If[LessEqual[U, 3.15e-87], t$95$0, If[LessEqual[U, 9.5e-25], t$95$1, If[LessEqual[U, 9.5e+222], t$95$0, If[LessEqual[U, 1.9e+270], (-U), U]]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\right)\\
t_1 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;U \leq 2.4 \cdot 10^{-112}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;U \leq 3.15 \cdot 10^{-87}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;U \leq 9.5 \cdot 10^{-25}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;U \leq 9.5 \cdot 10^{+222}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;U \leq 1.9 \cdot 10^{+270}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if U < 2.4000000000000001e-112 or 3.14999999999999988e-87 < U < 9.50000000000000065e-25Initial program 83.1%
*-commutative83.1%
associate-*l*83.1%
associate-*r*83.1%
*-commutative83.1%
associate-*l*83.0%
*-commutative83.0%
unpow283.0%
hypot-1-def94.2%
*-commutative94.2%
associate-*l*94.2%
Simplified94.2%
Taylor expanded in U around 0 60.9%
if 2.4000000000000001e-112 < U < 3.14999999999999988e-87 or 9.50000000000000065e-25 < U < 9.5000000000000001e222Initial program 64.6%
*-commutative64.6%
associate-*l*64.6%
associate-*r*64.6%
*-commutative64.6%
associate-*l*64.6%
*-commutative64.6%
unpow264.6%
hypot-1-def85.4%
*-commutative85.4%
associate-*l*85.4%
Simplified85.4%
Taylor expanded in K around 0 37.4%
associate-*r*37.4%
*-commutative37.4%
unpow237.4%
associate-/r*38.5%
metadata-eval38.5%
unpow238.5%
associate-*l/50.7%
associate-*r/50.7%
swap-sqr50.7%
hypot-1-def61.1%
Simplified61.1%
if 9.5000000000000001e222 < U < 1.90000000000000009e270Initial program 28.5%
*-commutative28.5%
associate-*l*28.5%
associate-*r*28.5%
*-commutative28.5%
associate-*l*28.6%
*-commutative28.6%
unpow228.6%
hypot-1-def56.8%
*-commutative56.8%
associate-*l*56.8%
Simplified56.8%
Taylor expanded in J around 0 61.6%
neg-mul-161.6%
Simplified61.6%
if 1.90000000000000009e270 < U Initial program 32.4%
*-commutative32.4%
associate-*l*32.4%
associate-*r*32.4%
*-commutative32.4%
associate-*l*32.5%
*-commutative32.5%
unpow232.5%
hypot-1-def54.9%
*-commutative54.9%
associate-*l*54.9%
Simplified54.9%
Taylor expanded in U around -inf 83.3%
Final simplification62.0%
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 -6.8e+34)
t_0
(if (<= J -2.1e-299) U (if (<= J 4.6e-52) (- 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 <= -6.8e+34) {
tmp = t_0;
} else if (J <= -2.1e-299) {
tmp = U;
} else if (J <= 4.6e-52) {
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 <= (-6.8d+34)) then
tmp = t_0
else if (j <= (-2.1d-299)) then
tmp = u
else if (j <= 4.6d-52) 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 <= -6.8e+34) {
tmp = t_0;
} else if (J <= -2.1e-299) {
tmp = U;
} else if (J <= 4.6e-52) {
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 <= -6.8e+34: tmp = t_0 elif J <= -2.1e-299: tmp = U elif J <= 4.6e-52: 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 <= -6.8e+34) tmp = t_0; elseif (J <= -2.1e-299) tmp = U; elseif (J <= 4.6e-52) 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 <= -6.8e+34) tmp = t_0; elseif (J <= -2.1e-299) tmp = U; elseif (J <= 4.6e-52) 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, -6.8e+34], t$95$0, If[LessEqual[J, -2.1e-299], U, If[LessEqual[J, 4.6e-52], (-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 -6.8 \cdot 10^{+34}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -2.1 \cdot 10^{-299}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 4.6 \cdot 10^{-52}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -6.7999999999999999e34 or 4.59999999999999989e-52 < J Initial program 92.0%
*-commutative92.0%
associate-*l*92.0%
associate-*r*92.0%
*-commutative92.0%
associate-*l*92.0%
*-commutative92.0%
unpow292.0%
hypot-1-def99.1%
*-commutative99.1%
associate-*l*99.1%
Simplified99.1%
Taylor expanded in U around 0 77.3%
if -6.7999999999999999e34 < J < -2.1000000000000001e-299Initial program 55.9%
*-commutative55.9%
associate-*l*55.9%
associate-*r*55.9%
*-commutative55.9%
associate-*l*55.8%
*-commutative55.8%
unpow255.8%
hypot-1-def83.9%
*-commutative83.9%
associate-*l*83.9%
Simplified83.9%
Taylor expanded in U around -inf 43.7%
if -2.1000000000000001e-299 < J < 4.59999999999999989e-52Initial program 58.9%
*-commutative58.9%
associate-*l*58.9%
associate-*r*58.9%
*-commutative58.9%
associate-*l*58.8%
*-commutative58.8%
unpow258.8%
hypot-1-def72.2%
*-commutative72.2%
associate-*l*72.2%
Simplified72.2%
Taylor expanded in J around 0 37.2%
neg-mul-137.2%
Simplified37.2%
Final simplification59.0%
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 -4.6e+34)
t_0
(if (<= J -2.6e-303)
(fma 2.0 (* J (/ J U)) U)
(if (<= J 2.15e-54) (- 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 <= -4.6e+34) {
tmp = t_0;
} else if (J <= -2.6e-303) {
tmp = fma(2.0, (J * (J / U)), U);
} else if (J <= 2.15e-54) {
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 <= -4.6e+34) tmp = t_0; elseif (J <= -2.6e-303) tmp = fma(2.0, Float64(J * Float64(J / U)), U); elseif (J <= 2.15e-54) tmp = Float64(-U); else tmp = t_0; end return 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, -4.6e+34], t$95$0, If[LessEqual[J, -2.6e-303], N[(2.0 * N[(J * N[(J / U), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[J, 2.15e-54], (-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 -4.6 \cdot 10^{+34}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -2.6 \cdot 10^{-303}:\\
\;\;\;\;\mathsf{fma}\left(2, J \cdot \frac{J}{U}, U\right)\\
\mathbf{elif}\;J \leq 2.15 \cdot 10^{-54}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -4.5999999999999996e34 or 2.15e-54 < J Initial program 92.0%
*-commutative92.0%
associate-*l*92.0%
associate-*r*92.0%
*-commutative92.0%
associate-*l*92.0%
*-commutative92.0%
unpow292.0%
hypot-1-def99.1%
*-commutative99.1%
associate-*l*99.1%
Simplified99.1%
Taylor expanded in U around 0 77.3%
if -4.5999999999999996e34 < J < -2.60000000000000005e-303Initial program 55.9%
*-commutative55.9%
associate-*l*55.9%
associate-*r*55.9%
*-commutative55.9%
associate-*l*55.8%
*-commutative55.8%
unpow255.8%
hypot-1-def83.9%
*-commutative83.9%
associate-*l*83.9%
Simplified83.9%
Taylor expanded in U around -inf 43.6%
fma-def43.6%
associate-/l*43.6%
unpow243.6%
Simplified43.6%
Taylor expanded in K around 0 43.6%
unpow243.6%
associate-*l/43.6%
Simplified43.6%
if -2.60000000000000005e-303 < J < 2.15e-54Initial program 58.9%
*-commutative58.9%
associate-*l*58.9%
associate-*r*58.9%
*-commutative58.9%
associate-*l*58.8%
*-commutative58.8%
unpow258.8%
hypot-1-def72.2%
*-commutative72.2%
associate-*l*72.2%
Simplified72.2%
Taylor expanded in J around 0 37.2%
neg-mul-137.2%
Simplified37.2%
Final simplification59.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -7.5e+34) (* -2.0 J) (if (<= J -2.3e-303) U (if (<= J 1.76e+50) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -7.5e+34) {
tmp = -2.0 * J;
} else if (J <= -2.3e-303) {
tmp = U;
} else if (J <= 1.76e+50) {
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 <= (-7.5d+34)) then
tmp = (-2.0d0) * j
else if (j <= (-2.3d-303)) then
tmp = u
else if (j <= 1.76d+50) 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 <= -7.5e+34) {
tmp = -2.0 * J;
} else if (J <= -2.3e-303) {
tmp = U;
} else if (J <= 1.76e+50) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -7.5e+34: tmp = -2.0 * J elif J <= -2.3e-303: tmp = U elif J <= 1.76e+50: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -7.5e+34) tmp = Float64(-2.0 * J); elseif (J <= -2.3e-303) tmp = U; elseif (J <= 1.76e+50) 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 <= -7.5e+34) tmp = -2.0 * J; elseif (J <= -2.3e-303) tmp = U; elseif (J <= 1.76e+50) 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, -7.5e+34], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -2.3e-303], U, If[LessEqual[J, 1.76e+50], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -7.5 \cdot 10^{+34}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -2.3 \cdot 10^{-303}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.76 \cdot 10^{+50}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -7.49999999999999976e34 or 1.7600000000000001e50 < J Initial program 95.6%
*-commutative95.6%
associate-*l*95.6%
associate-*r*95.6%
*-commutative95.6%
associate-*l*95.6%
*-commutative95.6%
unpow295.6%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 81.4%
Taylor expanded in K around 0 49.1%
if -7.49999999999999976e34 < J < -2.29999999999999995e-303Initial program 55.9%
*-commutative55.9%
associate-*l*55.9%
associate-*r*55.9%
*-commutative55.9%
associate-*l*55.8%
*-commutative55.8%
unpow255.8%
hypot-1-def83.9%
*-commutative83.9%
associate-*l*83.9%
Simplified83.9%
Taylor expanded in U around -inf 43.7%
if -2.29999999999999995e-303 < J < 1.7600000000000001e50Initial program 61.6%
*-commutative61.6%
associate-*l*61.6%
associate-*r*61.6%
*-commutative61.6%
associate-*l*61.5%
*-commutative61.5%
unpow261.5%
hypot-1-def77.7%
*-commutative77.7%
associate-*l*77.7%
Simplified77.7%
Taylor expanded in J around 0 35.4%
neg-mul-135.4%
Simplified35.4%
Final simplification43.6%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2.3e-303) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2.3e-303) {
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.3d-303)) 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.3e-303) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2.3e-303: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2.3e-303) 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.3e-303) 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.3e-303], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.3 \cdot 10^{-303}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -2.29999999999999995e-303Initial program 73.5%
*-commutative73.5%
associate-*l*73.5%
associate-*r*73.5%
*-commutative73.5%
associate-*l*73.4%
*-commutative73.4%
unpow273.4%
hypot-1-def91.0%
*-commutative91.0%
associate-*l*91.0%
Simplified91.0%
Taylor expanded in U around -inf 30.0%
if -2.29999999999999995e-303 < J Initial program 75.8%
*-commutative75.8%
associate-*l*75.8%
associate-*r*75.8%
*-commutative75.8%
associate-*l*75.8%
*-commutative75.8%
unpow275.8%
hypot-1-def86.7%
*-commutative86.7%
associate-*l*86.7%
Simplified86.7%
Taylor expanded in J around 0 25.0%
neg-mul-125.0%
Simplified25.0%
Final simplification27.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 74.6%
*-commutative74.6%
associate-*l*74.6%
associate-*r*74.6%
*-commutative74.6%
associate-*l*74.6%
*-commutative74.6%
unpow274.6%
hypot-1-def88.9%
*-commutative88.9%
associate-*l*88.9%
Simplified88.9%
Taylor expanded in U around -inf 29.7%
Final simplification29.7%
herbie shell --seed 2023244
(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)))))