
(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}
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U -4e+270)
U
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ U (* J (* 2.0 t_0))))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (U <= -4e+270) {
tmp = U;
} else {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
}
return tmp;
}
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (U <= -4e+270) {
tmp = U;
} else {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
}
return tmp;
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if U <= -4e+270: tmp = U else: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0)))) return tmp
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (U <= -4e+270) tmp = U; else tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))); end return tmp end
function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if (U <= -4e+270) tmp = U; else tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0)))); end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[U, -4e+270], U, 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]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U \leq -4 \cdot 10^{+270}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;\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)\\
\end{array}
\end{array}
if U < -4.0000000000000002e270Initial program 25.0%
*-commutative25.0%
associate-*l*25.0%
associate-*r*25.0%
*-commutative25.0%
associate-*l*25.0%
*-commutative25.0%
unpow225.0%
hypot-1-def32.7%
*-commutative32.7%
associate-*l*32.7%
Simplified32.7%
Taylor expanded in U around -inf 66.7%
if -4.0000000000000002e270 < U Initial program 74.1%
*-commutative74.1%
associate-*l*74.1%
unpow274.1%
hypot-1-def92.1%
*-commutative92.1%
associate-*l*92.1%
Simplified92.1%
Final simplification90.9%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U -5.1e+269)
U
(* J (* t_0 (* -2.0 (hypot 1.0 (/ U (* J (* 2.0 t_0))))))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (U <= -5.1e+269) {
tmp = U;
} else {
tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
return tmp;
}
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (U <= -5.1e+269) {
tmp = U;
} else {
tmp = J * (t_0 * (-2.0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
return tmp;
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if U <= -5.1e+269: tmp = U else: tmp = J * (t_0 * (-2.0 * math.hypot(1.0, (U / (J * (2.0 * t_0)))))) return tmp
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (U <= -5.1e+269) tmp = U; else tmp = Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))); end return tmp end
function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if (U <= -5.1e+269) tmp = U; else tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[U, -5.1e+269], U, 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}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U \leq -5.1 \cdot 10^{+269}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;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}
if U < -5.10000000000000012e269Initial program 25.0%
*-commutative25.0%
associate-*l*25.0%
associate-*r*25.0%
*-commutative25.0%
associate-*l*25.0%
*-commutative25.0%
unpow225.0%
hypot-1-def32.7%
*-commutative32.7%
associate-*l*32.7%
Simplified32.7%
Taylor expanded in U around -inf 66.7%
if -5.10000000000000012e269 < U Initial program 74.1%
*-commutative74.1%
associate-*l*74.1%
associate-*r*74.1%
*-commutative74.1%
associate-*l*74.0%
*-commutative74.0%
unpow274.0%
hypot-1-def92.0%
*-commutative92.0%
associate-*l*92.0%
Simplified92.0%
Final simplification90.8%
(FPCore (J K U)
:precision binary64
(if (<= U -1.45e+178)
U
(if (<= U 3.8e+185)
(* (* (cos (/ K 2.0)) (* J -2.0)) (hypot 1.0 (* 0.5 (/ U J))))
U)))
double code(double J, double K, double U) {
double tmp;
if (U <= -1.45e+178) {
tmp = U;
} else if (U <= 3.8e+185) {
tmp = (cos((K / 2.0)) * (J * -2.0)) * hypot(1.0, (0.5 * (U / J)));
} else {
tmp = U;
}
return tmp;
}
public static double code(double J, double K, double U) {
double tmp;
if (U <= -1.45e+178) {
tmp = U;
} else if (U <= 3.8e+185) {
tmp = (Math.cos((K / 2.0)) * (J * -2.0)) * Math.hypot(1.0, (0.5 * (U / J)));
} else {
tmp = U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if U <= -1.45e+178: tmp = U elif U <= 3.8e+185: tmp = (math.cos((K / 2.0)) * (J * -2.0)) * math.hypot(1.0, (0.5 * (U / J))) else: tmp = U return tmp
function code(J, K, U) tmp = 0.0 if (U <= -1.45e+178) tmp = U; elseif (U <= 3.8e+185) tmp = Float64(Float64(cos(Float64(K / 2.0)) * Float64(J * -2.0)) * hypot(1.0, Float64(0.5 * Float64(U / J)))); else tmp = U; end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= -1.45e+178) tmp = U; elseif (U <= 3.8e+185) tmp = (cos((K / 2.0)) * (J * -2.0)) * hypot(1.0, (0.5 * (U / J))); else tmp = U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[U, -1.45e+178], U, If[LessEqual[U, 3.8e+185], N[(N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * -2.0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], U]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -1.45 \cdot 10^{+178}:\\
\;\;\;\;U\\
\mathbf{elif}\;U \leq 3.8 \cdot 10^{+185}:\\
\;\;\;\;\left(\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot -2\right)\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if U < -1.45e178 or 3.7999999999999998e185 < U Initial program 41.0%
*-commutative41.0%
associate-*l*41.0%
associate-*r*41.0%
*-commutative41.0%
associate-*l*40.9%
*-commutative40.9%
unpow240.9%
hypot-1-def59.5%
*-commutative59.5%
associate-*l*59.5%
Simplified59.5%
Taylor expanded in U around -inf 60.4%
if -1.45e178 < U < 3.7999999999999998e185Initial program 79.3%
Taylor expanded in K around 0 61.6%
unpow261.6%
associate-/r*65.7%
metadata-eval65.7%
unpow265.7%
associate-*l/69.6%
associate-*r/69.6%
swap-sqr69.7%
hypot-1-def80.9%
Simplified80.9%
Final simplification76.9%
(FPCore (J K U) :precision binary64 (if (or (<= K -8.2e+34) (not (<= K 2.4e-23))) (* J (* -2.0 (cos (* K 0.5)))) (* J (* -2.0 (hypot 1.0 (* 0.5 (/ U J)))))))
double code(double J, double K, double U) {
double tmp;
if ((K <= -8.2e+34) || !(K <= 2.4e-23)) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else {
tmp = J * (-2.0 * hypot(1.0, (0.5 * (U / J))));
}
return tmp;
}
public static double code(double J, double K, double U) {
double tmp;
if ((K <= -8.2e+34) || !(K <= 2.4e-23)) {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
} else {
tmp = J * (-2.0 * Math.hypot(1.0, (0.5 * (U / J))));
}
return tmp;
}
def code(J, K, U): tmp = 0 if (K <= -8.2e+34) or not (K <= 2.4e-23): tmp = J * (-2.0 * math.cos((K * 0.5))) else: tmp = J * (-2.0 * math.hypot(1.0, (0.5 * (U / J)))) return tmp
function code(J, K, U) tmp = 0.0 if ((K <= -8.2e+34) || !(K <= 2.4e-23)) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); else tmp = Float64(J * Float64(-2.0 * hypot(1.0, Float64(0.5 * Float64(U / J))))); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if ((K <= -8.2e+34) || ~((K <= 2.4e-23))) tmp = J * (-2.0 * cos((K * 0.5))); else tmp = J * (-2.0 * hypot(1.0, (0.5 * (U / J)))); end tmp_2 = tmp; end
code[J_, K_, U_] := If[Or[LessEqual[K, -8.2e+34], N[Not[LessEqual[K, 2.4e-23]], $MachinePrecision]], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq -8.2 \cdot 10^{+34} \lor \neg \left(K \leq 2.4 \cdot 10^{-23}\right):\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(-2 \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\right)\\
\end{array}
\end{array}
if K < -8.1999999999999997e34 or 2.39999999999999996e-23 < K Initial program 79.5%
*-commutative79.5%
associate-*l*79.5%
associate-*r*79.5%
*-commutative79.5%
associate-*l*79.5%
*-commutative79.5%
unpow279.5%
hypot-1-def92.4%
*-commutative92.4%
associate-*l*92.4%
Simplified92.4%
Taylor expanded in U around 0 56.1%
if -8.1999999999999997e34 < K < 2.39999999999999996e-23Initial program 63.7%
*-commutative63.7%
associate-*l*63.7%
associate-*r*63.7%
*-commutative63.7%
associate-*l*63.7%
*-commutative63.7%
unpow263.7%
hypot-1-def85.8%
*-commutative85.8%
associate-*l*85.8%
Simplified85.8%
Taylor expanded in K around 0 49.2%
associate-*r*49.2%
*-commutative49.2%
unpow249.2%
associate-/r*53.4%
metadata-eval53.4%
unpow253.4%
associate-*l/58.8%
associate-*r/61.8%
swap-sqr61.8%
hypot-1-def83.9%
Simplified83.9%
Final simplification69.7%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -2.3e-58)
t_0
(if (<= J -5.4e-212) (- U) (if (<= J 1.1e-60) U t_0)))))
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -2.3e-58) {
tmp = t_0;
} else if (J <= -5.4e-212) {
tmp = -U;
} else if (J <= 1.1e-60) {
tmp = U;
} else {
tmp = t_0;
}
return tmp;
}
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 <= (-2.3d-58)) then
tmp = t_0
else if (j <= (-5.4d-212)) then
tmp = -u
else if (j <= 1.1d-60) then
tmp = u
else
tmp = t_0
end if
code = tmp
end function
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.3e-58) {
tmp = t_0;
} else if (J <= -5.4e-212) {
tmp = -U;
} else if (J <= 1.1e-60) {
tmp = U;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -2.3e-58: tmp = t_0 elif J <= -5.4e-212: tmp = -U elif J <= 1.1e-60: tmp = U else: tmp = t_0 return tmp
function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -2.3e-58) tmp = t_0; elseif (J <= -5.4e-212) tmp = Float64(-U); elseif (J <= 1.1e-60) tmp = U; else tmp = t_0; end return tmp end
function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (J <= -2.3e-58) tmp = t_0; elseif (J <= -5.4e-212) tmp = -U; elseif (J <= 1.1e-60) tmp = U; else tmp = t_0; end tmp_2 = tmp; end
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.3e-58], t$95$0, If[LessEqual[J, -5.4e-212], (-U), If[LessEqual[J, 1.1e-60], U, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -2.3 \cdot 10^{-58}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -5.4 \cdot 10^{-212}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq 1.1 \cdot 10^{-60}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -2.2999999999999999e-58 or 1.0999999999999999e-60 < J Initial program 93.2%
*-commutative93.2%
associate-*l*93.2%
associate-*r*93.2%
*-commutative93.2%
associate-*l*93.2%
*-commutative93.2%
unpow293.2%
hypot-1-def98.6%
*-commutative98.6%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in U around 0 76.0%
if -2.2999999999999999e-58 < J < -5.39999999999999962e-212Initial program 44.3%
*-commutative44.3%
associate-*l*44.3%
associate-*r*44.3%
*-commutative44.3%
associate-*l*44.2%
*-commutative44.2%
unpow244.2%
hypot-1-def83.2%
*-commutative83.2%
associate-*l*83.2%
Simplified83.2%
Taylor expanded in J around 0 54.9%
neg-mul-154.9%
Simplified54.9%
if -5.39999999999999962e-212 < J < 1.0999999999999999e-60Initial program 36.5%
*-commutative36.5%
associate-*l*36.5%
associate-*r*36.5%
*-commutative36.5%
associate-*l*36.5%
*-commutative36.5%
unpow236.5%
hypot-1-def70.0%
*-commutative70.0%
associate-*l*70.0%
Simplified70.0%
Taylor expanded in U around -inf 58.4%
Final simplification68.4%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (+ -2.0 (* (/ 0.125 J) (* -2.0 (/ U (/ J U))))))))
(if (<= J -1.6e-18)
t_0
(if (<= J -6.8e-212) (- U) (if (<= J 2.1e-16) U t_0)))))
double code(double J, double K, double U) {
double t_0 = J * (-2.0 + ((0.125 / J) * (-2.0 * (U / (J / U)))));
double tmp;
if (J <= -1.6e-18) {
tmp = t_0;
} else if (J <= -6.8e-212) {
tmp = -U;
} else if (J <= 2.1e-16) {
tmp = U;
} else {
tmp = t_0;
}
return tmp;
}
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) + ((0.125d0 / j) * ((-2.0d0) * (u / (j / u)))))
if (j <= (-1.6d-18)) then
tmp = t_0
else if (j <= (-6.8d-212)) then
tmp = -u
else if (j <= 2.1d-16) then
tmp = u
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double t_0 = J * (-2.0 + ((0.125 / J) * (-2.0 * (U / (J / U)))));
double tmp;
if (J <= -1.6e-18) {
tmp = t_0;
} else if (J <= -6.8e-212) {
tmp = -U;
} else if (J <= 2.1e-16) {
tmp = U;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, K, U): t_0 = J * (-2.0 + ((0.125 / J) * (-2.0 * (U / (J / U))))) tmp = 0 if J <= -1.6e-18: tmp = t_0 elif J <= -6.8e-212: tmp = -U elif J <= 2.1e-16: tmp = U else: tmp = t_0 return tmp
function code(J, K, U) t_0 = Float64(J * Float64(-2.0 + Float64(Float64(0.125 / J) * Float64(-2.0 * Float64(U / Float64(J / U)))))) tmp = 0.0 if (J <= -1.6e-18) tmp = t_0; elseif (J <= -6.8e-212) tmp = Float64(-U); elseif (J <= 2.1e-16) tmp = U; else tmp = t_0; end return tmp end
function tmp_2 = code(J, K, U) t_0 = J * (-2.0 + ((0.125 / J) * (-2.0 * (U / (J / U))))); tmp = 0.0; if (J <= -1.6e-18) tmp = t_0; elseif (J <= -6.8e-212) tmp = -U; elseif (J <= 2.1e-16) tmp = U; else tmp = t_0; end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(-2.0 + N[(N[(0.125 / J), $MachinePrecision] * N[(-2.0 * N[(U / N[(J / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.6e-18], t$95$0, If[LessEqual[J, -6.8e-212], (-U), If[LessEqual[J, 2.1e-16], U, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 + \frac{0.125}{J} \cdot \left(-2 \cdot \frac{U}{\frac{J}{U}}\right)\right)\\
\mathbf{if}\;J \leq -1.6 \cdot 10^{-18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -6.8 \cdot 10^{-212}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq 2.1 \cdot 10^{-16}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.6e-18 or 2.1000000000000001e-16 < J Initial program 96.3%
*-commutative96.3%
associate-*l*96.3%
associate-*r*96.3%
*-commutative96.3%
associate-*l*96.2%
*-commutative96.2%
unpow296.2%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in K around 0 41.4%
associate-*r*41.4%
*-commutative41.4%
unpow241.4%
associate-/r*42.1%
metadata-eval42.1%
unpow242.1%
associate-*l/46.0%
associate-*r/50.2%
swap-sqr50.2%
hypot-1-def53.1%
Simplified53.1%
Taylor expanded in U around 0 39.3%
associate-*r/39.3%
unpow239.3%
unpow239.3%
Simplified39.3%
expm1-log1p-u20.2%
expm1-udef20.0%
distribute-rgt-in20.0%
metadata-eval20.0%
times-frac20.5%
Applied egg-rr20.5%
expm1-def20.6%
expm1-log1p40.0%
associate-*l*40.0%
associate-/l*42.5%
Simplified42.5%
if -1.6e-18 < J < -6.79999999999999995e-212Initial program 53.7%
*-commutative53.7%
associate-*l*53.7%
associate-*r*53.7%
*-commutative53.7%
associate-*l*53.6%
*-commutative53.6%
unpow253.6%
hypot-1-def85.8%
*-commutative85.8%
associate-*l*85.8%
Simplified85.8%
Taylor expanded in J around 0 48.5%
neg-mul-148.5%
Simplified48.5%
if -6.79999999999999995e-212 < J < 2.1000000000000001e-16Initial program 40.6%
*-commutative40.6%
associate-*l*40.6%
associate-*r*40.6%
*-commutative40.6%
associate-*l*40.6%
*-commutative40.6%
unpow240.6%
hypot-1-def72.5%
*-commutative72.5%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in U around -inf 56.9%
Final simplification47.8%
(FPCore (J K U) :precision binary64 (if (<= J -1.6e-18) (* J -2.0) (if (<= J -7.2e-212) (- U) (if (<= J 1.15e-20) U (* J -2.0)))))
double code(double J, double K, double U) {
double tmp;
if (J <= -1.6e-18) {
tmp = J * -2.0;
} else if (J <= -7.2e-212) {
tmp = -U;
} else if (J <= 1.15e-20) {
tmp = U;
} else {
tmp = J * -2.0;
}
return tmp;
}
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.6d-18)) then
tmp = j * (-2.0d0)
else if (j <= (-7.2d-212)) then
tmp = -u
else if (j <= 1.15d-20) then
tmp = u
else
tmp = j * (-2.0d0)
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double tmp;
if (J <= -1.6e-18) {
tmp = J * -2.0;
} else if (J <= -7.2e-212) {
tmp = -U;
} else if (J <= 1.15e-20) {
tmp = U;
} else {
tmp = J * -2.0;
}
return tmp;
}
def code(J, K, U): tmp = 0 if J <= -1.6e-18: tmp = J * -2.0 elif J <= -7.2e-212: tmp = -U elif J <= 1.15e-20: tmp = U else: tmp = J * -2.0 return tmp
function code(J, K, U) tmp = 0.0 if (J <= -1.6e-18) tmp = Float64(J * -2.0); elseif (J <= -7.2e-212) tmp = Float64(-U); elseif (J <= 1.15e-20) tmp = U; else tmp = Float64(J * -2.0); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -1.6e-18) tmp = J * -2.0; elseif (J <= -7.2e-212) tmp = -U; elseif (J <= 1.15e-20) tmp = U; else tmp = J * -2.0; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[J, -1.6e-18], N[(J * -2.0), $MachinePrecision], If[LessEqual[J, -7.2e-212], (-U), If[LessEqual[J, 1.15e-20], U, N[(J * -2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.6 \cdot 10^{-18}:\\
\;\;\;\;J \cdot -2\\
\mathbf{elif}\;J \leq -7.2 \cdot 10^{-212}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq 1.15 \cdot 10^{-20}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;J \cdot -2\\
\end{array}
\end{array}
if J < -1.6e-18 or 1.15e-20 < J Initial program 96.3%
*-commutative96.3%
associate-*l*96.3%
associate-*r*96.3%
*-commutative96.3%
associate-*l*96.2%
*-commutative96.2%
unpow296.2%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in K around 0 41.4%
associate-*r*41.4%
*-commutative41.4%
unpow241.4%
associate-/r*42.1%
metadata-eval42.1%
unpow242.1%
associate-*l/46.0%
associate-*r/50.2%
swap-sqr50.2%
hypot-1-def53.1%
Simplified53.1%
Taylor expanded in J around inf 42.0%
if -1.6e-18 < J < -7.2000000000000002e-212Initial program 53.7%
*-commutative53.7%
associate-*l*53.7%
associate-*r*53.7%
*-commutative53.7%
associate-*l*53.6%
*-commutative53.6%
unpow253.6%
hypot-1-def85.8%
*-commutative85.8%
associate-*l*85.8%
Simplified85.8%
Taylor expanded in J around 0 48.5%
neg-mul-148.5%
Simplified48.5%
if -7.2000000000000002e-212 < J < 1.15e-20Initial program 40.6%
*-commutative40.6%
associate-*l*40.6%
associate-*r*40.6%
*-commutative40.6%
associate-*l*40.6%
*-commutative40.6%
unpow240.6%
hypot-1-def72.5%
*-commutative72.5%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in U around -inf 56.9%
Final simplification47.5%
(FPCore (J K U) :precision binary64 (if (<= K 1.2e-119) U (- U)))
double code(double J, double K, double U) {
double tmp;
if (K <= 1.2e-119) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
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 (k <= 1.2d-119) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double tmp;
if (K <= 1.2e-119) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if K <= 1.2e-119: tmp = U else: tmp = -U return tmp
function code(J, K, U) tmp = 0.0 if (K <= 1.2e-119) tmp = U; else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (K <= 1.2e-119) tmp = U; else tmp = -U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[K, 1.2e-119], U, (-U)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 1.2 \cdot 10^{-119}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if K < 1.20000000000000004e-119Initial program 70.1%
*-commutative70.1%
associate-*l*70.1%
associate-*r*70.1%
*-commutative70.1%
associate-*l*70.0%
*-commutative70.0%
unpow270.0%
hypot-1-def90.2%
*-commutative90.2%
associate-*l*90.2%
Simplified90.2%
Taylor expanded in U around -inf 34.1%
if 1.20000000000000004e-119 < K Initial program 74.9%
*-commutative74.9%
associate-*l*74.9%
associate-*r*74.9%
*-commutative74.9%
associate-*l*74.9%
*-commutative74.9%
unpow274.9%
hypot-1-def87.3%
*-commutative87.3%
associate-*l*87.3%
Simplified87.3%
Taylor expanded in J around 0 29.1%
neg-mul-129.1%
Simplified29.1%
Final simplification32.3%
(FPCore (J K U) :precision binary64 U)
double code(double J, double K, double U) {
return U;
}
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
public static double code(double J, double K, double U) {
return U;
}
def code(J, K, U): return U
function code(J, K, U) return U end
function tmp = code(J, K, U) tmp = U; end
code[J_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 71.8%
*-commutative71.8%
associate-*l*71.8%
associate-*r*71.8%
*-commutative71.8%
associate-*l*71.7%
*-commutative71.7%
unpow271.7%
hypot-1-def89.2%
*-commutative89.2%
associate-*l*89.2%
Simplified89.2%
Taylor expanded in U around -inf 29.7%
Final simplification29.7%
herbie shell --seed 2023178
(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)))))