
(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 11 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
(*
(* t_0 (* -2.0 J))
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY)) (- U) (if (<= t_1 1e+302) t_1 U))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = (t_0 * (-2.0 * J)) * 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+302) {
tmp = t_1;
} 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 = (t_0 * (-2.0 * J)) * 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+302) {
tmp = t_1;
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = (t_0 * (-2.0 * J)) * 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+302: tmp = t_1 else: tmp = U return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(t_0 * Float64(-2.0 * J)) * 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+302) tmp = t_1; 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 = (t_0 * (-2.0 * J)) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U; elseif (t_1 <= 1e+302) tmp = t_1; 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[(t$95$0 * N[(-2.0 * J), $MachinePrecision]), $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+302], t$95$1, U]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(t_0 \cdot \left(-2 \cdot J\right)\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^{+302}:\\
\;\;\;\;t_1\\
\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.3%
Taylor expanded in J around 0 52.7%
neg-mul-152.7%
Simplified52.7%
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)))) < 1.0000000000000001e302Initial program 99.7%
if 1.0000000000000001e302 < (*.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.9%
Taylor expanded in U around -inf 32.7%
Final simplification82.7%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U 6e+244)
(* -2.0 (* t_0 (* J (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 tmp;
if (U <= 6e+244) {
tmp = -2.0 * (t_0 * (J * 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 tmp;
if (U <= 6e+244) {
tmp = -2.0 * (t_0 * (J * 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)) tmp = 0 if U <= 6e+244: tmp = -2.0 * (t_0 * (J * 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)) tmp = 0.0 if (U <= 6e+244) tmp = Float64(-2.0 * Float64(t_0 * Float64(J * hypot(1.0, Float64(Float64(U / Float64(J * 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)); tmp = 0.0; if (U <= 6e+244) tmp = -2.0 * (t_0 * (J * 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]}, If[LessEqual[U, 6e+244], N[(-2.0 * N[(t$95$0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], U]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U \leq 6 \cdot 10^{+244}:\\
\;\;\;\;-2 \cdot \left(t_0 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{t_0}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if U < 5.9999999999999995e244Initial program 72.4%
Simplified87.9%
if 5.9999999999999995e244 < U Initial program 36.5%
Taylor expanded in U around -inf 30.1%
Final simplification85.6%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U 4.3e+245)
(* -2.0 (* (* J 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 tmp;
if (U <= 4.3e+245) {
tmp = -2.0 * ((J * 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 tmp;
if (U <= 4.3e+245) {
tmp = -2.0 * ((J * 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)) tmp = 0 if U <= 4.3e+245: tmp = -2.0 * ((J * 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)) tmp = 0.0 if (U <= 4.3e+245) tmp = Float64(-2.0 * Float64(Float64(J * t_0) * hypot(1.0, Float64(Float64(U / Float64(J * 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)); tmp = 0.0; if (U <= 4.3e+245) tmp = -2.0 * ((J * 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]}, If[LessEqual[U, 4.3e+245], N[(-2.0 * N[(N[(J * t$95$0), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], U]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U \leq 4.3 \cdot 10^{+245}:\\
\;\;\;\;-2 \cdot \left(\left(J \cdot t_0\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{t_0}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if U < 4.29999999999999979e245Initial program 72.4%
associate-*l*72.4%
associate-*l*72.4%
unpow272.4%
hypot-1-def88.0%
associate-/r*87.9%
cos-neg87.9%
distribute-frac-neg87.9%
associate-/r*88.0%
associate-/r*87.9%
distribute-frac-neg87.9%
cos-neg87.9%
Simplified87.9%
if 4.29999999999999979e245 < U Initial program 36.5%
Taylor expanded in U around -inf 30.1%
Final simplification85.7%
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))) (hypot 1.0 (/ (* U 0.5) J)))))
(t_1 (* J (cos (* K 0.5)))))
(if (<= J -4.1e-115)
t_0
(if (<= J -4e-310)
(* -2.0 (- (* U -0.5) (/ t_1 (/ U t_1))))
(if (<= J 7.8e-28) (- (* -2.0 (/ (pow t_1 2.0) U)) U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, ((U * 0.5) / J)));
double t_1 = J * cos((K * 0.5));
double tmp;
if (J <= -4.1e-115) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = -2.0 * ((U * -0.5) - (t_1 / (U / t_1)));
} else if (J <= 7.8e-28) {
tmp = (-2.0 * (pow(t_1, 2.0) / U)) - U;
} 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 * ((J * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U * 0.5) / J)));
double t_1 = J * Math.cos((K * 0.5));
double tmp;
if (J <= -4.1e-115) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = -2.0 * ((U * -0.5) - (t_1 / (U / t_1)));
} else if (J <= 7.8e-28) {
tmp = (-2.0 * (Math.pow(t_1, 2.0) / U)) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * ((J * math.cos((K / 2.0))) * math.hypot(1.0, ((U * 0.5) / J))) t_1 = J * math.cos((K * 0.5)) tmp = 0 if J <= -4.1e-115: tmp = t_0 elif J <= -4e-310: tmp = -2.0 * ((U * -0.5) - (t_1 / (U / t_1))) elif J <= 7.8e-28: tmp = (-2.0 * (math.pow(t_1, 2.0) / U)) - U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(Float64(J * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U * 0.5) / J)))) t_1 = Float64(J * cos(Float64(K * 0.5))) tmp = 0.0 if (J <= -4.1e-115) tmp = t_0; elseif (J <= -4e-310) tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(t_1 / Float64(U / t_1)))); elseif (J <= 7.8e-28) tmp = Float64(Float64(-2.0 * Float64((t_1 ^ 2.0) / U)) - U); 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))) * hypot(1.0, ((U * 0.5) / J))); t_1 = J * cos((K * 0.5)); tmp = 0.0; if (J <= -4.1e-115) tmp = t_0; elseif (J <= -4e-310) tmp = -2.0 * ((U * -0.5) - (t_1 / (U / t_1))); elseif (J <= 7.8e-28) tmp = (-2.0 * ((t_1 ^ 2.0) / 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[(-2.0 * N[(N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -4.1e-115], t$95$0, If[LessEqual[J, -4e-310], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(t$95$1 / N[(U / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 7.8e-28], N[(N[(-2.0 * N[(N[Power[t$95$1, 2.0], $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U \cdot 0.5}{J}\right)\right)\\
t_1 := J \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq -4.1 \cdot 10^{-115}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{t_1}{\frac{U}{t_1}}\right)\\
\mathbf{elif}\;J \leq 7.8 \cdot 10^{-28}:\\
\;\;\;\;-2 \cdot \frac{{t_1}^{2}}{U} - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -4.0999999999999997e-115 or 7.79999999999999998e-28 < J Initial program 90.0%
associate-*l*90.0%
associate-*l*90.0%
unpow290.0%
hypot-1-def96.9%
associate-/r*96.9%
cos-neg96.9%
distribute-frac-neg96.9%
associate-/r*96.9%
associate-/r*96.9%
distribute-frac-neg96.9%
cos-neg96.9%
Simplified96.9%
Taylor expanded in K around 0 88.5%
associate-*r/88.5%
Simplified88.5%
if -4.0999999999999997e-115 < J < -3.999999999999988e-310Initial program 34.1%
Simplified60.1%
Taylor expanded in U around -inf 34.3%
+-commutative34.3%
mul-1-neg34.3%
unsub-neg34.3%
*-commutative34.3%
unpow234.3%
*-commutative34.3%
unpow234.3%
swap-sqr34.3%
unpow234.3%
*-commutative34.3%
Simplified34.3%
*-commutative34.3%
pow234.3%
*-un-lft-identity34.3%
times-frac34.2%
Applied egg-rr34.2%
clear-num34.2%
/-rgt-identity34.2%
un-div-inv34.2%
*-commutative34.2%
*-commutative34.2%
Applied egg-rr34.2%
if -3.999999999999988e-310 < J < 7.79999999999999998e-28Initial program 40.8%
Taylor expanded in J around 0 42.8%
neg-mul-142.8%
unsub-neg42.8%
unpow242.8%
*-commutative42.8%
unpow242.8%
swap-sqr42.8%
unpow242.8%
*-commutative42.8%
Simplified42.8%
Final simplification70.6%
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))) (hypot 1.0 (/ (* U 0.5) J)))))
(t_1 (* J (cos (* K 0.5)))))
(if (<= J -6.5e-115)
t_0
(if (<= J -4e-310)
(* -2.0 (- (* U -0.5) (* t_1 (/ J U))))
(if (<= J 7.8e-28) (- (* -2.0 (/ (pow t_1 2.0) U)) U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, ((U * 0.5) / J)));
double t_1 = J * cos((K * 0.5));
double tmp;
if (J <= -6.5e-115) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = -2.0 * ((U * -0.5) - (t_1 * (J / U)));
} else if (J <= 7.8e-28) {
tmp = (-2.0 * (pow(t_1, 2.0) / U)) - U;
} 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 * ((J * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U * 0.5) / J)));
double t_1 = J * Math.cos((K * 0.5));
double tmp;
if (J <= -6.5e-115) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = -2.0 * ((U * -0.5) - (t_1 * (J / U)));
} else if (J <= 7.8e-28) {
tmp = (-2.0 * (Math.pow(t_1, 2.0) / U)) - U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * ((J * math.cos((K / 2.0))) * math.hypot(1.0, ((U * 0.5) / J))) t_1 = J * math.cos((K * 0.5)) tmp = 0 if J <= -6.5e-115: tmp = t_0 elif J <= -4e-310: tmp = -2.0 * ((U * -0.5) - (t_1 * (J / U))) elif J <= 7.8e-28: tmp = (-2.0 * (math.pow(t_1, 2.0) / U)) - U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(Float64(J * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U * 0.5) / J)))) t_1 = Float64(J * cos(Float64(K * 0.5))) tmp = 0.0 if (J <= -6.5e-115) tmp = t_0; elseif (J <= -4e-310) tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(t_1 * Float64(J / U)))); elseif (J <= 7.8e-28) tmp = Float64(Float64(-2.0 * Float64((t_1 ^ 2.0) / U)) - U); 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))) * hypot(1.0, ((U * 0.5) / J))); t_1 = J * cos((K * 0.5)); tmp = 0.0; if (J <= -6.5e-115) tmp = t_0; elseif (J <= -4e-310) tmp = -2.0 * ((U * -0.5) - (t_1 * (J / U))); elseif (J <= 7.8e-28) tmp = (-2.0 * ((t_1 ^ 2.0) / 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[(-2.0 * N[(N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -6.5e-115], t$95$0, If[LessEqual[J, -4e-310], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(t$95$1 * N[(J / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 7.8e-28], N[(N[(-2.0 * N[(N[Power[t$95$1, 2.0], $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U \cdot 0.5}{J}\right)\right)\\
t_1 := J \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq -6.5 \cdot 10^{-115}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - t_1 \cdot \frac{J}{U}\right)\\
\mathbf{elif}\;J \leq 7.8 \cdot 10^{-28}:\\
\;\;\;\;-2 \cdot \frac{{t_1}^{2}}{U} - U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -6.50000000000000033e-115 or 7.79999999999999998e-28 < J Initial program 90.0%
associate-*l*90.0%
associate-*l*90.0%
unpow290.0%
hypot-1-def96.9%
associate-/r*96.9%
cos-neg96.9%
distribute-frac-neg96.9%
associate-/r*96.9%
associate-/r*96.9%
distribute-frac-neg96.9%
cos-neg96.9%
Simplified96.9%
Taylor expanded in K around 0 88.5%
associate-*r/88.5%
Simplified88.5%
if -6.50000000000000033e-115 < J < -3.999999999999988e-310Initial program 34.1%
Simplified60.1%
Taylor expanded in U around -inf 34.3%
+-commutative34.3%
mul-1-neg34.3%
unsub-neg34.3%
*-commutative34.3%
unpow234.3%
*-commutative34.3%
unpow234.3%
swap-sqr34.3%
unpow234.3%
*-commutative34.3%
Simplified34.3%
*-commutative34.3%
pow234.3%
*-un-lft-identity34.3%
times-frac34.2%
Applied egg-rr34.2%
Taylor expanded in K around 0 34.2%
if -3.999999999999988e-310 < J < 7.79999999999999998e-28Initial program 40.8%
Taylor expanded in J around 0 42.8%
neg-mul-142.8%
unsub-neg42.8%
unpow242.8%
*-commutative42.8%
unpow242.8%
swap-sqr42.8%
unpow242.8%
*-commutative42.8%
Simplified42.8%
Final simplification70.6%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (or (<= K 4.8e+58) (and (not (<= K 3.1e+153)) (<= K 2.9e+172))) (* (* -2.0 J) (hypot 1.0 (* 0.5 (/ U J)))) (* (cos (* K 0.5)) (* -2.0 J))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if ((K <= 4.8e+58) || (!(K <= 3.1e+153) && (K <= 2.9e+172))) {
tmp = (-2.0 * J) * hypot(1.0, (0.5 * (U / J)));
} else {
tmp = cos((K * 0.5)) * (-2.0 * J);
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if ((K <= 4.8e+58) || (!(K <= 3.1e+153) && (K <= 2.9e+172))) {
tmp = (-2.0 * J) * Math.hypot(1.0, (0.5 * (U / J)));
} else {
tmp = Math.cos((K * 0.5)) * (-2.0 * J);
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if (K <= 4.8e+58) or (not (K <= 3.1e+153) and (K <= 2.9e+172)): tmp = (-2.0 * J) * math.hypot(1.0, (0.5 * (U / J))) else: tmp = math.cos((K * 0.5)) * (-2.0 * J) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if ((K <= 4.8e+58) || (!(K <= 3.1e+153) && (K <= 2.9e+172))) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(0.5 * Float64(U / J)))); else tmp = Float64(cos(Float64(K * 0.5)) * Float64(-2.0 * J)); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if ((K <= 4.8e+58) || (~((K <= 3.1e+153)) && (K <= 2.9e+172))) tmp = (-2.0 * J) * hypot(1.0, (0.5 * (U / J))); else tmp = cos((K * 0.5)) * (-2.0 * J); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[Or[LessEqual[K, 4.8e+58], And[N[Not[LessEqual[K, 3.1e+153]], $MachinePrecision], LessEqual[K, 2.9e+172]]], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;K \leq 4.8 \cdot 10^{+58} \lor \neg \left(K \leq 3.1 \cdot 10^{+153}\right) \land K \leq 2.9 \cdot 10^{+172}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(-2 \cdot J\right)\\
\end{array}
\end{array}
if K < 4.8e58 or 3.1e153 < K < 2.8999999999999999e172Initial program 72.2%
Taylor expanded in K around 0 38.7%
associate-*r*38.7%
*-commutative38.7%
metadata-eval38.7%
unpow238.7%
unpow238.7%
times-frac55.0%
swap-sqr55.5%
associate-*r/55.5%
*-commutative55.5%
associate-*r/55.4%
associate-*r/55.4%
*-commutative55.4%
associate-*r/55.4%
unpow255.4%
associate-*r/55.5%
*-commutative55.5%
associate-*r/55.5%
Simplified55.5%
expm1-log1p-u54.1%
expm1-udef54.1%
metadata-eval54.1%
unpow254.1%
associate-*r/54.1%
associate-*r/54.1%
hypot-udef65.6%
associate-*r/65.6%
Applied egg-rr65.6%
expm1-def65.6%
expm1-log1p68.5%
Simplified68.5%
if 4.8e58 < K < 3.1e153 or 2.8999999999999999e172 < K Initial program 66.6%
Taylor expanded in J around inf 58.6%
associate-*r*58.6%
*-commutative58.6%
Simplified58.6%
Final simplification66.5%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (cos (* K 0.5)) (* -2.0 J))))
(if (<= J -2.05e-71)
t_0
(if (<= J -4e-310) U (if (<= J 9.4e-26) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K * 0.5)) * (-2.0 * J);
double tmp;
if (J <= -2.05e-71) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 9.4e-26) {
tmp = -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 = cos((k * 0.5d0)) * ((-2.0d0) * j)
if (j <= (-2.05d-71)) then
tmp = t_0
else if (j <= (-4d-310)) then
tmp = u
else if (j <= 9.4d-26) then
tmp = -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 = Math.cos((K * 0.5)) * (-2.0 * J);
double tmp;
if (J <= -2.05e-71) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 9.4e-26) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K * 0.5)) * (-2.0 * J) tmp = 0 if J <= -2.05e-71: tmp = t_0 elif J <= -4e-310: tmp = U elif J <= 9.4e-26: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(cos(Float64(K * 0.5)) * Float64(-2.0 * J)) tmp = 0.0 if (J <= -2.05e-71) tmp = t_0; elseif (J <= -4e-310) tmp = U; elseif (J <= 9.4e-26) tmp = Float64(-U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K * 0.5)) * (-2.0 * J); tmp = 0.0; if (J <= -2.05e-71) tmp = t_0; elseif (J <= -4e-310) tmp = U; elseif (J <= 9.4e-26) tmp = -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[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -2.05e-71], t$95$0, If[LessEqual[J, -4e-310], U, If[LessEqual[J, 9.4e-26], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right) \cdot \left(-2 \cdot J\right)\\
\mathbf{if}\;J \leq -2.05 \cdot 10^{-71}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 9.4 \cdot 10^{-26}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -2.04999999999999997e-71 or 9.39999999999999979e-26 < J Initial program 92.8%
Taylor expanded in J around inf 74.1%
associate-*r*74.1%
*-commutative74.1%
Simplified74.1%
if -2.04999999999999997e-71 < J < -3.999999999999988e-310Initial program 43.6%
Taylor expanded in U around -inf 38.3%
if -3.999999999999988e-310 < J < 9.39999999999999979e-26Initial program 41.1%
Taylor expanded in J around 0 42.7%
neg-mul-142.7%
Simplified42.7%
Final simplification59.8%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (cos (* K 0.5)) (* -2.0 J))))
(if (<= J -1.22e-73)
t_0
(if (<= J -4e-310)
(+ U (/ (* 2.0 (pow J 2.0)) U))
(if (<= J 3.5e-26) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K * 0.5)) * (-2.0 * J);
double tmp;
if (J <= -1.22e-73) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U + ((2.0 * pow(J, 2.0)) / U);
} else if (J <= 3.5e-26) {
tmp = -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 = cos((k * 0.5d0)) * ((-2.0d0) * j)
if (j <= (-1.22d-73)) then
tmp = t_0
else if (j <= (-4d-310)) then
tmp = u + ((2.0d0 * (j ** 2.0d0)) / u)
else if (j <= 3.5d-26) then
tmp = -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 = Math.cos((K * 0.5)) * (-2.0 * J);
double tmp;
if (J <= -1.22e-73) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U + ((2.0 * Math.pow(J, 2.0)) / U);
} else if (J <= 3.5e-26) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K * 0.5)) * (-2.0 * J) tmp = 0 if J <= -1.22e-73: tmp = t_0 elif J <= -4e-310: tmp = U + ((2.0 * math.pow(J, 2.0)) / U) elif J <= 3.5e-26: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(cos(Float64(K * 0.5)) * Float64(-2.0 * J)) tmp = 0.0 if (J <= -1.22e-73) tmp = t_0; elseif (J <= -4e-310) tmp = Float64(U + Float64(Float64(2.0 * (J ^ 2.0)) / U)); elseif (J <= 3.5e-26) tmp = Float64(-U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K * 0.5)) * (-2.0 * J); tmp = 0.0; if (J <= -1.22e-73) tmp = t_0; elseif (J <= -4e-310) tmp = U + ((2.0 * (J ^ 2.0)) / U); elseif (J <= 3.5e-26) tmp = -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[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.22e-73], t$95$0, If[LessEqual[J, -4e-310], N[(U + N[(N[(2.0 * N[Power[J, 2.0], $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 3.5e-26], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right) \cdot \left(-2 \cdot J\right)\\
\mathbf{if}\;J \leq -1.22 \cdot 10^{-73}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U + \frac{2 \cdot {J}^{2}}{U}\\
\mathbf{elif}\;J \leq 3.5 \cdot 10^{-26}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.22e-73 or 3.49999999999999985e-26 < J Initial program 92.8%
Taylor expanded in J around inf 74.1%
associate-*r*74.1%
*-commutative74.1%
Simplified74.1%
if -1.22e-73 < J < -3.999999999999988e-310Initial program 43.6%
Taylor expanded in K around 0 17.6%
associate-*r*17.6%
*-commutative17.6%
metadata-eval17.6%
unpow217.6%
unpow217.6%
times-frac32.0%
swap-sqr32.0%
associate-*r/32.0%
*-commutative32.0%
associate-*r/31.9%
associate-*r/31.9%
*-commutative31.9%
associate-*r/31.9%
unpow231.9%
associate-*r/32.0%
*-commutative32.0%
associate-*r/32.0%
Simplified32.0%
Taylor expanded in U around -inf 38.6%
associate-*r/38.6%
Simplified38.6%
if -3.999999999999988e-310 < J < 3.49999999999999985e-26Initial program 41.1%
Taylor expanded in J around 0 42.7%
neg-mul-142.7%
Simplified42.7%
Final simplification59.9%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -3.1e-37) (* -2.0 J) (if (<= J -4e-310) U (if (<= J 9.2e+82) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -3.1e-37) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 9.2e+82) {
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 <= (-3.1d-37)) then
tmp = (-2.0d0) * j
else if (j <= (-4d-310)) then
tmp = u
else if (j <= 9.2d+82) 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 <= -3.1e-37) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 9.2e+82) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -3.1e-37: tmp = -2.0 * J elif J <= -4e-310: tmp = U elif J <= 9.2e+82: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -3.1e-37) tmp = Float64(-2.0 * J); elseif (J <= -4e-310) tmp = U; elseif (J <= 9.2e+82) 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 <= -3.1e-37) tmp = -2.0 * J; elseif (J <= -4e-310) tmp = U; elseif (J <= 9.2e+82) 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, -3.1e-37], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -4e-310], U, If[LessEqual[J, 9.2e+82], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -3.1 \cdot 10^{-37}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 9.2 \cdot 10^{+82}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -3.09999999999999993e-37 or 9.19999999999999953e82 < J Initial program 97.1%
Taylor expanded in K around 0 45.9%
associate-*r*45.9%
*-commutative45.9%
metadata-eval45.9%
unpow245.9%
unpow245.9%
times-frac59.0%
swap-sqr59.0%
associate-*r/59.0%
*-commutative59.0%
associate-*r/59.0%
associate-*r/59.0%
*-commutative59.0%
associate-*r/59.0%
unpow259.0%
associate-*r/59.0%
*-commutative59.0%
associate-*r/59.0%
Simplified59.0%
Taylor expanded in J around inf 46.8%
*-commutative46.8%
Simplified46.8%
if -3.09999999999999993e-37 < J < -3.999999999999988e-310Initial program 51.1%
Taylor expanded in U around -inf 31.5%
if -3.999999999999988e-310 < J < 9.19999999999999953e82Initial program 52.1%
Taylor expanded in J around 0 40.9%
neg-mul-140.9%
Simplified40.9%
Final simplification41.3%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -4e-310) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -4e-310) {
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 <= (-4d-310)) 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 <= -4e-310) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -4e-310: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -4e-310) 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 <= -4e-310) 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, -4e-310], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -3.999999999999988e-310Initial program 75.6%
Taylor expanded in U around -inf 18.5%
if -3.999999999999988e-310 < J Initial program 66.4%
Taylor expanded in J around 0 30.9%
neg-mul-130.9%
Simplified30.9%
Final simplification24.7%
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 71.0%
Taylor expanded in U around -inf 23.4%
Final simplification23.4%
herbie shell --seed 2023300
(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)))))