
(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)))) (* (* 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));
return (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
}
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0))))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0)))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, 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)\\
\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}
Initial program 73.6%
*-commutative73.6%
associate-*l*73.6%
unpow273.6%
hypot-1-def86.7%
*-commutative86.7%
associate-*l*86.7%
Simplified86.7%
Final simplification86.7%
(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)))))))))
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))))));
}
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))))));
}
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))))))
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
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
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}
\\
\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 73.6%
*-commutative73.6%
associate-*l*73.6%
associate-*r*73.6%
*-commutative73.6%
associate-*l*73.6%
*-commutative73.6%
unpow273.6%
hypot-1-def86.6%
*-commutative86.6%
associate-*l*86.6%
Simplified86.6%
Final simplification86.6%
(FPCore (J K U)
:precision binary64
(if (<= U -6.2e+176)
(- U)
(if (<= U 2.55e+163)
(* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (/ U (* J 2.0))))
(- U))))
double code(double J, double K, double U) {
double tmp;
if (U <= -6.2e+176) {
tmp = -U;
} else if (U <= 2.55e+163) {
tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0)));
} else {
tmp = -U;
}
return tmp;
}
public static double code(double J, double K, double U) {
double tmp;
if (U <= -6.2e+176) {
tmp = -U;
} else if (U <= 2.55e+163) {
tmp = (J * (-2.0 * Math.cos((K / 2.0)))) * Math.hypot(1.0, (U / (J * 2.0)));
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if U <= -6.2e+176: tmp = -U elif U <= 2.55e+163: tmp = (J * (-2.0 * math.cos((K / 2.0)))) * math.hypot(1.0, (U / (J * 2.0))) else: tmp = -U return tmp
function code(J, K, U) tmp = 0.0 if (U <= -6.2e+176) tmp = Float64(-U); elseif (U <= 2.55e+163) tmp = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(U / Float64(J * 2.0)))); else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= -6.2e+176) tmp = -U; elseif (U <= 2.55e+163) tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0))); else tmp = -U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[U, -6.2e+176], (-U), If[LessEqual[U, 2.55e+163], 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], (-U)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -6.2 \cdot 10^{+176}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq 2.55 \cdot 10^{+163}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < -6.1999999999999998e176 or 2.5500000000000001e163 < U Initial program 37.2%
*-commutative37.2%
associate-*l*37.2%
associate-*r*37.2%
*-commutative37.2%
associate-*l*37.1%
*-commutative37.1%
unpow237.1%
hypot-1-def54.6%
*-commutative54.6%
associate-*l*54.6%
Simplified54.6%
Taylor expanded in J around 0 56.2%
neg-mul-156.2%
Simplified56.2%
if -6.1999999999999998e176 < U < 2.5500000000000001e163Initial program 85.8%
*-commutative85.8%
associate-*l*85.8%
unpow285.8%
hypot-1-def97.3%
*-commutative97.3%
associate-*l*97.3%
Simplified97.3%
Taylor expanded in K around 0 86.0%
Final simplification78.6%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -6.8e-23)
t_0
(if (<= J -2.4e-131)
(- U)
(if (<= J -4.8e-272) U (if (<= J 1.4e-209) (- 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 <= -6.8e-23) {
tmp = t_0;
} else if (J <= -2.4e-131) {
tmp = -U;
} else if (J <= -4.8e-272) {
tmp = U;
} else if (J <= 1.4e-209) {
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 <= (-6.8d-23)) then
tmp = t_0
else if (j <= (-2.4d-131)) then
tmp = -u
else if (j <= (-4.8d-272)) then
tmp = u
else if (j <= 1.4d-209) 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 <= -6.8e-23) {
tmp = t_0;
} else if (J <= -2.4e-131) {
tmp = -U;
} else if (J <= -4.8e-272) {
tmp = U;
} else if (J <= 1.4e-209) {
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 <= -6.8e-23: tmp = t_0 elif J <= -2.4e-131: tmp = -U elif J <= -4.8e-272: tmp = U elif J <= 1.4e-209: 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 <= -6.8e-23) tmp = t_0; elseif (J <= -2.4e-131) tmp = Float64(-U); elseif (J <= -4.8e-272) tmp = U; elseif (J <= 1.4e-209) tmp = Float64(-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 <= -6.8e-23) tmp = t_0; elseif (J <= -2.4e-131) tmp = -U; elseif (J <= -4.8e-272) tmp = U; elseif (J <= 1.4e-209) 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, -6.8e-23], t$95$0, If[LessEqual[J, -2.4e-131], (-U), If[LessEqual[J, -4.8e-272], U, If[LessEqual[J, 1.4e-209], (-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 -6.8 \cdot 10^{-23}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -2.4 \cdot 10^{-131}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq -4.8 \cdot 10^{-272}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.4 \cdot 10^{-209}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -6.8000000000000001e-23 or 1.40000000000000006e-209 < J Initial program 87.1%
*-commutative87.1%
associate-*l*87.1%
associate-*r*87.1%
*-commutative87.1%
associate-*l*87.1%
*-commutative87.1%
unpow287.1%
hypot-1-def95.0%
*-commutative95.0%
associate-*l*95.0%
Simplified95.0%
Taylor expanded in U around 0 69.1%
if -6.8000000000000001e-23 < J < -2.4e-131 or -4.7999999999999998e-272 < J < 1.40000000000000006e-209Initial program 45.3%
*-commutative45.3%
associate-*l*45.3%
associate-*r*45.3%
*-commutative45.3%
associate-*l*45.2%
*-commutative45.2%
unpow245.2%
hypot-1-def64.4%
*-commutative64.4%
associate-*l*64.4%
Simplified64.4%
Taylor expanded in J around 0 63.0%
neg-mul-163.0%
Simplified63.0%
if -2.4e-131 < J < -4.7999999999999998e-272Initial program 38.5%
*-commutative38.5%
associate-*l*38.5%
associate-*r*38.5%
*-commutative38.5%
associate-*l*38.4%
*-commutative38.4%
unpow238.4%
hypot-1-def72.8%
*-commutative72.8%
associate-*l*72.8%
Simplified72.8%
Taylor expanded in U around -inf 65.1%
Final simplification67.5%
(FPCore (J K U) :precision binary64 (if (or (<= K -0.0022) (not (<= K 3.3e+17))) (* J (* -2.0 (cos (* K 0.5)))) (* (hypot 1.0 (/ U (* J 2.0))) (* J -2.0))))
double code(double J, double K, double U) {
double tmp;
if ((K <= -0.0022) || !(K <= 3.3e+17)) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else {
tmp = hypot(1.0, (U / (J * 2.0))) * (J * -2.0);
}
return tmp;
}
public static double code(double J, double K, double U) {
double tmp;
if ((K <= -0.0022) || !(K <= 3.3e+17)) {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
} else {
tmp = Math.hypot(1.0, (U / (J * 2.0))) * (J * -2.0);
}
return tmp;
}
def code(J, K, U): tmp = 0 if (K <= -0.0022) or not (K <= 3.3e+17): tmp = J * (-2.0 * math.cos((K * 0.5))) else: tmp = math.hypot(1.0, (U / (J * 2.0))) * (J * -2.0) return tmp
function code(J, K, U) tmp = 0.0 if ((K <= -0.0022) || !(K <= 3.3e+17)) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); else tmp = Float64(hypot(1.0, Float64(U / Float64(J * 2.0))) * Float64(J * -2.0)); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if ((K <= -0.0022) || ~((K <= 3.3e+17))) tmp = J * (-2.0 * cos((K * 0.5))); else tmp = hypot(1.0, (U / (J * 2.0))) * (J * -2.0); end tmp_2 = tmp; end
code[J_, K_, U_] := If[Or[LessEqual[K, -0.0022], N[Not[LessEqual[K, 3.3e+17]], $MachinePrecision]], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * N[(J * -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq -0.0022 \lor \neg \left(K \leq 3.3 \cdot 10^{+17}\right):\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right) \cdot \left(J \cdot -2\right)\\
\end{array}
\end{array}
if K < -0.00220000000000000013 or 3.3e17 < K Initial program 80.6%
*-commutative80.6%
associate-*l*80.6%
associate-*r*80.6%
*-commutative80.6%
associate-*l*80.6%
*-commutative80.6%
unpow280.6%
hypot-1-def90.9%
*-commutative90.9%
associate-*l*90.9%
Simplified90.9%
Taylor expanded in U around 0 60.1%
if -0.00220000000000000013 < K < 3.3e17Initial program 67.5%
*-commutative67.5%
associate-*l*67.5%
unpow267.5%
hypot-1-def82.9%
*-commutative82.9%
associate-*l*82.9%
Simplified82.9%
Taylor expanded in K around 0 80.3%
Taylor expanded in K around 0 81.1%
Final simplification71.3%
(FPCore (J K U)
:precision binary64
(if (<= U -3.6e+190)
(- U)
(if (<= U -5e+71)
U
(if (<= U 2.8e-30)
(* J (* -2.0 (+ 1.0 (/ (* U (/ 0.125 J)) (/ J U)))))
(- U)))))
double code(double J, double K, double U) {
double tmp;
if (U <= -3.6e+190) {
tmp = -U;
} else if (U <= -5e+71) {
tmp = U;
} else if (U <= 2.8e-30) {
tmp = J * (-2.0 * (1.0 + ((U * (0.125 / J)) / (J / 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 (u <= (-3.6d+190)) then
tmp = -u
else if (u <= (-5d+71)) then
tmp = u
else if (u <= 2.8d-30) then
tmp = j * ((-2.0d0) * (1.0d0 + ((u * (0.125d0 / j)) / (j / u))))
else
tmp = -u
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double tmp;
if (U <= -3.6e+190) {
tmp = -U;
} else if (U <= -5e+71) {
tmp = U;
} else if (U <= 2.8e-30) {
tmp = J * (-2.0 * (1.0 + ((U * (0.125 / J)) / (J / U))));
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if U <= -3.6e+190: tmp = -U elif U <= -5e+71: tmp = U elif U <= 2.8e-30: tmp = J * (-2.0 * (1.0 + ((U * (0.125 / J)) / (J / U)))) else: tmp = -U return tmp
function code(J, K, U) tmp = 0.0 if (U <= -3.6e+190) tmp = Float64(-U); elseif (U <= -5e+71) tmp = U; elseif (U <= 2.8e-30) tmp = Float64(J * Float64(-2.0 * Float64(1.0 + Float64(Float64(U * Float64(0.125 / J)) / Float64(J / U))))); else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= -3.6e+190) tmp = -U; elseif (U <= -5e+71) tmp = U; elseif (U <= 2.8e-30) tmp = J * (-2.0 * (1.0 + ((U * (0.125 / J)) / (J / U)))); else tmp = -U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[U, -3.6e+190], (-U), If[LessEqual[U, -5e+71], U, If[LessEqual[U, 2.8e-30], N[(J * N[(-2.0 * N[(1.0 + N[(N[(U * N[(0.125 / J), $MachinePrecision]), $MachinePrecision] / N[(J / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -3.6 \cdot 10^{+190}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq -5 \cdot 10^{+71}:\\
\;\;\;\;U\\
\mathbf{elif}\;U \leq 2.8 \cdot 10^{-30}:\\
\;\;\;\;J \cdot \left(-2 \cdot \left(1 + \frac{U \cdot \frac{0.125}{J}}{\frac{J}{U}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < -3.59999999999999979e190 or 2.79999999999999988e-30 < U Initial program 47.2%
*-commutative47.2%
associate-*l*47.2%
associate-*r*47.2%
*-commutative47.2%
associate-*l*47.2%
*-commutative47.2%
unpow247.2%
hypot-1-def69.5%
*-commutative69.5%
associate-*l*69.5%
Simplified69.5%
Taylor expanded in J around 0 47.9%
neg-mul-147.9%
Simplified47.9%
if -3.59999999999999979e190 < U < -4.99999999999999972e71Initial program 65.2%
*-commutative65.2%
associate-*l*65.2%
associate-*r*65.2%
*-commutative65.2%
associate-*l*65.1%
*-commutative65.1%
unpow265.1%
hypot-1-def86.8%
*-commutative86.8%
associate-*l*86.8%
Simplified86.8%
Taylor expanded in U around -inf 55.7%
if -4.99999999999999972e71 < U < 2.79999999999999988e-30Initial program 95.4%
*-commutative95.4%
associate-*l*95.4%
associate-*r*95.4%
*-commutative95.4%
associate-*l*95.4%
*-commutative95.4%
unpow295.4%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in K around 0 42.2%
associate-*r*42.2%
unpow242.2%
unpow242.2%
Simplified42.2%
Taylor expanded in U around 0 37.8%
associate-*r/37.8%
unpow237.8%
unpow237.8%
Simplified37.8%
Taylor expanded in U around 0 37.8%
associate-*r/37.8%
unpow237.8%
times-frac41.2%
unpow241.2%
associate-/l*41.4%
associate-*r/41.4%
Simplified41.4%
Final simplification45.2%
(FPCore (J K U) :precision binary64 (if (<= U -2e+191) (- U) (if (<= U -2e+72) U (if (<= U 2.8e-31) (* J -2.0) (- U)))))
double code(double J, double K, double U) {
double tmp;
if (U <= -2e+191) {
tmp = -U;
} else if (U <= -2e+72) {
tmp = U;
} else if (U <= 2.8e-31) {
tmp = J * -2.0;
} 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 (u <= (-2d+191)) then
tmp = -u
else if (u <= (-2d+72)) then
tmp = u
else if (u <= 2.8d-31) then
tmp = j * (-2.0d0)
else
tmp = -u
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double tmp;
if (U <= -2e+191) {
tmp = -U;
} else if (U <= -2e+72) {
tmp = U;
} else if (U <= 2.8e-31) {
tmp = J * -2.0;
} else {
tmp = -U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if U <= -2e+191: tmp = -U elif U <= -2e+72: tmp = U elif U <= 2.8e-31: tmp = J * -2.0 else: tmp = -U return tmp
function code(J, K, U) tmp = 0.0 if (U <= -2e+191) tmp = Float64(-U); elseif (U <= -2e+72) tmp = U; elseif (U <= 2.8e-31) tmp = Float64(J * -2.0); else tmp = Float64(-U); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= -2e+191) tmp = -U; elseif (U <= -2e+72) tmp = U; elseif (U <= 2.8e-31) tmp = J * -2.0; else tmp = -U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[U, -2e+191], (-U), If[LessEqual[U, -2e+72], U, If[LessEqual[U, 2.8e-31], N[(J * -2.0), $MachinePrecision], (-U)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -2 \cdot 10^{+191}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq -2 \cdot 10^{+72}:\\
\;\;\;\;U\\
\mathbf{elif}\;U \leq 2.8 \cdot 10^{-31}:\\
\;\;\;\;J \cdot -2\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < -2.00000000000000015e191 or 2.7999999999999999e-31 < U Initial program 47.2%
*-commutative47.2%
associate-*l*47.2%
associate-*r*47.2%
*-commutative47.2%
associate-*l*47.2%
*-commutative47.2%
unpow247.2%
hypot-1-def69.5%
*-commutative69.5%
associate-*l*69.5%
Simplified69.5%
Taylor expanded in J around 0 47.9%
neg-mul-147.9%
Simplified47.9%
if -2.00000000000000015e191 < U < -1.99999999999999989e72Initial program 65.2%
*-commutative65.2%
associate-*l*65.2%
associate-*r*65.2%
*-commutative65.2%
associate-*l*65.1%
*-commutative65.1%
unpow265.1%
hypot-1-def86.8%
*-commutative86.8%
associate-*l*86.8%
Simplified86.8%
Taylor expanded in U around -inf 55.7%
if -1.99999999999999989e72 < U < 2.7999999999999999e-31Initial program 95.4%
*-commutative95.4%
associate-*l*95.4%
associate-*r*95.4%
*-commutative95.4%
associate-*l*95.4%
*-commutative95.4%
unpow295.4%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in K around 0 42.2%
associate-*r*42.2%
unpow242.2%
unpow242.2%
Simplified42.2%
Taylor expanded in U around 0 41.0%
Final simplification45.0%
(FPCore (J K U) :precision binary64 (if (<= K 2.9e-10) (- U) (if (<= K 4.8e+138) U (if (<= K 3.8e+271) (- U) U))))
double code(double J, double K, double U) {
double tmp;
if (K <= 2.9e-10) {
tmp = -U;
} else if (K <= 4.8e+138) {
tmp = U;
} else if (K <= 3.8e+271) {
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 <= 2.9d-10) then
tmp = -u
else if (k <= 4.8d+138) then
tmp = u
else if (k <= 3.8d+271) 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 <= 2.9e-10) {
tmp = -U;
} else if (K <= 4.8e+138) {
tmp = U;
} else if (K <= 3.8e+271) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}
def code(J, K, U): tmp = 0 if K <= 2.9e-10: tmp = -U elif K <= 4.8e+138: tmp = U elif K <= 3.8e+271: tmp = -U else: tmp = U return tmp
function code(J, K, U) tmp = 0.0 if (K <= 2.9e-10) tmp = Float64(-U); elseif (K <= 4.8e+138) tmp = U; elseif (K <= 3.8e+271) tmp = Float64(-U); else tmp = U; end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (K <= 2.9e-10) tmp = -U; elseif (K <= 4.8e+138) tmp = U; elseif (K <= 3.8e+271) tmp = -U; else tmp = U; end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[K, 2.9e-10], (-U), If[LessEqual[K, 4.8e+138], U, If[LessEqual[K, 3.8e+271], (-U), U]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 2.9 \cdot 10^{-10}:\\
\;\;\;\;-U\\
\mathbf{elif}\;K \leq 4.8 \cdot 10^{+138}:\\
\;\;\;\;U\\
\mathbf{elif}\;K \leq 3.8 \cdot 10^{+271}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if K < 2.89999999999999981e-10 or 4.8000000000000002e138 < K < 3.7999999999999997e271Initial program 72.9%
*-commutative72.9%
associate-*l*72.9%
associate-*r*72.9%
*-commutative72.9%
associate-*l*72.9%
*-commutative72.9%
unpow272.9%
hypot-1-def86.0%
*-commutative86.0%
associate-*l*86.0%
Simplified86.0%
Taylor expanded in J around 0 31.1%
neg-mul-131.1%
Simplified31.1%
if 2.89999999999999981e-10 < K < 4.8000000000000002e138 or 3.7999999999999997e271 < K Initial program 76.9%
*-commutative76.9%
associate-*l*76.9%
associate-*r*76.9%
*-commutative76.9%
associate-*l*76.8%
*-commutative76.8%
unpow276.8%
hypot-1-def89.5%
*-commutative89.5%
associate-*l*89.5%
Simplified89.5%
Taylor expanded in U around -inf 45.3%
Final simplification33.6%
(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 73.6%
*-commutative73.6%
associate-*l*73.6%
associate-*r*73.6%
*-commutative73.6%
associate-*l*73.6%
*-commutative73.6%
unpow273.6%
hypot-1-def86.6%
*-commutative86.6%
associate-*l*86.6%
Simplified86.6%
Taylor expanded in U around -inf 25.6%
Final simplification25.6%
herbie shell --seed 2023189
(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)))))