
(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 5e+306)
(* (* 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 <= 5e+306) {
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 <= 5e+306) {
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 <= 5e+306: 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 <= 5e+306) 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 <= 5e+306) 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, 5e+306], 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 5 \cdot 10^{+306}:\\
\;\;\;\;\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 6.7%
*-commutative6.7%
associate-*l*6.7%
associate-*r*6.7%
*-commutative6.7%
associate-*l*6.7%
*-commutative6.7%
unpow26.7%
hypot-1-def60.9%
*-commutative60.9%
associate-*l*60.9%
Simplified60.9%
Taylor expanded in J around 0 52.7%
neg-mul-152.7%
Simplified52.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)))) < 4.99999999999999993e306Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if 4.99999999999999993e306 < (*.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.6%
*-commutative5.6%
associate-*l*5.6%
associate-*r*5.6%
*-commutative5.6%
associate-*l*5.6%
*-commutative5.6%
unpow25.6%
hypot-1-def49.5%
*-commutative49.5%
associate-*l*49.5%
Simplified49.5%
Taylor expanded in U around -inf 51.7%
Final simplification85.5%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U 1.65e+236)
(* 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 (U <= 1.65e+236) {
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 (U <= 1.65e+236) {
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 U <= 1.65e+236: 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 (U <= 1.65e+236) tmp = Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))); else tmp = Float64(-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 (U <= 1.65e+236) 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[LessEqual[U, 1.65e+236], 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}\;U \leq 1.65 \cdot 10^{+236}:\\
\;\;\;\;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 U < 1.6499999999999999e236Initial program 74.3%
*-commutative74.3%
associate-*l*74.3%
associate-*r*74.3%
*-commutative74.3%
associate-*l*74.2%
*-commutative74.2%
unpow274.2%
hypot-1-def88.9%
*-commutative88.9%
associate-*l*88.9%
Simplified88.9%
if 1.6499999999999999e236 < U Initial program 31.5%
*-commutative31.5%
associate-*l*31.5%
associate-*r*31.5%
*-commutative31.5%
associate-*l*31.4%
*-commutative31.4%
unpow231.4%
hypot-1-def48.6%
*-commutative48.6%
associate-*l*48.6%
Simplified48.6%
Taylor expanded in J around 0 68.8%
neg-mul-168.8%
Simplified68.8%
Final simplification87.7%
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 -5e-161)
t_0
(if (<= J 7.8e-284)
U
(if (<= J 1.85e-106) (- (* -2.0 (* J (/ J U))) 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 <= -5e-161) {
tmp = t_0;
} else if (J <= 7.8e-284) {
tmp = U;
} else if (J <= 1.85e-106) {
tmp = (-2.0 * (J * (J / U))) - 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 <= -5e-161) {
tmp = t_0;
} else if (J <= 7.8e-284) {
tmp = U;
} else if (J <= 1.85e-106) {
tmp = (-2.0 * (J * (J / U))) - 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 <= -5e-161: tmp = t_0 elif J <= 7.8e-284: tmp = U elif J <= 1.85e-106: tmp = (-2.0 * (J * (J / U))) - 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 <= -5e-161) tmp = t_0; elseif (J <= 7.8e-284) tmp = U; elseif (J <= 1.85e-106) tmp = Float64(Float64(-2.0 * Float64(J * Float64(J / U))) - 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 <= -5e-161) tmp = t_0; elseif (J <= 7.8e-284) tmp = U; elseif (J <= 1.85e-106) tmp = (-2.0 * (J * (J / U))) - 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, -5e-161], t$95$0, If[LessEqual[J, 7.8e-284], U, If[LessEqual[J, 1.85e-106], N[(N[(-2.0 * N[(J * N[(J / U), $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 \cdot 10^{-161}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 7.8 \cdot 10^{-284}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.85 \cdot 10^{-106}:\\
\;\;\;\;-2 \cdot \left(J \cdot \frac{J}{U}\right) - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -4.9999999999999999e-161 or 1.8499999999999999e-106 < J Initial program 85.8%
*-commutative85.8%
associate-*l*85.8%
unpow285.8%
hypot-1-def96.0%
*-commutative96.0%
associate-*l*96.0%
Simplified96.0%
Taylor expanded in K around 0 87.9%
if -4.9999999999999999e-161 < J < 7.7999999999999994e-284Initial program 23.5%
*-commutative23.5%
associate-*l*23.5%
associate-*r*23.5%
*-commutative23.5%
associate-*l*23.4%
*-commutative23.4%
unpow223.4%
hypot-1-def51.4%
*-commutative51.4%
associate-*l*51.4%
Simplified51.4%
Taylor expanded in U around -inf 46.2%
if 7.7999999999999994e-284 < J < 1.8499999999999999e-106Initial program 36.0%
*-commutative36.0%
associate-*l*36.0%
unpow236.0%
hypot-1-def64.4%
*-commutative64.4%
associate-*l*64.4%
Simplified64.4%
Taylor expanded in K around 0 35.9%
Taylor expanded in K around 0 44.6%
Taylor expanded in U around inf 28.2%
+-commutative28.2%
*-commutative28.2%
metadata-eval28.2%
times-frac28.2%
*-rgt-identity28.2%
associate-*r/28.2%
Simplified28.2%
Taylor expanded in J around 0 36.6%
mul-1-neg36.6%
unsub-neg36.6%
unpow236.6%
associate-*l/36.6%
*-commutative36.6%
Simplified36.6%
Final simplification76.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= (/ K 2.0) 500.0) (* (* -2.0 J) (hypot 1.0 (/ U (* J 2.0)))) (* (* J (* -2.0 (cos (/ K 2.0)))) (+ 1.0 (* (* (/ U J) (/ U J)) 0.125)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if ((K / 2.0) <= 500.0) {
tmp = (-2.0 * J) * hypot(1.0, (U / (J * 2.0)));
} else {
tmp = (J * (-2.0 * cos((K / 2.0)))) * (1.0 + (((U / J) * (U / J)) * 0.125));
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if ((K / 2.0) <= 500.0) {
tmp = (-2.0 * J) * Math.hypot(1.0, (U / (J * 2.0)));
} else {
tmp = (J * (-2.0 * Math.cos((K / 2.0)))) * (1.0 + (((U / J) * (U / J)) * 0.125));
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if (K / 2.0) <= 500.0: tmp = (-2.0 * J) * math.hypot(1.0, (U / (J * 2.0))) else: tmp = (J * (-2.0 * math.cos((K / 2.0)))) * (1.0 + (((U / J) * (U / J)) * 0.125)) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 500.0) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(U / Float64(J * 2.0)))); else tmp = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * Float64(1.0 + Float64(Float64(Float64(U / J) * Float64(U / J)) * 0.125))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if ((K / 2.0) <= 500.0) tmp = (-2.0 * J) * hypot(1.0, (U / (J * 2.0))); else tmp = (J * (-2.0 * cos((K / 2.0)))) * (1.0 + (((U / J) * (U / J)) * 0.125)); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 500.0], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(J * N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(N[(U / J), $MachinePrecision] * N[(U / J), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 500:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \left(1 + \left(\frac{U}{J} \cdot \frac{U}{J}\right) \cdot 0.125\right)\\
\end{array}
\end{array}
if (/.f64 K 2) < 500Initial program 68.4%
*-commutative68.4%
associate-*l*68.4%
unpow268.4%
hypot-1-def85.3%
*-commutative85.3%
associate-*l*85.3%
Simplified85.3%
Taylor expanded in K around 0 75.8%
Taylor expanded in K around 0 62.5%
if 500 < (/.f64 K 2) Initial program 84.0%
*-commutative84.0%
associate-*l*84.0%
unpow284.0%
hypot-1-def90.9%
*-commutative90.9%
associate-*l*90.9%
Simplified90.9%
Taylor expanded in K around 0 67.7%
Taylor expanded in U around 0 49.8%
*-commutative49.8%
unpow249.8%
unpow249.8%
times-frac64.3%
Simplified64.3%
Final simplification62.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 -1.35e-88)
t_0
(if (<= J 7.8e-284)
U
(if (<= J 4.6e-57)
(- (* -2.0 (* J (/ J U))) U)
(if (or (<= J 2.4e+28) (not (<= J 3.65e+68))) t_0 (- U)))))))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 <= -1.35e-88) {
tmp = t_0;
} else if (J <= 7.8e-284) {
tmp = U;
} else if (J <= 4.6e-57) {
tmp = (-2.0 * (J * (J / U))) - U;
} else if ((J <= 2.4e+28) || !(J <= 3.65e+68)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-1.35d-88)) then
tmp = t_0
else if (j <= 7.8d-284) then
tmp = u
else if (j <= 4.6d-57) then
tmp = ((-2.0d0) * (j * (j / u))) - u
else if ((j <= 2.4d+28) .or. (.not. (j <= 3.65d+68))) then
tmp = t_0
else
tmp = -u
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 <= -1.35e-88) {
tmp = t_0;
} else if (J <= 7.8e-284) {
tmp = U;
} else if (J <= 4.6e-57) {
tmp = (-2.0 * (J * (J / U))) - U;
} else if ((J <= 2.4e+28) || !(J <= 3.65e+68)) {
tmp = t_0;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -1.35e-88: tmp = t_0 elif J <= 7.8e-284: tmp = U elif J <= 4.6e-57: tmp = (-2.0 * (J * (J / U))) - U elif (J <= 2.4e+28) or not (J <= 3.65e+68): tmp = t_0 else: tmp = -U 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 <= -1.35e-88) tmp = t_0; elseif (J <= 7.8e-284) tmp = U; elseif (J <= 4.6e-57) tmp = Float64(Float64(-2.0 * Float64(J * Float64(J / U))) - U); elseif ((J <= 2.4e+28) || !(J <= 3.65e+68)) tmp = t_0; else tmp = Float64(-U); 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 <= -1.35e-88) tmp = t_0; elseif (J <= 7.8e-284) tmp = U; elseif (J <= 4.6e-57) tmp = (-2.0 * (J * (J / U))) - U; elseif ((J <= 2.4e+28) || ~((J <= 3.65e+68))) tmp = 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[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.35e-88], t$95$0, If[LessEqual[J, 7.8e-284], U, If[LessEqual[J, 4.6e-57], N[(N[(-2.0 * N[(J * N[(J / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[Or[LessEqual[J, 2.4e+28], N[Not[LessEqual[J, 3.65e+68]], $MachinePrecision]], t$95$0, (-U)]]]]]
\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 -1.35 \cdot 10^{-88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 7.8 \cdot 10^{-284}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 4.6 \cdot 10^{-57}:\\
\;\;\;\;-2 \cdot \left(J \cdot \frac{J}{U}\right) - U\\
\mathbf{elif}\;J \leq 2.4 \cdot 10^{+28} \lor \neg \left(J \leq 3.65 \cdot 10^{+68}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -1.34999999999999997e-88 or 4.6e-57 < J < 2.39999999999999981e28 or 3.65000000000000017e68 < J Initial program 91.1%
*-commutative91.1%
associate-*l*91.1%
associate-*r*91.1%
*-commutative91.1%
associate-*l*91.1%
*-commutative91.1%
unpow291.1%
hypot-1-def97.5%
*-commutative97.5%
associate-*l*97.5%
Simplified97.5%
Taylor expanded in U around 0 78.9%
if -1.34999999999999997e-88 < J < 7.7999999999999994e-284Initial program 31.8%
*-commutative31.8%
associate-*l*31.8%
associate-*r*31.8%
*-commutative31.8%
associate-*l*31.7%
*-commutative31.7%
unpow231.7%
hypot-1-def56.4%
*-commutative56.4%
associate-*l*56.4%
Simplified56.4%
Taylor expanded in U around -inf 38.8%
if 7.7999999999999994e-284 < J < 4.6e-57Initial program 44.1%
*-commutative44.1%
associate-*l*44.1%
unpow244.1%
hypot-1-def72.5%
*-commutative72.5%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in K around 0 48.6%
Taylor expanded in K around 0 54.9%
Taylor expanded in U around inf 26.6%
+-commutative26.6%
*-commutative26.6%
metadata-eval26.6%
times-frac26.6%
*-rgt-identity26.6%
associate-*r/26.6%
Simplified26.6%
Taylor expanded in J around 0 33.1%
mul-1-neg33.1%
unsub-neg33.1%
unpow233.1%
associate-*l/33.1%
*-commutative33.1%
Simplified33.1%
if 2.39999999999999981e28 < J < 3.65000000000000017e68Initial program 53.7%
*-commutative53.7%
associate-*l*53.7%
associate-*r*53.7%
*-commutative53.7%
associate-*l*53.7%
*-commutative53.7%
unpow253.7%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in J around 0 30.5%
neg-mul-130.5%
Simplified30.5%
Final simplification62.4%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= K 650.0) (* (* -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 <= 650.0) {
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 <= 650.0) {
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 <= 650.0: 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 <= 650.0) 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 <= 650.0) 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, 650.0], 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 650:\\
\;\;\;\;\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 < 650Initial program 68.4%
*-commutative68.4%
associate-*l*68.4%
unpow268.4%
hypot-1-def85.3%
*-commutative85.3%
associate-*l*85.3%
Simplified85.3%
Taylor expanded in K around 0 75.8%
Taylor expanded in K around 0 62.5%
if 650 < K Initial program 84.0%
*-commutative84.0%
associate-*l*84.0%
associate-*r*84.0%
*-commutative84.0%
associate-*l*83.8%
*-commutative83.8%
unpow283.8%
hypot-1-def90.9%
*-commutative90.9%
associate-*l*90.9%
Simplified90.9%
Taylor expanded in U around 0 63.2%
Final simplification62.7%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -1.62e-43) (* -2.0 J) (if (<= J 7.8e-284) U (if (<= J 4.6e+126) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.62e-43) {
tmp = -2.0 * J;
} else if (J <= 7.8e-284) {
tmp = U;
} else if (J <= 4.6e+126) {
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.62d-43)) then
tmp = (-2.0d0) * j
else if (j <= 7.8d-284) then
tmp = u
else if (j <= 4.6d+126) 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.62e-43) {
tmp = -2.0 * J;
} else if (J <= 7.8e-284) {
tmp = U;
} else if (J <= 4.6e+126) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.62e-43: tmp = -2.0 * J elif J <= 7.8e-284: tmp = U elif J <= 4.6e+126: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.62e-43) tmp = Float64(-2.0 * J); elseif (J <= 7.8e-284) tmp = U; elseif (J <= 4.6e+126) 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.62e-43) tmp = -2.0 * J; elseif (J <= 7.8e-284) tmp = U; elseif (J <= 4.6e+126) 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.62e-43], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, 7.8e-284], U, If[LessEqual[J, 4.6e+126], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.62 \cdot 10^{-43}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq 7.8 \cdot 10^{-284}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 4.6 \cdot 10^{+126}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -1.6199999999999999e-43 or 4.6000000000000001e126 < J Initial program 98.2%
*-commutative98.2%
associate-*l*98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*l*98.1%
*-commutative98.1%
unpow298.1%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 86.5%
Taylor expanded in K around 0 50.9%
if -1.6199999999999999e-43 < J < 7.7999999999999994e-284Initial program 39.4%
*-commutative39.4%
associate-*l*39.4%
associate-*r*39.4%
*-commutative39.4%
associate-*l*39.3%
*-commutative39.3%
unpow239.3%
hypot-1-def61.7%
*-commutative61.7%
associate-*l*61.7%
Simplified61.7%
Taylor expanded in U around -inf 33.9%
if 7.7999999999999994e-284 < J < 4.6000000000000001e126Initial program 57.8%
*-commutative57.8%
associate-*l*57.8%
associate-*r*57.8%
*-commutative57.8%
associate-*l*57.8%
*-commutative57.8%
unpow257.8%
hypot-1-def84.9%
*-commutative84.9%
associate-*l*84.9%
Simplified84.9%
Taylor expanded in J around 0 26.9%
neg-mul-126.9%
Simplified26.9%
Final simplification39.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J 7.8e-284) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= 7.8e-284) {
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 <= 7.8d-284) 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 <= 7.8e-284) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= 7.8e-284: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= 7.8e-284) 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 <= 7.8e-284) 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, 7.8e-284], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq 7.8 \cdot 10^{-284}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < 7.7999999999999994e-284Initial program 71.0%
*-commutative71.0%
associate-*l*71.0%
associate-*r*71.0%
*-commutative71.0%
associate-*l*71.0%
*-commutative71.0%
unpow271.0%
hypot-1-def82.6%
*-commutative82.6%
associate-*l*82.6%
Simplified82.6%
Taylor expanded in U around -inf 20.7%
if 7.7999999999999994e-284 < J Initial program 72.2%
*-commutative72.2%
associate-*l*72.2%
associate-*r*72.2%
*-commutative72.2%
associate-*l*72.1%
*-commutative72.1%
unpow272.1%
hypot-1-def90.0%
*-commutative90.0%
associate-*l*90.0%
Simplified90.0%
Taylor expanded in J around 0 19.3%
neg-mul-119.3%
Simplified19.3%
Final simplification20.0%
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 71.6%
*-commutative71.6%
associate-*l*71.6%
associate-*r*71.6%
*-commutative71.6%
associate-*l*71.6%
*-commutative71.6%
unpow271.6%
hypot-1-def86.4%
*-commutative86.4%
associate-*l*86.4%
Simplified86.4%
Taylor expanded in U around -inf 25.9%
Final simplification25.9%
herbie shell --seed 2023242
(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)))))