
(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
(*
(* 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+308) t_1 (* -2.0 (- (* U -0.5) (/ (* J J) 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+308) {
tmp = t_1;
} else {
tmp = -2.0 * ((U * -0.5) - ((J * J) / 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+308) {
tmp = t_1;
} else {
tmp = -2.0 * ((U * -0.5) - ((J * J) / 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+308: tmp = t_1 else: tmp = -2.0 * ((U * -0.5) - ((J * J) / 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+308) tmp = t_1; else tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(Float64(J * J) / 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+308) tmp = t_1; else tmp = -2.0 * ((U * -0.5) - ((J * J) / 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+308], t$95$1, N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(N[(J * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\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^{+308}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\
\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 4.8%
Taylor expanded in J around 0 40.6%
neg-mul-140.6%
Simplified40.6%
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)))) < 1e308Initial program 99.9%
if 1e308 < (*.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 10.8%
Taylor expanded in K around 0 7.2%
*-commutative7.2%
*-commutative7.2%
unpow27.2%
unpow27.2%
Simplified7.2%
Taylor expanded in U around -inf 54.1%
+-commutative54.1%
mul-1-neg54.1%
unsub-neg54.1%
*-commutative54.1%
unpow254.1%
Simplified54.1%
Final simplification87.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* -2.0 (* J (* t_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 -2.0 * (J * (t_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 -2.0 * (J * (t_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 -2.0 * (J * (t_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(-2.0 * Float64(J * Float64(t_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 = -2.0 * (J * (t_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[(-2.0 * N[(J * N[(t$95$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)\\
-2 \cdot \left(J \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)
\end{array}
\end{array}
Initial program 77.0%
Simplified89.5%
Final simplification89.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (* J (cos (/ K 2.0))))) (* -2.0 (* t_0 (hypot 1.0 (/ U (* 2.0 t_0)))))))
U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * cos((K / 2.0));
return -2.0 * (t_0 * hypot(1.0, (U / (2.0 * t_0))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = J * Math.cos((K / 2.0));
return -2.0 * (t_0 * Math.hypot(1.0, (U / (2.0 * t_0))));
}
U = abs(U) def code(J, K, U): t_0 = J * math.cos((K / 2.0)) return -2.0 * (t_0 * math.hypot(1.0, (U / (2.0 * t_0))))
U = abs(U) function code(J, K, U) t_0 = Float64(J * cos(Float64(K / 2.0))) return Float64(-2.0 * Float64(t_0 * hypot(1.0, Float64(U / Float64(2.0 * t_0))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = J * cos((K / 2.0)); tmp = -2.0 * (t_0 * hypot(1.0, (U / (2.0 * t_0)))); end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(-2.0 * N[(t$95$0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{U}{2 \cdot t_0}\right)\right)
\end{array}
\end{array}
Initial program 77.0%
associate-*l*77.0%
associate-*l*77.0%
unpow277.0%
sqr-neg77.0%
distribute-frac-neg77.0%
distribute-frac-neg77.0%
unpow277.0%
Simplified89.6%
Final simplification89.6%
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 (* J 2.0))))))))
(if (<= J -2.8e-166)
t_0
(if (<= J -6.5e-306)
U
(if (<= J 1.75e-114)
(- (* -2.0 (/ (pow (* J (cos (* K 0.5))) 2.0) U)) 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 / (J * 2.0)))));
double tmp;
if (J <= -2.8e-166) {
tmp = t_0;
} else if (J <= -6.5e-306) {
tmp = U;
} else if (J <= 1.75e-114) {
tmp = (-2.0 * (pow((J * cos((K * 0.5))), 2.0) / 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 = -2.0 * (J * (Math.cos((K / 2.0)) * Math.hypot(1.0, (U / (J * 2.0)))));
double tmp;
if (J <= -2.8e-166) {
tmp = t_0;
} else if (J <= -6.5e-306) {
tmp = U;
} else if (J <= 1.75e-114) {
tmp = (-2.0 * (Math.pow((J * Math.cos((K * 0.5))), 2.0) / U)) - 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 / (J * 2.0))))) tmp = 0 if J <= -2.8e-166: tmp = t_0 elif J <= -6.5e-306: tmp = U elif J <= 1.75e-114: tmp = (-2.0 * (math.pow((J * math.cos((K * 0.5))), 2.0) / U)) - 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 / 2.0)) * hypot(1.0, Float64(U / Float64(J * 2.0)))))) tmp = 0.0 if (J <= -2.8e-166) tmp = t_0; elseif (J <= -6.5e-306) tmp = U; elseif (J <= 1.75e-114) tmp = Float64(Float64(-2.0 * Float64((Float64(J * cos(Float64(K * 0.5))) ^ 2.0) / U)) - 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 / (J * 2.0))))); tmp = 0.0; if (J <= -2.8e-166) tmp = t_0; elseif (J <= -6.5e-306) tmp = U; elseif (J <= 1.75e-114) tmp = (-2.0 * (((J * cos((K * 0.5))) ^ 2.0) / 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[(-2.0 * N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -2.8e-166], t$95$0, If[LessEqual[J, -6.5e-306], U, If[LessEqual[J, 1.75e-114], N[(N[(-2.0 * N[(N[Power[N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\right)\right)\\
\mathbf{if}\;J \leq -2.8 \cdot 10^{-166}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -6.5 \cdot 10^{-306}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.75 \cdot 10^{-114}:\\
\;\;\;\;-2 \cdot \frac{{\left(J \cdot \cos \left(K \cdot 0.5\right)\right)}^{2}}{U} - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -2.7999999999999999e-166 or 1.75e-114 < J Initial program 88.5%
Simplified96.9%
Taylor expanded in K around 0 82.8%
if -2.7999999999999999e-166 < J < -6.5000000000000004e-306Initial program 50.7%
Taylor expanded in U around -inf 57.0%
if -6.5000000000000004e-306 < J < 1.75e-114Initial program 40.3%
Taylor expanded in J around 0 32.0%
neg-mul-132.0%
unsub-neg32.0%
*-commutative32.0%
*-commutative32.0%
unpow232.0%
*-commutative32.0%
unpow232.0%
swap-sqr32.0%
unpow232.0%
*-commutative32.0%
Simplified32.0%
Final simplification72.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 3.35e-134) (* (cos (* K 0.5)) (* -2.0 J)) (if (<= U 1.02e+185) (* -2.0 (* J (hypot 1.0 (* 0.5 (/ U J))))) U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 3.35e-134) {
tmp = cos((K * 0.5)) * (-2.0 * J);
} else if (U <= 1.02e+185) {
tmp = -2.0 * (J * hypot(1.0, (0.5 * (U / J))));
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 3.35e-134) {
tmp = Math.cos((K * 0.5)) * (-2.0 * J);
} else if (U <= 1.02e+185) {
tmp = -2.0 * (J * Math.hypot(1.0, (0.5 * (U / J))));
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 3.35e-134: tmp = math.cos((K * 0.5)) * (-2.0 * J) elif U <= 1.02e+185: tmp = -2.0 * (J * math.hypot(1.0, (0.5 * (U / J)))) else: tmp = U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 3.35e-134) tmp = Float64(cos(Float64(K * 0.5)) * Float64(-2.0 * J)); elseif (U <= 1.02e+185) tmp = Float64(-2.0 * Float64(J * hypot(1.0, Float64(0.5 * Float64(U / J))))); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 3.35e-134) tmp = cos((K * 0.5)) * (-2.0 * J); elseif (U <= 1.02e+185) tmp = -2.0 * (J * hypot(1.0, (0.5 * (U / J)))); else tmp = U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 3.35e-134], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 1.02e+185], N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], U]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 3.35 \cdot 10^{-134}:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(-2 \cdot J\right)\\
\mathbf{elif}\;U \leq 1.02 \cdot 10^{+185}:\\
\;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if U < 3.34999999999999998e-134Initial program 80.9%
Taylor expanded in J around inf 61.4%
associate-*r*61.4%
*-commutative61.4%
*-commutative61.4%
associate-*r*61.4%
*-commutative61.4%
Simplified61.4%
if 3.34999999999999998e-134 < U < 1.0200000000000001e185Initial program 78.2%
Taylor expanded in K around 0 42.1%
*-commutative42.1%
*-commutative42.1%
unpow242.1%
unpow242.1%
Simplified42.1%
expm1-log1p-u41.3%
expm1-udef41.3%
add-sqr-sqrt41.3%
hypot-1-def41.3%
sqrt-prod41.3%
metadata-eval41.3%
times-frac54.8%
sqrt-prod39.2%
add-sqr-sqrt65.8%
Applied egg-rr65.8%
expm1-def65.8%
expm1-log1p68.2%
Simplified68.2%
if 1.0200000000000001e185 < U Initial program 43.2%
Taylor expanded in U around -inf 63.1%
Final simplification63.4%
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 -9.6e-98)
t_0
(if (<= J -5.5e-306) U (if (<= J 1.05e-82) (- U) t_0)))))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 <= -9.6e-98) {
tmp = t_0;
} else if (J <= -5.5e-306) {
tmp = U;
} else if (J <= 1.05e-82) {
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 = cos((k * 0.5d0)) * ((-2.0d0) * j)
if (j <= (-9.6d-98)) then
tmp = t_0
else if (j <= (-5.5d-306)) then
tmp = u
else if (j <= 1.05d-82) 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 = Math.cos((K * 0.5)) * (-2.0 * J);
double tmp;
if (J <= -9.6e-98) {
tmp = t_0;
} else if (J <= -5.5e-306) {
tmp = U;
} else if (J <= 1.05e-82) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K * 0.5)) * (-2.0 * J) tmp = 0 if J <= -9.6e-98: tmp = t_0 elif J <= -5.5e-306: tmp = U elif J <= 1.05e-82: tmp = -U else: tmp = t_0 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 <= -9.6e-98) tmp = t_0; elseif (J <= -5.5e-306) tmp = U; elseif (J <= 1.05e-82) tmp = Float64(-U); else tmp = t_0; 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 <= -9.6e-98) tmp = t_0; elseif (J <= -5.5e-306) tmp = U; elseif (J <= 1.05e-82) 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[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -9.6e-98], t$95$0, If[LessEqual[J, -5.5e-306], U, If[LessEqual[J, 1.05e-82], (-U), t$95$0]]]]
\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 -9.6 \cdot 10^{-98}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -5.5 \cdot 10^{-306}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.05 \cdot 10^{-82}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -9.60000000000000019e-98 or 1.05e-82 < J Initial program 90.2%
Taylor expanded in J around inf 71.9%
associate-*r*71.9%
*-commutative71.9%
*-commutative71.9%
associate-*r*71.9%
*-commutative71.9%
Simplified71.9%
if -9.60000000000000019e-98 < J < -5.49999999999999992e-306Initial program 52.5%
Taylor expanded in U around -inf 43.9%
if -5.49999999999999992e-306 < J < 1.05e-82Initial program 47.0%
Taylor expanded in J around 0 30.8%
neg-mul-130.8%
Simplified30.8%
Final simplification60.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2.46e+120) (* -2.0 J) (if (<= J -5.5e-306) U (if (<= J 3.7e-53) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2.46e+120) {
tmp = -2.0 * J;
} else if (J <= -5.5e-306) {
tmp = U;
} else if (J <= 3.7e-53) {
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.46d+120)) then
tmp = (-2.0d0) * j
else if (j <= (-5.5d-306)) then
tmp = u
else if (j <= 3.7d-53) 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.46e+120) {
tmp = -2.0 * J;
} else if (J <= -5.5e-306) {
tmp = U;
} else if (J <= 3.7e-53) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2.46e+120: tmp = -2.0 * J elif J <= -5.5e-306: tmp = U elif J <= 3.7e-53: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2.46e+120) tmp = Float64(-2.0 * J); elseif (J <= -5.5e-306) tmp = U; elseif (J <= 3.7e-53) 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.46e+120) tmp = -2.0 * J; elseif (J <= -5.5e-306) tmp = U; elseif (J <= 3.7e-53) 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.46e+120], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -5.5e-306], U, If[LessEqual[J, 3.7e-53], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.46 \cdot 10^{+120}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -5.5 \cdot 10^{-306}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 3.7 \cdot 10^{-53}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -2.4600000000000001e120 or 3.69999999999999982e-53 < J Initial program 98.2%
Taylor expanded in K around 0 51.6%
*-commutative51.6%
*-commutative51.6%
unpow251.6%
unpow251.6%
Simplified51.6%
Taylor expanded in J around inf 54.3%
if -2.4600000000000001e120 < J < -5.49999999999999992e-306Initial program 67.8%
Taylor expanded in U around -inf 33.7%
if -5.49999999999999992e-306 < J < 3.69999999999999982e-53Initial program 47.9%
Taylor expanded in J around 0 34.2%
neg-mul-134.2%
Simplified34.2%
Final simplification42.8%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -5.5e-306) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -5.5e-306) {
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 <= (-5.5d-306)) 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 <= -5.5e-306) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -5.5e-306: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -5.5e-306) 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 <= -5.5e-306) 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, -5.5e-306], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -5.5 \cdot 10^{-306}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -5.49999999999999992e-306Initial program 77.3%
Taylor expanded in U around -inf 26.2%
if -5.49999999999999992e-306 < J Initial program 76.7%
Taylor expanded in J around 0 20.9%
neg-mul-120.9%
Simplified20.9%
Final simplification23.6%
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 77.0%
Taylor expanded in U around -inf 27.8%
Final simplification27.8%
herbie shell --seed 2023275
(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)))))