
(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 8 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 1e+305)
(* (* 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 <= 1e+305) {
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 <= 1e+305) {
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 <= 1e+305: 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 <= 1e+305) 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 <= 1e+305) 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, 1e+305], 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 10^{+305}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot t_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < -inf.0Initial program 5.2%
*-commutative5.2%
associate-*l*5.2%
associate-*r*5.2%
*-commutative5.2%
associate-*l*5.2%
*-commutative5.2%
unpow25.2%
hypot-1-def66.6%
*-commutative66.6%
associate-*l*66.6%
Simplified66.6%
Taylor expanded in J around 0 54.3%
neg-mul-154.3%
Simplified54.3%
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)))) < 9.9999999999999994e304Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if 9.9999999999999994e304 < (*.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.3%
*-commutative5.3%
associate-*l*5.3%
associate-*r*5.3%
*-commutative5.3%
associate-*l*5.3%
*-commutative5.3%
unpow25.3%
hypot-1-def60.7%
*-commutative60.7%
associate-*l*60.7%
Simplified60.7%
Taylor expanded in U around -inf 49.2%
Final simplification84.4%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* J (* t_0 (* -2.0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return J * (t_0 * (-2.0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) return J * (t_0 * (-2.0 * math.hypot(1.0, (U / (J * (2.0 * t_0))))))
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(J * N[(t$95$0 * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
J \cdot \left(t_0 \cdot \left(-2 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)
\end{array}
\end{array}
Initial program 69.5%
*-commutative69.5%
associate-*l*69.5%
associate-*r*69.5%
*-commutative69.5%
associate-*l*69.5%
*-commutative69.5%
unpow269.5%
hypot-1-def88.1%
*-commutative88.1%
associate-*l*88.1%
Simplified88.1%
Final simplification88.1%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= U 1.25e+58)
(* J (* -2.0 (cos (* K 0.5))))
(if (<= U 4.8e+116)
(- (/ (- -1.0 (cos K)) (/ U (* J J))) U)
(if (<= U 1e+273) U (- U)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 1.25e+58) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else if (U <= 4.8e+116) {
tmp = ((-1.0 - cos(K)) / (U / (J * J))) - U;
} else if (U <= 1e+273) {
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 (u <= 1.25d+58) then
tmp = j * ((-2.0d0) * cos((k * 0.5d0)))
else if (u <= 4.8d+116) then
tmp = (((-1.0d0) - cos(k)) / (u / (j * j))) - u
else if (u <= 1d+273) 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 (U <= 1.25e+58) {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
} else if (U <= 4.8e+116) {
tmp = ((-1.0 - Math.cos(K)) / (U / (J * J))) - U;
} else if (U <= 1e+273) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 1.25e+58: tmp = J * (-2.0 * math.cos((K * 0.5))) elif U <= 4.8e+116: tmp = ((-1.0 - math.cos(K)) / (U / (J * J))) - U elif U <= 1e+273: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 1.25e+58) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); elseif (U <= 4.8e+116) tmp = Float64(Float64(Float64(-1.0 - cos(K)) / Float64(U / Float64(J * J))) - U); elseif (U <= 1e+273) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 1.25e+58) tmp = J * (-2.0 * cos((K * 0.5))); elseif (U <= 4.8e+116) tmp = ((-1.0 - cos(K)) / (U / (J * J))) - U; elseif (U <= 1e+273) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 1.25e+58], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 4.8e+116], N[(N[(N[(-1.0 - N[Cos[K], $MachinePrecision]), $MachinePrecision] / N[(U / N[(J * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[LessEqual[U, 1e+273], U, (-U)]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 1.25 \cdot 10^{+58}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{elif}\;U \leq 4.8 \cdot 10^{+116}:\\
\;\;\;\;\frac{-1 - \cos K}{\frac{U}{J \cdot J}} - U\\
\mathbf{elif}\;U \leq 10^{+273}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < 1.24999999999999996e58Initial program 76.7%
*-commutative76.7%
associate-*l*76.7%
associate-*r*76.7%
*-commutative76.7%
associate-*l*76.7%
*-commutative76.7%
unpow276.7%
hypot-1-def93.3%
*-commutative93.3%
associate-*l*93.3%
Simplified93.3%
Taylor expanded in U around 0 62.6%
if 1.24999999999999996e58 < U < 4.8000000000000001e116Initial program 58.4%
*-commutative58.4%
associate-*l*58.4%
associate-*r*58.4%
*-commutative58.4%
associate-*l*58.3%
*-commutative58.3%
unpow258.3%
hypot-1-def92.5%
*-commutative92.5%
associate-*l*92.5%
Simplified92.5%
Taylor expanded in J around 0 69.1%
neg-mul-169.1%
unsub-neg69.1%
associate-/l*69.1%
associate-*r/69.1%
unpow269.1%
Simplified69.1%
*-commutative69.1%
pow269.1%
cos-mult69.1%
Applied egg-rr69.1%
+-commutative69.1%
+-inverses69.1%
cos-069.1%
distribute-lft-out69.1%
metadata-eval69.1%
*-rgt-identity69.1%
Simplified69.1%
Taylor expanded in K around inf 69.1%
mul-1-neg69.1%
associate-/l*69.1%
distribute-neg-frac69.1%
unpow269.1%
Simplified69.1%
if 4.8000000000000001e116 < U < 9.99999999999999945e272Initial program 37.8%
*-commutative37.8%
associate-*l*37.8%
associate-*r*37.8%
*-commutative37.8%
associate-*l*37.7%
*-commutative37.7%
unpow237.7%
hypot-1-def64.8%
*-commutative64.8%
associate-*l*64.8%
Simplified64.8%
Taylor expanded in U around -inf 52.9%
if 9.99999999999999945e272 < U Initial program 39.8%
*-commutative39.8%
associate-*l*39.8%
associate-*r*39.8%
*-commutative39.8%
associate-*l*39.8%
*-commutative39.8%
unpow239.8%
hypot-1-def39.8%
*-commutative39.8%
associate-*l*39.8%
Simplified39.8%
Taylor expanded in J around 0 51.6%
neg-mul-151.6%
Simplified51.6%
Final simplification61.4%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= U 7.8e+56)
(* J (* -2.0 (cos (* K 0.5))))
(if (<= U 5.5e+116)
(- (* -2.0 (/ (* J J) U)) U)
(if (<= U 8e+272) U (- U)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 7.8e+56) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else if (U <= 5.5e+116) {
tmp = (-2.0 * ((J * J) / U)) - U;
} else if (U <= 8e+272) {
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 (u <= 7.8d+56) then
tmp = j * ((-2.0d0) * cos((k * 0.5d0)))
else if (u <= 5.5d+116) then
tmp = ((-2.0d0) * ((j * j) / u)) - u
else if (u <= 8d+272) 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 (U <= 7.8e+56) {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
} else if (U <= 5.5e+116) {
tmp = (-2.0 * ((J * J) / U)) - U;
} else if (U <= 8e+272) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 7.8e+56: tmp = J * (-2.0 * math.cos((K * 0.5))) elif U <= 5.5e+116: tmp = (-2.0 * ((J * J) / U)) - U elif U <= 8e+272: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 7.8e+56) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); elseif (U <= 5.5e+116) tmp = Float64(Float64(-2.0 * Float64(Float64(J * J) / U)) - U); elseif (U <= 8e+272) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 7.8e+56) tmp = J * (-2.0 * cos((K * 0.5))); elseif (U <= 5.5e+116) tmp = (-2.0 * ((J * J) / U)) - U; elseif (U <= 8e+272) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 7.8e+56], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 5.5e+116], N[(N[(-2.0 * N[(N[(J * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[LessEqual[U, 8e+272], U, (-U)]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 7.8 \cdot 10^{+56}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{elif}\;U \leq 5.5 \cdot 10^{+116}:\\
\;\;\;\;-2 \cdot \frac{J \cdot J}{U} - U\\
\mathbf{elif}\;U \leq 8 \cdot 10^{+272}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < 7.79999999999999989e56Initial program 76.7%
*-commutative76.7%
associate-*l*76.7%
associate-*r*76.7%
*-commutative76.7%
associate-*l*76.7%
*-commutative76.7%
unpow276.7%
hypot-1-def93.3%
*-commutative93.3%
associate-*l*93.3%
Simplified93.3%
Taylor expanded in U around 0 62.6%
if 7.79999999999999989e56 < U < 5.50000000000000035e116Initial program 58.4%
*-commutative58.4%
associate-*l*58.4%
associate-*r*58.4%
*-commutative58.4%
associate-*l*58.3%
*-commutative58.3%
unpow258.3%
hypot-1-def92.5%
*-commutative92.5%
associate-*l*92.5%
Simplified92.5%
Taylor expanded in J around 0 69.1%
neg-mul-169.1%
unsub-neg69.1%
associate-/l*69.1%
associate-*r/69.1%
unpow269.1%
Simplified69.1%
Taylor expanded in K around 0 67.5%
unpow267.5%
Simplified67.5%
if 5.50000000000000035e116 < U < 8.0000000000000005e272Initial program 37.8%
*-commutative37.8%
associate-*l*37.8%
associate-*r*37.8%
*-commutative37.8%
associate-*l*37.7%
*-commutative37.7%
unpow237.7%
hypot-1-def64.8%
*-commutative64.8%
associate-*l*64.8%
Simplified64.8%
Taylor expanded in U around -inf 52.9%
if 8.0000000000000005e272 < U Initial program 39.8%
*-commutative39.8%
associate-*l*39.8%
associate-*r*39.8%
*-commutative39.8%
associate-*l*39.8%
*-commutative39.8%
unpow239.8%
hypot-1-def39.8%
*-commutative39.8%
associate-*l*39.8%
Simplified39.8%
Taylor expanded in J around 0 51.6%
neg-mul-151.6%
Simplified51.6%
Final simplification61.3%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= U 3.4e-101)
(* -2.0 J)
(if (<= U 6.4e+116)
(- (* -2.0 (/ (* J J) U)) U)
(if (<= U 1.7e+273) U (- U)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 3.4e-101) {
tmp = -2.0 * J;
} else if (U <= 6.4e+116) {
tmp = (-2.0 * ((J * J) / U)) - U;
} else if (U <= 1.7e+273) {
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 (u <= 3.4d-101) then
tmp = (-2.0d0) * j
else if (u <= 6.4d+116) then
tmp = ((-2.0d0) * ((j * j) / u)) - u
else if (u <= 1.7d+273) 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 (U <= 3.4e-101) {
tmp = -2.0 * J;
} else if (U <= 6.4e+116) {
tmp = (-2.0 * ((J * J) / U)) - U;
} else if (U <= 1.7e+273) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 3.4e-101: tmp = -2.0 * J elif U <= 6.4e+116: tmp = (-2.0 * ((J * J) / U)) - U elif U <= 1.7e+273: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 3.4e-101) tmp = Float64(-2.0 * J); elseif (U <= 6.4e+116) tmp = Float64(Float64(-2.0 * Float64(Float64(J * J) / U)) - U); elseif (U <= 1.7e+273) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 3.4e-101) tmp = -2.0 * J; elseif (U <= 6.4e+116) tmp = (-2.0 * ((J * J) / U)) - U; elseif (U <= 1.7e+273) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 3.4e-101], N[(-2.0 * J), $MachinePrecision], If[LessEqual[U, 6.4e+116], N[(N[(-2.0 * N[(N[(J * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], If[LessEqual[U, 1.7e+273], U, (-U)]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 3.4 \cdot 10^{-101}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;U \leq 6.4 \cdot 10^{+116}:\\
\;\;\;\;-2 \cdot \frac{J \cdot J}{U} - U\\
\mathbf{elif}\;U \leq 1.7 \cdot 10^{+273}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < 3.39999999999999989e-101Initial program 77.2%
*-commutative77.2%
associate-*l*77.2%
associate-*r*77.2%
*-commutative77.2%
associate-*l*77.1%
*-commutative77.1%
unpow277.1%
hypot-1-def92.2%
*-commutative92.2%
associate-*l*92.2%
Simplified92.2%
Taylor expanded in U around 0 63.6%
Taylor expanded in K around 0 38.5%
if 3.39999999999999989e-101 < U < 6.4000000000000001e116Initial program 69.0%
*-commutative69.0%
associate-*l*69.0%
associate-*r*69.0%
*-commutative69.0%
associate-*l*69.0%
*-commutative69.0%
unpow269.0%
hypot-1-def97.5%
*-commutative97.5%
associate-*l*97.5%
Simplified97.5%
Taylor expanded in J around 0 44.3%
neg-mul-144.3%
unsub-neg44.3%
associate-/l*44.3%
associate-*r/44.3%
unpow244.3%
Simplified44.3%
Taylor expanded in K around 0 43.8%
unpow243.8%
Simplified43.8%
if 6.4000000000000001e116 < U < 1.69999999999999999e273Initial program 37.8%
*-commutative37.8%
associate-*l*37.8%
associate-*r*37.8%
*-commutative37.8%
associate-*l*37.7%
*-commutative37.7%
unpow237.7%
hypot-1-def64.8%
*-commutative64.8%
associate-*l*64.8%
Simplified64.8%
Taylor expanded in U around -inf 52.9%
if 1.69999999999999999e273 < U Initial program 39.8%
*-commutative39.8%
associate-*l*39.8%
associate-*r*39.8%
*-commutative39.8%
associate-*l*39.8%
*-commutative39.8%
unpow239.8%
hypot-1-def39.8%
*-commutative39.8%
associate-*l*39.8%
Simplified39.8%
Taylor expanded in J around 0 51.6%
neg-mul-151.6%
Simplified51.6%
Final simplification41.7%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 3.4e-101) (* -2.0 J) (if (<= U 1.45e+116) (- U) (if (<= U 1.25e+273) U (- U)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 3.4e-101) {
tmp = -2.0 * J;
} else if (U <= 1.45e+116) {
tmp = -U;
} else if (U <= 1.25e+273) {
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 (u <= 3.4d-101) then
tmp = (-2.0d0) * j
else if (u <= 1.45d+116) then
tmp = -u
else if (u <= 1.25d+273) 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 (U <= 3.4e-101) {
tmp = -2.0 * J;
} else if (U <= 1.45e+116) {
tmp = -U;
} else if (U <= 1.25e+273) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 3.4e-101: tmp = -2.0 * J elif U <= 1.45e+116: tmp = -U elif U <= 1.25e+273: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 3.4e-101) tmp = Float64(-2.0 * J); elseif (U <= 1.45e+116) tmp = Float64(-U); elseif (U <= 1.25e+273) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 3.4e-101) tmp = -2.0 * J; elseif (U <= 1.45e+116) tmp = -U; elseif (U <= 1.25e+273) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 3.4e-101], N[(-2.0 * J), $MachinePrecision], If[LessEqual[U, 1.45e+116], (-U), If[LessEqual[U, 1.25e+273], U, (-U)]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 3.4 \cdot 10^{-101}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;U \leq 1.45 \cdot 10^{+116}:\\
\;\;\;\;-U\\
\mathbf{elif}\;U \leq 1.25 \cdot 10^{+273}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if U < 3.39999999999999989e-101Initial program 77.2%
*-commutative77.2%
associate-*l*77.2%
associate-*r*77.2%
*-commutative77.2%
associate-*l*77.1%
*-commutative77.1%
unpow277.1%
hypot-1-def92.2%
*-commutative92.2%
associate-*l*92.2%
Simplified92.2%
Taylor expanded in U around 0 63.6%
Taylor expanded in K around 0 38.5%
if 3.39999999999999989e-101 < U < 1.4500000000000001e116 or 1.2499999999999999e273 < U Initial program 65.5%
*-commutative65.5%
associate-*l*65.5%
associate-*r*65.5%
*-commutative65.5%
associate-*l*65.5%
*-commutative65.5%
unpow265.5%
hypot-1-def90.6%
*-commutative90.6%
associate-*l*90.6%
Simplified90.6%
Taylor expanded in J around 0 43.9%
neg-mul-143.9%
Simplified43.9%
if 1.4500000000000001e116 < U < 1.2499999999999999e273Initial program 37.8%
*-commutative37.8%
associate-*l*37.8%
associate-*r*37.8%
*-commutative37.8%
associate-*l*37.7%
*-commutative37.7%
unpow237.7%
hypot-1-def64.8%
*-commutative64.8%
associate-*l*64.8%
Simplified64.8%
Taylor expanded in U around -inf 52.9%
Final simplification41.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J 3.7e-308) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= 3.7e-308) {
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 <= 3.7d-308) 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 <= 3.7e-308) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= 3.7e-308: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= 3.7e-308) 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 <= 3.7e-308) 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, 3.7e-308], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq 3.7 \cdot 10^{-308}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < 3.70000000000000006e-308Initial 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-def90.8%
*-commutative90.8%
associate-*l*90.8%
Simplified90.8%
Taylor expanded in U around -inf 26.2%
if 3.70000000000000006e-308 < J Initial program 68.1%
*-commutative68.1%
associate-*l*68.1%
associate-*r*68.1%
*-commutative68.1%
associate-*l*68.1%
*-commutative68.1%
unpow268.1%
hypot-1-def85.5%
*-commutative85.5%
associate-*l*85.5%
Simplified85.5%
Taylor expanded in J around 0 32.2%
neg-mul-132.2%
Simplified32.2%
Final simplification29.3%
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 69.5%
*-commutative69.5%
associate-*l*69.5%
associate-*r*69.5%
*-commutative69.5%
associate-*l*69.5%
*-commutative69.5%
unpow269.5%
hypot-1-def88.1%
*-commutative88.1%
associate-*l*88.1%
Simplified88.1%
Taylor expanded in U around -inf 24.8%
Final simplification24.8%
herbie shell --seed 2023238
(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)))))