
(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 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t_0}\right)}^{2}}
\end{array}
\end{array}
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY))
(- U)
(if (<= t_1 5e+304)
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ U (* J (* 2.0 t_0)))))
U))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U;
} else if (t_1 <= 5e+304) {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U;
} else if (t_1 <= 5e+304) {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U elif t_1 <= 5e+304: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0)))) else: tmp = U return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U); elseif (t_1 <= 5e+304) tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U; elseif (t_1 <= 5e+304) tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0)))); else tmp = U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U), If[LessEqual[t$95$1, 5e+304], N[(N[(J * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], U]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-U\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;\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.6%
*-commutative5.6%
associate-*l*5.6%
associate-*r*5.6%
*-commutative5.6%
associate-*l*5.6%
*-commutative5.6%
unpow25.6%
hypot-1-def55.7%
*-commutative55.7%
associate-*l*55.7%
Simplified55.7%
Taylor expanded in J around 0 42.0%
neg-mul-142.0%
Simplified42.0%
if -inf.0 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < 4.9999999999999997e304Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if 4.9999999999999997e304 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) Initial program 5.6%
*-commutative5.6%
associate-*l*5.6%
associate-*r*5.6%
*-commutative5.6%
associate-*l*5.6%
*-commutative5.6%
unpow25.6%
hypot-1-def54.8%
*-commutative54.8%
associate-*l*54.8%
Simplified54.8%
Taylor expanded in U around -inf 48.9%
Final simplification85.1%
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 74.4%
*-commutative74.4%
associate-*l*74.4%
associate-*r*74.4%
*-commutative74.4%
associate-*l*74.4%
*-commutative74.4%
unpow274.4%
hypot-1-def87.7%
*-commutative87.7%
associate-*l*87.7%
Simplified87.7%
Final simplification87.7%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 1.4e+240) (* J (* (cos (/ K 2.0)) (* -2.0 (hypot 1.0 (/ U (* J 2.0)))))) (if (<= U 5e+273) (- U) U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 1.4e+240) {
tmp = J * (cos((K / 2.0)) * (-2.0 * hypot(1.0, (U / (J * 2.0)))));
} else if (U <= 5e+273) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 1.4e+240) {
tmp = J * (Math.cos((K / 2.0)) * (-2.0 * Math.hypot(1.0, (U / (J * 2.0)))));
} else if (U <= 5e+273) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 1.4e+240: tmp = J * (math.cos((K / 2.0)) * (-2.0 * math.hypot(1.0, (U / (J * 2.0))))) elif U <= 5e+273: tmp = -U else: tmp = U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 1.4e+240) tmp = Float64(J * Float64(cos(Float64(K / 2.0)) * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * 2.0)))))); elseif (U <= 5e+273) tmp = Float64(-U); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 1.4e+240) tmp = J * (cos((K / 2.0)) * (-2.0 * hypot(1.0, (U / (J * 2.0))))); elseif (U <= 5e+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.4e+240], N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 5e+273], (-U), U]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 1.4 \cdot 10^{+240}:\\
\;\;\;\;J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\right)\right)\\
\mathbf{elif}\;U \leq 5 \cdot 10^{+273}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if U < 1.4000000000000001e240Initial program 76.3%
*-commutative76.3%
associate-*l*76.3%
associate-*r*76.3%
*-commutative76.3%
associate-*l*76.3%
*-commutative76.3%
unpow276.3%
hypot-1-def89.3%
*-commutative89.3%
associate-*l*89.3%
Simplified89.3%
Taylor expanded in K around 0 74.8%
if 1.4000000000000001e240 < U < 4.99999999999999961e273Initial program 25.2%
*-commutative25.2%
associate-*l*25.2%
associate-*r*25.2%
*-commutative25.2%
associate-*l*25.2%
*-commutative25.2%
unpow225.2%
hypot-1-def80.8%
*-commutative80.8%
associate-*l*80.8%
Simplified80.8%
Taylor expanded in J around 0 62.4%
neg-mul-162.4%
Simplified62.4%
if 4.99999999999999961e273 < U Initial program 50.2%
*-commutative50.2%
associate-*l*50.2%
associate-*r*50.2%
*-commutative50.2%
associate-*l*50.2%
*-commutative50.2%
unpow250.2%
hypot-1-def50.2%
*-commutative50.2%
associate-*l*50.2%
Simplified50.2%
Taylor expanded in U around -inf 47.8%
Final simplification73.6%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -1.65e-76)
t_0
(if (<= J 8.6e-305)
U
(if (<= J 7.5e-84) (- (* -2.0 (/ (* J J) U)) U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -1.65e-76) {
tmp = t_0;
} else if (J <= 8.6e-305) {
tmp = U;
} else if (J <= 7.5e-84) {
tmp = (-2.0 * ((J * J) / U)) - 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 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-1.65d-76)) then
tmp = t_0
else if (j <= 8.6d-305) then
tmp = u
else if (j <= 7.5d-84) then
tmp = ((-2.0d0) * ((j * j) / u)) - 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 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (J <= -1.65e-76) {
tmp = t_0;
} else if (J <= 8.6e-305) {
tmp = U;
} else if (J <= 7.5e-84) {
tmp = (-2.0 * ((J * J) / U)) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -1.65e-76: tmp = t_0 elif J <= 8.6e-305: tmp = U elif J <= 7.5e-84: tmp = (-2.0 * ((J * J) / U)) - U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -1.65e-76) tmp = t_0; elseif (J <= 8.6e-305) tmp = U; elseif (J <= 7.5e-84) tmp = Float64(Float64(-2.0 * Float64(Float64(J * J) / U)) - U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (J <= -1.65e-76) tmp = t_0; elseif (J <= 8.6e-305) tmp = U; elseif (J <= 7.5e-84) tmp = (-2.0 * ((J * J) / U)) - U; else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.65e-76], t$95$0, If[LessEqual[J, 8.6e-305], U, If[LessEqual[J, 7.5e-84], N[(N[(-2.0 * N[(N[(J * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -1.65 \cdot 10^{-76}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 8.6 \cdot 10^{-305}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 7.5 \cdot 10^{-84}:\\
\;\;\;\;-2 \cdot \frac{J \cdot J}{U} - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.64999999999999992e-76 or 7.50000000000000026e-84 < J Initial program 92.0%
*-commutative92.0%
associate-*l*92.0%
associate-*r*92.0%
*-commutative92.0%
associate-*l*92.0%
*-commutative92.0%
unpow292.0%
hypot-1-def98.6%
*-commutative98.6%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in U around 0 74.7%
if -1.64999999999999992e-76 < J < 8.6000000000000004e-305Initial program 54.6%
*-commutative54.6%
associate-*l*54.6%
associate-*r*54.6%
*-commutative54.6%
associate-*l*54.5%
*-commutative54.5%
unpow254.5%
hypot-1-def77.5%
*-commutative77.5%
associate-*l*77.5%
Simplified77.5%
Taylor expanded in U around -inf 40.9%
if 8.6000000000000004e-305 < J < 7.50000000000000026e-84Initial program 41.3%
*-commutative41.3%
associate-*l*41.3%
associate-*r*41.3%
*-commutative41.3%
associate-*l*41.3%
*-commutative41.3%
unpow241.3%
hypot-1-def65.8%
*-commutative65.8%
associate-*l*65.8%
Simplified65.8%
Taylor expanded in K around 0 4.8%
associate-*r*4.8%
unpow24.8%
unpow24.8%
Simplified4.8%
Taylor expanded in U around inf 34.4%
mul-1-neg34.4%
unsub-neg34.4%
unpow234.4%
Simplified34.4%
Final simplification60.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -1.12e+15) (* -2.0 J) (if (<= J 1.2e-304) U (if (<= J 2.45e+141) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.12e+15) {
tmp = -2.0 * J;
} else if (J <= 1.2e-304) {
tmp = U;
} else if (J <= 2.45e+141) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-1.12d+15)) then
tmp = (-2.0d0) * j
else if (j <= 1.2d-304) then
tmp = u
else if (j <= 2.45d+141) then
tmp = -u
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -1.12e+15) {
tmp = -2.0 * J;
} else if (J <= 1.2e-304) {
tmp = U;
} else if (J <= 2.45e+141) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.12e+15: tmp = -2.0 * J elif J <= 1.2e-304: tmp = U elif J <= 2.45e+141: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.12e+15) tmp = Float64(-2.0 * J); elseif (J <= 1.2e-304) tmp = U; elseif (J <= 2.45e+141) tmp = Float64(-U); else tmp = Float64(-2.0 * J); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -1.12e+15) tmp = -2.0 * J; elseif (J <= 1.2e-304) tmp = U; elseif (J <= 2.45e+141) tmp = -U; else tmp = -2.0 * J; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -1.12e+15], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, 1.2e-304], U, If[LessEqual[J, 2.45e+141], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.12 \cdot 10^{+15}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq 1.2 \cdot 10^{-304}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2.45 \cdot 10^{+141}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -1.12e15 or 2.45000000000000005e141 < J Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*l*99.8%
*-commutative99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 85.7%
Taylor expanded in K around 0 43.9%
*-commutative43.9%
Simplified43.9%
if -1.12e15 < J < 1.2e-304Initial program 58.7%
*-commutative58.7%
associate-*l*58.7%
associate-*r*58.7%
*-commutative58.7%
associate-*l*58.7%
*-commutative58.7%
unpow258.7%
hypot-1-def81.0%
*-commutative81.0%
associate-*l*81.0%
Simplified81.0%
Taylor expanded in U around -inf 34.7%
if 1.2e-304 < J < 2.45000000000000005e141Initial program 60.3%
*-commutative60.3%
associate-*l*60.3%
associate-*r*60.3%
*-commutative60.3%
associate-*l*60.2%
*-commutative60.2%
unpow260.2%
hypot-1-def80.6%
*-commutative80.6%
associate-*l*80.6%
Simplified80.6%
Taylor expanded in J around 0 27.3%
neg-mul-127.3%
Simplified27.3%
Final simplification35.3%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J 8.6e-305) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= 8.6e-305) {
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 <= 8.6d-305) 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 <= 8.6e-305) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= 8.6e-305: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= 8.6e-305) 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 <= 8.6e-305) 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, 8.6e-305], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq 8.6 \cdot 10^{-305}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < 8.6000000000000004e-305Initial program 78.6%
*-commutative78.6%
associate-*l*78.6%
associate-*r*78.6%
*-commutative78.6%
associate-*l*78.6%
*-commutative78.6%
unpow278.6%
hypot-1-def90.1%
*-commutative90.1%
associate-*l*90.1%
Simplified90.1%
Taylor expanded in U around -inf 23.8%
if 8.6000000000000004e-305 < J Initial program 70.4%
*-commutative70.4%
associate-*l*70.4%
associate-*r*70.4%
*-commutative70.4%
associate-*l*70.4%
*-commutative70.4%
unpow270.4%
hypot-1-def85.6%
*-commutative85.6%
associate-*l*85.6%
Simplified85.6%
Taylor expanded in J around 0 22.3%
neg-mul-122.3%
Simplified22.3%
Final simplification23.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 U)
U = abs(U);
double code(double J, double K, double U) {
return U;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
return U;
}
U = abs(U) def code(J, K, U): return U
U = abs(U) function code(J, K, U) return U end
U = abs(U) function tmp = code(J, K, U) tmp = U; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := U
\begin{array}{l}
U = |U|\\
\\
U
\end{array}
Initial program 74.4%
*-commutative74.4%
associate-*l*74.4%
associate-*r*74.4%
*-commutative74.4%
associate-*l*74.4%
*-commutative74.4%
unpow274.4%
hypot-1-def87.7%
*-commutative87.7%
associate-*l*87.7%
Simplified87.7%
Taylor expanded in U around -inf 29.0%
Final simplification29.0%
herbie shell --seed 2023249
(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)))))