
(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 10 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 (* J t_0))
(t_2
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_2 (- INFINITY))
(* -2.0 (* U 0.5))
(if (<= t_2 2e+297)
(* -2.0 (* t_1 (hypot 1.0 (/ U (* 2.0 t_1)))))
(* -2.0 (* U -0.5))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = J * t_0;
double t_2 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = -2.0 * (U * 0.5);
} else if (t_2 <= 2e+297) {
tmp = -2.0 * (t_1 * hypot(1.0, (U / (2.0 * t_1))));
} else {
tmp = -2.0 * (U * -0.5);
}
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 = J * t_0;
double t_2 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = -2.0 * (U * 0.5);
} else if (t_2 <= 2e+297) {
tmp = -2.0 * (t_1 * Math.hypot(1.0, (U / (2.0 * t_1))));
} else {
tmp = -2.0 * (U * -0.5);
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = J * t_0 t_2 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_2 <= -math.inf: tmp = -2.0 * (U * 0.5) elif t_2 <= 2e+297: tmp = -2.0 * (t_1 * math.hypot(1.0, (U / (2.0 * t_1)))) else: tmp = -2.0 * (U * -0.5) return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(J * t_0) t_2 = 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_2 <= Float64(-Inf)) tmp = Float64(-2.0 * Float64(U * 0.5)); elseif (t_2 <= 2e+297) tmp = Float64(-2.0 * Float64(t_1 * hypot(1.0, Float64(U / Float64(2.0 * t_1))))); else tmp = Float64(-2.0 * Float64(U * -0.5)); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = J * t_0; t_2 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_2 <= -Inf) tmp = -2.0 * (U * 0.5); elseif (t_2 <= 2e+297) tmp = -2.0 * (t_1 * hypot(1.0, (U / (2.0 * t_1)))); else tmp = -2.0 * (U * -0.5); 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[(J * t$95$0), $MachinePrecision]}, Block[{t$95$2 = 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$2, (-Infinity)], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+297], N[(-2.0 * N[(t$95$1 * N[Sqrt[1.0 ^ 2 + N[(U / N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := J \cdot t_0\\
t_2 := \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_2 \leq -\infty:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+297}:\\
\;\;\;\;-2 \cdot \left(t_1 \cdot \mathsf{hypot}\left(1, \frac{U}{2 \cdot t_1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < -inf.0Initial program 6.0%
Simplified49.5%
Taylor expanded in J around 0 54.1%
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)))) < 2e297Initial program 99.8%
associate-*l*99.8%
associate-*l*99.8%
unpow299.8%
sqr-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg99.8%
unpow299.8%
Simplified99.8%
if 2e297 < (*.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 6.1%
Simplified49.5%
Taylor expanded in U around -inf 54.6%
*-commutative54.6%
Simplified54.6%
Final simplification86.7%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* -2.0 (* J (* t_0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return -2.0 * (J * (t_0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return -2.0 * (J * (t_0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) return -2.0 * (J * (t_0 * math.hypot(1.0, (U / (J * (2.0 * t_0))))))
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(-2.0 * Float64(J * Float64(t_0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = -2.0 * (J * (t_0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(-2.0 * N[(J * N[(t$95$0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(J \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)
\end{array}
\end{array}
Initial program 72.7%
Simplified85.2%
Final simplification85.2%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* (cos (/ K 2.0)) (* J (hypot 1.0 (* 0.5 (/ U J))))))))
(if (<= J -5.2e-52)
t_0
(if (<= J 8e-309)
(* -2.0 (- (* U -0.5) (/ (* J J) U)))
(if (<= J 3.8e-147) (* -2.0 (* U 0.5)) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * (cos((K / 2.0)) * (J * hypot(1.0, (0.5 * (U / J)))));
double tmp;
if (J <= -5.2e-52) {
tmp = t_0;
} else if (J <= 8e-309) {
tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
} else if (J <= 3.8e-147) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = -2.0 * (Math.cos((K / 2.0)) * (J * Math.hypot(1.0, (0.5 * (U / J)))));
double tmp;
if (J <= -5.2e-52) {
tmp = t_0;
} else if (J <= 8e-309) {
tmp = -2.0 * ((U * -0.5) - ((J * J) / U));
} else if (J <= 3.8e-147) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * (math.cos((K / 2.0)) * (J * math.hypot(1.0, (0.5 * (U / J))))) tmp = 0 if J <= -5.2e-52: tmp = t_0 elif J <= 8e-309: tmp = -2.0 * ((U * -0.5) - ((J * J) / U)) elif J <= 3.8e-147: tmp = -2.0 * (U * 0.5) else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(cos(Float64(K / 2.0)) * Float64(J * hypot(1.0, Float64(0.5 * Float64(U / J)))))) tmp = 0.0 if (J <= -5.2e-52) tmp = t_0; elseif (J <= 8e-309) tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(Float64(J * J) / U))); elseif (J <= 3.8e-147) tmp = Float64(-2.0 * Float64(U * 0.5)); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = -2.0 * (cos((K / 2.0)) * (J * hypot(1.0, (0.5 * (U / J))))); tmp = 0.0; if (J <= -5.2e-52) tmp = t_0; elseif (J <= 8e-309) tmp = -2.0 * ((U * -0.5) - ((J * J) / U)); elseif (J <= 3.8e-147) tmp = -2.0 * (U * 0.5); else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -5.2e-52], t$95$0, If[LessEqual[J, 8e-309], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(N[(J * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 3.8e-147], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\right)\right)\\
\mathbf{if}\;J \leq -5.2 \cdot 10^{-52}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 8 \cdot 10^{-309}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J \cdot J}{U}\right)\\
\mathbf{elif}\;J \leq 3.8 \cdot 10^{-147}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -5.1999999999999997e-52 or 3.80000000000000028e-147 < J Initial program 88.2%
associate-*l*88.2%
associate-*l*88.2%
*-commutative88.2%
unpow288.2%
sqr-neg88.2%
distribute-frac-neg88.2%
distribute-frac-neg88.2%
unpow288.2%
Simplified96.3%
Taylor expanded in K around 0 84.6%
if -5.1999999999999997e-52 < J < 8.0000000000000003e-309Initial program 50.2%
Simplified73.6%
Taylor expanded in K around 0 12.3%
unpow212.3%
unpow212.3%
Simplified12.3%
Taylor expanded in U around -inf 41.7%
+-commutative41.7%
mul-1-neg41.7%
unsub-neg41.7%
*-commutative41.7%
unpow241.7%
Simplified41.7%
if 8.0000000000000003e-309 < J < 3.80000000000000028e-147Initial program 45.0%
Simplified59.8%
Taylor expanded in J around 0 48.1%
Final simplification69.3%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* J (cos (/ K 2.0))))))
(if (<= J -6.1e+16)
t_0
(if (<= J -4e-310)
(* -2.0 (* U -0.5))
(if (<= J 1.7e-144)
(* -2.0 (* U 0.5))
(if (or (<= J 125000000.0) (not (<= J 3.5e+153)))
t_0
(* -2.0 (* J (sqrt (+ 1.0 (* 0.25 (* (/ U J) (/ U J)))))))))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * (J * cos((K / 2.0)));
double tmp;
if (J <= -6.1e+16) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 1.7e-144) {
tmp = -2.0 * (U * 0.5);
} else if ((J <= 125000000.0) || !(J <= 3.5e+153)) {
tmp = t_0;
} else {
tmp = -2.0 * (J * sqrt((1.0 + (0.25 * ((U / J) * (U / 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) :: t_0
real(8) :: tmp
t_0 = (-2.0d0) * (j * cos((k / 2.0d0)))
if (j <= (-6.1d+16)) then
tmp = t_0
else if (j <= (-4d-310)) then
tmp = (-2.0d0) * (u * (-0.5d0))
else if (j <= 1.7d-144) then
tmp = (-2.0d0) * (u * 0.5d0)
else if ((j <= 125000000.0d0) .or. (.not. (j <= 3.5d+153))) then
tmp = t_0
else
tmp = (-2.0d0) * (j * sqrt((1.0d0 + (0.25d0 * ((u / j) * (u / j))))))
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = -2.0 * (J * Math.cos((K / 2.0)));
double tmp;
if (J <= -6.1e+16) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 1.7e-144) {
tmp = -2.0 * (U * 0.5);
} else if ((J <= 125000000.0) || !(J <= 3.5e+153)) {
tmp = t_0;
} else {
tmp = -2.0 * (J * Math.sqrt((1.0 + (0.25 * ((U / J) * (U / J))))));
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * (J * math.cos((K / 2.0))) tmp = 0 if J <= -6.1e+16: tmp = t_0 elif J <= -4e-310: tmp = -2.0 * (U * -0.5) elif J <= 1.7e-144: tmp = -2.0 * (U * 0.5) elif (J <= 125000000.0) or not (J <= 3.5e+153): tmp = t_0 else: tmp = -2.0 * (J * math.sqrt((1.0 + (0.25 * ((U / J) * (U / J)))))) return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(J * cos(Float64(K / 2.0)))) tmp = 0.0 if (J <= -6.1e+16) tmp = t_0; elseif (J <= -4e-310) tmp = Float64(-2.0 * Float64(U * -0.5)); elseif (J <= 1.7e-144) tmp = Float64(-2.0 * Float64(U * 0.5)); elseif ((J <= 125000000.0) || !(J <= 3.5e+153)) tmp = t_0; else tmp = Float64(-2.0 * Float64(J * sqrt(Float64(1.0 + Float64(0.25 * Float64(Float64(U / J) * Float64(U / J))))))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = -2.0 * (J * cos((K / 2.0))); tmp = 0.0; if (J <= -6.1e+16) tmp = t_0; elseif (J <= -4e-310) tmp = -2.0 * (U * -0.5); elseif (J <= 1.7e-144) tmp = -2.0 * (U * 0.5); elseif ((J <= 125000000.0) || ~((J <= 3.5e+153))) tmp = t_0; else tmp = -2.0 * (J * sqrt((1.0 + (0.25 * ((U / J) * (U / J)))))); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -6.1e+16], t$95$0, If[LessEqual[J, -4e-310], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.7e-144], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[J, 125000000.0], N[Not[LessEqual[J, 3.5e+153]], $MachinePrecision]], t$95$0, N[(-2.0 * N[(J * N[Sqrt[N[(1.0 + N[(0.25 * N[(N[(U / J), $MachinePrecision] * N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\
\mathbf{if}\;J \leq -6.1 \cdot 10^{+16}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 1.7 \cdot 10^{-144}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{elif}\;J \leq 125000000 \lor \neg \left(J \leq 3.5 \cdot 10^{+153}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \sqrt{1 + 0.25 \cdot \left(\frac{U}{J} \cdot \frac{U}{J}\right)}\right)\\
\end{array}
\end{array}
if J < -6.1e16 or 1.70000000000000009e-144 < J < 1.25e8 or 3.4999999999999999e153 < J Initial program 91.2%
associate-*l*91.2%
associate-*l*91.2%
*-commutative91.2%
unpow291.2%
sqr-neg91.2%
distribute-frac-neg91.2%
distribute-frac-neg91.2%
unpow291.2%
Simplified96.7%
Taylor expanded in J around inf 78.2%
if -6.1e16 < J < -3.999999999999988e-310Initial program 51.1%
Simplified77.0%
Taylor expanded in U around -inf 38.1%
*-commutative38.1%
Simplified38.1%
if -3.999999999999988e-310 < J < 1.70000000000000009e-144Initial program 45.0%
Simplified59.8%
Taylor expanded in J around 0 48.1%
if 1.25e8 < J < 3.4999999999999999e153Initial program 95.9%
Simplified99.9%
Taylor expanded in K around 0 62.4%
unpow262.4%
unpow262.4%
Simplified62.4%
frac-times78.1%
Applied egg-rr78.1%
Final simplification62.1%
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))))
(if (<= J -1.15e+18)
t_1
(if (<= J -4e-310)
(* -2.0 (* U -0.5))
(if (<= J 3e-144)
(* -2.0 (* U 0.5))
(if (<= J 106000000.0)
(* -2.0 (* t_0 (+ J (* 0.125 (/ (* U U) J)))))
(if (<= J 2.7e+153)
(* -2.0 (* J (sqrt (+ 1.0 (* 0.25 (* (/ U J) (/ U J)))))))
t_1)))))))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);
double tmp;
if (J <= -1.15e+18) {
tmp = t_1;
} else if (J <= -4e-310) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 3e-144) {
tmp = -2.0 * (U * 0.5);
} else if (J <= 106000000.0) {
tmp = -2.0 * (t_0 * (J + (0.125 * ((U * U) / J))));
} else if (J <= 2.7e+153) {
tmp = -2.0 * (J * sqrt((1.0 + (0.25 * ((U / J) * (U / J))))));
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = (-2.0d0) * (j * t_0)
if (j <= (-1.15d+18)) then
tmp = t_1
else if (j <= (-4d-310)) then
tmp = (-2.0d0) * (u * (-0.5d0))
else if (j <= 3d-144) then
tmp = (-2.0d0) * (u * 0.5d0)
else if (j <= 106000000.0d0) then
tmp = (-2.0d0) * (t_0 * (j + (0.125d0 * ((u * u) / j))))
else if (j <= 2.7d+153) then
tmp = (-2.0d0) * (j * sqrt((1.0d0 + (0.25d0 * ((u / j) * (u / j))))))
else
tmp = t_1
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = -2.0 * (J * t_0);
double tmp;
if (J <= -1.15e+18) {
tmp = t_1;
} else if (J <= -4e-310) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 3e-144) {
tmp = -2.0 * (U * 0.5);
} else if (J <= 106000000.0) {
tmp = -2.0 * (t_0 * (J + (0.125 * ((U * U) / J))));
} else if (J <= 2.7e+153) {
tmp = -2.0 * (J * Math.sqrt((1.0 + (0.25 * ((U / J) * (U / J))))));
} else {
tmp = t_1;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = -2.0 * (J * t_0) tmp = 0 if J <= -1.15e+18: tmp = t_1 elif J <= -4e-310: tmp = -2.0 * (U * -0.5) elif J <= 3e-144: tmp = -2.0 * (U * 0.5) elif J <= 106000000.0: tmp = -2.0 * (t_0 * (J + (0.125 * ((U * U) / J)))) elif J <= 2.7e+153: tmp = -2.0 * (J * math.sqrt((1.0 + (0.25 * ((U / J) * (U / J)))))) else: tmp = t_1 return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(-2.0 * Float64(J * t_0)) tmp = 0.0 if (J <= -1.15e+18) tmp = t_1; elseif (J <= -4e-310) tmp = Float64(-2.0 * Float64(U * -0.5)); elseif (J <= 3e-144) tmp = Float64(-2.0 * Float64(U * 0.5)); elseif (J <= 106000000.0) tmp = Float64(-2.0 * Float64(t_0 * Float64(J + Float64(0.125 * Float64(Float64(U * U) / J))))); elseif (J <= 2.7e+153) tmp = Float64(-2.0 * Float64(J * sqrt(Float64(1.0 + Float64(0.25 * Float64(Float64(U / J) * Float64(U / J))))))); else tmp = t_1; 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); tmp = 0.0; if (J <= -1.15e+18) tmp = t_1; elseif (J <= -4e-310) tmp = -2.0 * (U * -0.5); elseif (J <= 3e-144) tmp = -2.0 * (U * 0.5); elseif (J <= 106000000.0) tmp = -2.0 * (t_0 * (J + (0.125 * ((U * U) / J)))); elseif (J <= 2.7e+153) tmp = -2.0 * (J * sqrt((1.0 + (0.25 * ((U / J) * (U / J)))))); else tmp = t_1; 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[(-2.0 * N[(J * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.15e+18], t$95$1, If[LessEqual[J, -4e-310], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 3e-144], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 106000000.0], N[(-2.0 * N[(t$95$0 * N[(J + N[(0.125 * N[(N[(U * U), $MachinePrecision] / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 2.7e+153], N[(-2.0 * N[(J * N[Sqrt[N[(1.0 + N[(0.25 * N[(N[(U / J), $MachinePrecision] * N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := -2 \cdot \left(J \cdot t_0\right)\\
\mathbf{if}\;J \leq -1.15 \cdot 10^{+18}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 3 \cdot 10^{-144}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{elif}\;J \leq 106000000:\\
\;\;\;\;-2 \cdot \left(t_0 \cdot \left(J + 0.125 \cdot \frac{U \cdot U}{J}\right)\right)\\
\mathbf{elif}\;J \leq 2.7 \cdot 10^{+153}:\\
\;\;\;\;-2 \cdot \left(J \cdot \sqrt{1 + 0.25 \cdot \left(\frac{U}{J} \cdot \frac{U}{J}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if J < -1.15e18 or 2.7000000000000001e153 < J Initial program 98.8%
associate-*l*98.8%
associate-*l*98.8%
*-commutative98.8%
unpow298.8%
sqr-neg98.8%
distribute-frac-neg98.8%
distribute-frac-neg98.8%
unpow298.8%
Simplified99.8%
Taylor expanded in J around inf 87.1%
if -1.15e18 < J < -3.999999999999988e-310Initial program 51.1%
Simplified77.0%
Taylor expanded in U around -inf 38.1%
*-commutative38.1%
Simplified38.1%
if -3.999999999999988e-310 < J < 2.9999999999999999e-144Initial program 45.0%
Simplified59.8%
Taylor expanded in J around 0 48.1%
if 2.9999999999999999e-144 < J < 1.06e8Initial program 70.0%
associate-*l*70.0%
associate-*l*70.0%
*-commutative70.0%
unpow270.0%
sqr-neg70.0%
distribute-frac-neg70.0%
distribute-frac-neg70.0%
unpow270.0%
Simplified87.9%
Taylor expanded in K around 0 72.7%
Taylor expanded in J around inf 54.8%
unpow254.8%
Simplified54.8%
if 1.06e8 < J < 2.7000000000000001e153Initial program 95.9%
Simplified99.9%
Taylor expanded in K around 0 62.4%
unpow262.4%
unpow262.4%
Simplified62.4%
frac-times78.1%
Applied egg-rr78.1%
Final simplification62.3%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* J (cos (/ K 2.0))))))
(if (<= J -4.2e+19)
t_0
(if (<= J -4e-310)
(* -2.0 (* U -0.5))
(if (<= J 3e-144) (* -2.0 (* U 0.5)) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * (J * cos((K / 2.0)));
double tmp;
if (J <= -4.2e+19) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 3e-144) {
tmp = -2.0 * (U * 0.5);
} 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 = (-2.0d0) * (j * cos((k / 2.0d0)))
if (j <= (-4.2d+19)) then
tmp = t_0
else if (j <= (-4d-310)) then
tmp = (-2.0d0) * (u * (-0.5d0))
else if (j <= 3d-144) then
tmp = (-2.0d0) * (u * 0.5d0)
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 = -2.0 * (J * Math.cos((K / 2.0)));
double tmp;
if (J <= -4.2e+19) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 3e-144) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * (J * math.cos((K / 2.0))) tmp = 0 if J <= -4.2e+19: tmp = t_0 elif J <= -4e-310: tmp = -2.0 * (U * -0.5) elif J <= 3e-144: tmp = -2.0 * (U * 0.5) else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(J * cos(Float64(K / 2.0)))) tmp = 0.0 if (J <= -4.2e+19) tmp = t_0; elseif (J <= -4e-310) tmp = Float64(-2.0 * Float64(U * -0.5)); elseif (J <= 3e-144) tmp = Float64(-2.0 * Float64(U * 0.5)); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = -2.0 * (J * cos((K / 2.0))); tmp = 0.0; if (J <= -4.2e+19) tmp = t_0; elseif (J <= -4e-310) tmp = -2.0 * (U * -0.5); elseif (J <= 3e-144) tmp = -2.0 * (U * 0.5); else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -4.2e+19], t$95$0, If[LessEqual[J, -4e-310], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 3e-144], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\\
\mathbf{if}\;J \leq -4.2 \cdot 10^{+19}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 3 \cdot 10^{-144}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -4.2e19 or 2.9999999999999999e-144 < J Initial program 92.0%
associate-*l*92.0%
associate-*l*92.0%
*-commutative92.0%
unpow292.0%
sqr-neg92.0%
distribute-frac-neg92.0%
distribute-frac-neg92.0%
unpow292.0%
Simplified97.2%
Taylor expanded in J around inf 74.0%
if -4.2e19 < J < -3.999999999999988e-310Initial program 51.1%
Simplified77.0%
Taylor expanded in U around -inf 38.1%
*-commutative38.1%
Simplified38.1%
if -3.999999999999988e-310 < J < 2.9999999999999999e-144Initial program 45.0%
Simplified59.8%
Taylor expanded in J around 0 48.1%
Final simplification59.8%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* J (+ 1.0 (* -0.5 (/ U J)))))))
(if (<= J -2.3e-33)
t_0
(if (<= J -4e-310)
(* -2.0 (* U -0.5))
(if (or (<= J 3e-144) (and (not (<= J 4.2e-82)) (<= J 2.9e+68)))
(* -2.0 (* U 0.5))
t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * (J * (1.0 + (-0.5 * (U / J))));
double tmp;
if (J <= -2.3e-33) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = -2.0 * (U * -0.5);
} else if ((J <= 3e-144) || (!(J <= 4.2e-82) && (J <= 2.9e+68))) {
tmp = -2.0 * (U * 0.5);
} 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 = (-2.0d0) * (j * (1.0d0 + ((-0.5d0) * (u / j))))
if (j <= (-2.3d-33)) then
tmp = t_0
else if (j <= (-4d-310)) then
tmp = (-2.0d0) * (u * (-0.5d0))
else if ((j <= 3d-144) .or. (.not. (j <= 4.2d-82)) .and. (j <= 2.9d+68)) then
tmp = (-2.0d0) * (u * 0.5d0)
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 = -2.0 * (J * (1.0 + (-0.5 * (U / J))));
double tmp;
if (J <= -2.3e-33) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = -2.0 * (U * -0.5);
} else if ((J <= 3e-144) || (!(J <= 4.2e-82) && (J <= 2.9e+68))) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * (J * (1.0 + (-0.5 * (U / J)))) tmp = 0 if J <= -2.3e-33: tmp = t_0 elif J <= -4e-310: tmp = -2.0 * (U * -0.5) elif (J <= 3e-144) or (not (J <= 4.2e-82) and (J <= 2.9e+68)): tmp = -2.0 * (U * 0.5) else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(J * Float64(1.0 + Float64(-0.5 * Float64(U / J))))) tmp = 0.0 if (J <= -2.3e-33) tmp = t_0; elseif (J <= -4e-310) tmp = Float64(-2.0 * Float64(U * -0.5)); elseif ((J <= 3e-144) || (!(J <= 4.2e-82) && (J <= 2.9e+68))) tmp = Float64(-2.0 * Float64(U * 0.5)); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = -2.0 * (J * (1.0 + (-0.5 * (U / J)))); tmp = 0.0; if (J <= -2.3e-33) tmp = t_0; elseif (J <= -4e-310) tmp = -2.0 * (U * -0.5); elseif ((J <= 3e-144) || (~((J <= 4.2e-82)) && (J <= 2.9e+68))) tmp = -2.0 * (U * 0.5); else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(J * N[(1.0 + N[(-0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -2.3e-33], t$95$0, If[LessEqual[J, -4e-310], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[J, 3e-144], And[N[Not[LessEqual[J, 4.2e-82]], $MachinePrecision], LessEqual[J, 2.9e+68]]], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \left(1 + -0.5 \cdot \frac{U}{J}\right)\right)\\
\mathbf{if}\;J \leq -2.3 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 3 \cdot 10^{-144} \lor \neg \left(J \leq 4.2 \cdot 10^{-82}\right) \land J \leq 2.9 \cdot 10^{+68}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -2.29999999999999986e-33 or 2.9999999999999999e-144 < J < 4.2000000000000001e-82 or 2.90000000000000011e68 < J Initial program 93.0%
Simplified98.3%
expm1-log1p-u90.4%
*-commutative90.4%
associate-*r*90.4%
*-commutative90.4%
*-un-lft-identity90.4%
times-frac90.4%
metadata-eval90.4%
*-commutative90.4%
div-inv90.4%
metadata-eval90.4%
*-commutative90.4%
associate-/r*90.4%
Applied egg-rr90.4%
expm1-udef90.1%
log1p-expm1-u90.1%
log1p-udef90.1%
add-exp-log90.1%
expm1-log1p-u97.9%
associate-/l*97.9%
Applied egg-rr97.9%
associate--l+98.0%
Simplified98.0%
Taylor expanded in U around -inf 60.1%
if -2.29999999999999986e-33 < J < -3.999999999999988e-310Initial program 49.8%
Simplified72.8%
Taylor expanded in U around -inf 41.7%
*-commutative41.7%
Simplified41.7%
if -3.999999999999988e-310 < J < 2.9999999999999999e-144 or 4.2000000000000001e-82 < J < 2.90000000000000011e68Initial program 58.1%
Simplified74.1%
Taylor expanded in J around 0 37.5%
Final simplification49.1%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= J -5.6e+20)
(* -2.0 J)
(if (<= J -4e-310)
(* -2.0 (* U -0.5))
(if (<= J 2.2e+43) (* -2.0 (* U 0.5)) (* -2.0 J)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -5.6e+20) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 2.2e+43) {
tmp = -2.0 * (U * 0.5);
} 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 <= (-5.6d+20)) then
tmp = (-2.0d0) * j
else if (j <= (-4d-310)) then
tmp = (-2.0d0) * (u * (-0.5d0))
else if (j <= 2.2d+43) then
tmp = (-2.0d0) * (u * 0.5d0)
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 <= -5.6e+20) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 2.2e+43) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -5.6e+20: tmp = -2.0 * J elif J <= -4e-310: tmp = -2.0 * (U * -0.5) elif J <= 2.2e+43: tmp = -2.0 * (U * 0.5) else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -5.6e+20) tmp = Float64(-2.0 * J); elseif (J <= -4e-310) tmp = Float64(-2.0 * Float64(U * -0.5)); elseif (J <= 2.2e+43) tmp = Float64(-2.0 * Float64(U * 0.5)); 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 <= -5.6e+20) tmp = -2.0 * J; elseif (J <= -4e-310) tmp = -2.0 * (U * -0.5); elseif (J <= 2.2e+43) tmp = -2.0 * (U * 0.5); 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, -5.6e+20], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -4e-310], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 2.2e+43], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -5.6 \cdot 10^{+20}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 2.2 \cdot 10^{+43}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -5.6e20 or 2.20000000000000001e43 < J Initial program 98.0%
associate-*l*98.0%
associate-*l*98.0%
*-commutative98.0%
unpow298.0%
sqr-neg98.0%
distribute-frac-neg98.0%
distribute-frac-neg98.0%
unpow298.0%
Simplified99.8%
Taylor expanded in J around inf 83.3%
Taylor expanded in K around 0 57.4%
if -5.6e20 < J < -3.999999999999988e-310Initial program 51.1%
Simplified77.0%
Taylor expanded in U around -inf 38.1%
*-commutative38.1%
Simplified38.1%
if -3.999999999999988e-310 < J < 2.20000000000000001e43Initial program 60.3%
Simplified74.6%
Taylor expanded in J around 0 35.2%
Final simplification44.7%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -5.6e+28) (* -2.0 J) (if (<= J 1.95e+56) (* -2.0 (* U 0.5)) (* -2.0 J))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -5.6e+28) {
tmp = -2.0 * J;
} else if (J <= 1.95e+56) {
tmp = -2.0 * (U * 0.5);
} 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 <= (-5.6d+28)) then
tmp = (-2.0d0) * j
else if (j <= 1.95d+56) then
tmp = (-2.0d0) * (u * 0.5d0)
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 <= -5.6e+28) {
tmp = -2.0 * J;
} else if (J <= 1.95e+56) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -5.6e+28: tmp = -2.0 * J elif J <= 1.95e+56: tmp = -2.0 * (U * 0.5) else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -5.6e+28) tmp = Float64(-2.0 * J); elseif (J <= 1.95e+56) tmp = Float64(-2.0 * Float64(U * 0.5)); 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 <= -5.6e+28) tmp = -2.0 * J; elseif (J <= 1.95e+56) tmp = -2.0 * (U * 0.5); 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, -5.6e+28], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, 1.95e+56], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -5.6 \cdot 10^{+28}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq 1.95 \cdot 10^{+56}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -5.6000000000000003e28 or 1.94999999999999997e56 < J Initial program 98.0%
associate-*l*98.0%
associate-*l*98.0%
*-commutative98.0%
unpow298.0%
sqr-neg98.0%
distribute-frac-neg98.0%
distribute-frac-neg98.0%
unpow298.0%
Simplified99.8%
Taylor expanded in J around inf 83.8%
Taylor expanded in K around 0 58.1%
if -5.6000000000000003e28 < J < 1.94999999999999997e56Initial program 57.0%
Simplified76.2%
Taylor expanded in J around 0 41.2%
Final simplification47.6%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (* -2.0 J))
U = abs(U);
double code(double J, double K, double U) {
return -2.0 * J;
}
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 = (-2.0d0) * j
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
return -2.0 * J;
}
U = abs(U) def code(J, K, U): return -2.0 * J
U = abs(U) function code(J, K, U) return Float64(-2.0 * J) end
U = abs(U) function tmp = code(J, K, U) tmp = -2.0 * J; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := N[(-2.0 * J), $MachinePrecision]
\begin{array}{l}
U = |U|\\
\\
-2 \cdot J
\end{array}
Initial program 72.7%
associate-*l*72.7%
associate-*l*72.7%
*-commutative72.7%
unpow272.7%
sqr-neg72.7%
distribute-frac-neg72.7%
distribute-frac-neg72.7%
unpow272.7%
Simplified85.2%
Taylor expanded in J around inf 48.0%
Taylor expanded in K around 0 31.5%
Final simplification31.5%
herbie shell --seed 2023293
(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)))))