
(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 2e+300) 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 <= 2e+300) {
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 <= 2e+300) {
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 <= 2e+300: 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 <= 2e+300) 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 <= 2e+300) 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, 2e+300], 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 2 \cdot 10^{+300}:\\
\;\;\;\;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.1%
Simplified5.1%
Taylor expanded in J around 0 63.6%
neg-mul-163.6%
Simplified63.6%
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)))) < 2.0000000000000001e300Initial program 99.9%
if 2.0000000000000001e300 < (*.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%
Simplified5.9%
Taylor expanded in U around -inf 38.3%
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 (* t_0 (* J (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 * (t_0 * (J * 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 * (t_0 * (J * 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 * (t_0 * (J * 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(t_0 * Float64(J * hypot(1.0, Float64(Float64(U / Float64(J * 2.0)) / t_0))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = -2.0 * (t_0 * (J * 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[(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]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(t_0 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{t_0}\right)\right)\right)
\end{array}
\end{array}
Initial program 75.2%
Simplified91.0%
Final simplification91.0%
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(Float64(J * t_0) * hypot(1.0, Float64(Float64(U / Float64(J * 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[(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]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
-2 \cdot \left(\left(J \cdot t_0\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U}{J \cdot 2}}{t_0}\right)\right)
\end{array}
\end{array}
Initial program 75.2%
associate-*l*75.2%
associate-*l*75.2%
unpow275.2%
hypot-1-def91.1%
associate-/r*91.1%
cos-neg91.1%
distribute-frac-neg91.1%
associate-/r*91.1%
associate-/r*91.1%
distribute-frac-neg91.1%
cos-neg91.1%
Simplified91.1%
Final simplification91.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 4.5e+230) (* -2.0 (* (cos (/ K 2.0)) (* J (hypot 1.0 (/ (* U 0.5) J))))) U))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 4.5e+230) {
tmp = -2.0 * (cos((K / 2.0)) * (J * hypot(1.0, ((U * 0.5) / J))));
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 4.5e+230) {
tmp = -2.0 * (Math.cos((K / 2.0)) * (J * Math.hypot(1.0, ((U * 0.5) / J))));
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 4.5e+230: tmp = -2.0 * (math.cos((K / 2.0)) * (J * math.hypot(1.0, ((U * 0.5) / J)))) else: tmp = U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 4.5e+230) tmp = Float64(-2.0 * Float64(cos(Float64(K / 2.0)) * Float64(J * hypot(1.0, Float64(Float64(U * 0.5) / J))))); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 4.5e+230) tmp = -2.0 * (cos((K / 2.0)) * (J * hypot(1.0, ((U * 0.5) / J)))); else tmp = U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 4.5e+230], N[(-2.0 * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 4.5 \cdot 10^{+230}:\\
\;\;\;\;-2 \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{U \cdot 0.5}{J}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if U < 4.4999999999999999e230Initial program 77.3%
Simplified92.1%
Taylor expanded in K around 0 76.9%
associate-*r/76.9%
Simplified76.9%
if 4.4999999999999999e230 < U Initial program 31.6%
Simplified31.4%
Taylor expanded in U around -inf 66.7%
Final simplification76.4%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (* (* -2.0 J) t_0))
(t_2 (* (* -2.0 J) (hypot 1.0 (* 0.5 (/ U J))))))
(if (<= K 800000.0)
t_2
(if (<= K 5.7e+20)
t_1
(if (<= K 4.8e+34)
U
(if (<= K 2.4e+241)
t_1
(if (<= K 1.4e+255)
t_2
(+ (* -2.0 (* J t_0)) (* -0.25 (* U (/ U J)))))))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = (-2.0 * J) * t_0;
double t_2 = (-2.0 * J) * hypot(1.0, (0.5 * (U / J)));
double tmp;
if (K <= 800000.0) {
tmp = t_2;
} else if (K <= 5.7e+20) {
tmp = t_1;
} else if (K <= 4.8e+34) {
tmp = U;
} else if (K <= 2.4e+241) {
tmp = t_1;
} else if (K <= 1.4e+255) {
tmp = t_2;
} else {
tmp = (-2.0 * (J * t_0)) + (-0.25 * (U * (U / J)));
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K * 0.5));
double t_1 = (-2.0 * J) * t_0;
double t_2 = (-2.0 * J) * Math.hypot(1.0, (0.5 * (U / J)));
double tmp;
if (K <= 800000.0) {
tmp = t_2;
} else if (K <= 5.7e+20) {
tmp = t_1;
} else if (K <= 4.8e+34) {
tmp = U;
} else if (K <= 2.4e+241) {
tmp = t_1;
} else if (K <= 1.4e+255) {
tmp = t_2;
} else {
tmp = (-2.0 * (J * t_0)) + (-0.25 * (U * (U / J)));
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K * 0.5)) t_1 = (-2.0 * J) * t_0 t_2 = (-2.0 * J) * math.hypot(1.0, (0.5 * (U / J))) tmp = 0 if K <= 800000.0: tmp = t_2 elif K <= 5.7e+20: tmp = t_1 elif K <= 4.8e+34: tmp = U elif K <= 2.4e+241: tmp = t_1 elif K <= 1.4e+255: tmp = t_2 else: tmp = (-2.0 * (J * t_0)) + (-0.25 * (U * (U / J))) return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(Float64(-2.0 * J) * t_0) t_2 = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(0.5 * Float64(U / J)))) tmp = 0.0 if (K <= 800000.0) tmp = t_2; elseif (K <= 5.7e+20) tmp = t_1; elseif (K <= 4.8e+34) tmp = U; elseif (K <= 2.4e+241) tmp = t_1; elseif (K <= 1.4e+255) tmp = t_2; else tmp = Float64(Float64(-2.0 * Float64(J * t_0)) + Float64(-0.25 * Float64(U * Float64(U / J)))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K * 0.5)); t_1 = (-2.0 * J) * t_0; t_2 = (-2.0 * J) * hypot(1.0, (0.5 * (U / J))); tmp = 0.0; if (K <= 800000.0) tmp = t_2; elseif (K <= 5.7e+20) tmp = t_1; elseif (K <= 4.8e+34) tmp = U; elseif (K <= 2.4e+241) tmp = t_1; elseif (K <= 1.4e+255) tmp = t_2; else tmp = (-2.0 * (J * t_0)) + (-0.25 * (U * (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[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[K, 800000.0], t$95$2, If[LessEqual[K, 5.7e+20], t$95$1, If[LessEqual[K, 4.8e+34], U, If[LessEqual[K, 2.4e+241], t$95$1, If[LessEqual[K, 1.4e+255], t$95$2, N[(N[(-2.0 * N[(J * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(U * N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := \left(-2 \cdot J\right) \cdot t_0\\
t_2 := \left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\\
\mathbf{if}\;K \leq 800000:\\
\;\;\;\;t_2\\
\mathbf{elif}\;K \leq 5.7 \cdot 10^{+20}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;K \leq 4.8 \cdot 10^{+34}:\\
\;\;\;\;U\\
\mathbf{elif}\;K \leq 2.4 \cdot 10^{+241}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;K \leq 1.4 \cdot 10^{+255}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot t_0\right) + -0.25 \cdot \left(U \cdot \frac{U}{J}\right)\\
\end{array}
\end{array}
if K < 8e5 or 2.3999999999999999e241 < K < 1.40000000000000007e255Initial program 73.1%
Simplified73.0%
Taylor expanded in K around 0 39.2%
associate-*r*39.2%
*-commutative39.2%
metadata-eval39.2%
unpow239.2%
unpow239.2%
times-frac52.4%
swap-sqr52.9%
associate-*r/52.9%
*-commutative52.9%
associate-*r/52.9%
associate-*r/52.9%
*-commutative52.9%
associate-*r/52.9%
unpow252.9%
associate-*r/52.9%
*-commutative52.9%
associate-*r/52.9%
Simplified52.9%
expm1-log1p-u51.8%
expm1-udef51.8%
metadata-eval51.8%
unpow251.8%
associate-*r/51.8%
associate-*r/51.8%
hypot-udef65.8%
associate-/l*65.8%
Applied egg-rr65.8%
expm1-def65.8%
expm1-log1p68.6%
associate-/l*68.7%
associate-*r/68.7%
Simplified68.7%
if 8e5 < K < 5.7e20 or 4.79999999999999974e34 < K < 2.3999999999999999e241Initial program 81.2%
Simplified81.2%
Taylor expanded in J around inf 57.0%
associate-*r*57.0%
*-commutative57.0%
Simplified57.0%
if 5.7e20 < K < 4.79999999999999974e34Initial program 62.8%
Simplified62.5%
Taylor expanded in U around -inf 20.8%
if 1.40000000000000007e255 < K Initial program 85.0%
Simplified84.9%
Taylor expanded in J around inf 50.9%
Taylor expanded in K around 0 50.3%
div-inv9.1%
unpow29.1%
associate-*l*10.2%
div-inv10.2%
Applied egg-rr60.2%
Final simplification65.1%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (* -2.0 J) (cos (* K 0.5))))
(t_1 (* (* -2.0 J) (hypot 1.0 (* 0.5 (/ U J))))))
(if (<= K 800000.0)
t_1
(if (<= K 3.5e+20)
t_0
(if (<= K 4.8e+34)
U
(if (or (<= K 1.5e+241) (not (<= K 1.85e+254))) t_0 t_1))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = (-2.0 * J) * cos((K * 0.5));
double t_1 = (-2.0 * J) * hypot(1.0, (0.5 * (U / J)));
double tmp;
if (K <= 800000.0) {
tmp = t_1;
} else if (K <= 3.5e+20) {
tmp = t_0;
} else if (K <= 4.8e+34) {
tmp = U;
} else if ((K <= 1.5e+241) || !(K <= 1.85e+254)) {
tmp = t_0;
} else {
tmp = t_1;
}
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 * 0.5));
double t_1 = (-2.0 * J) * Math.hypot(1.0, (0.5 * (U / J)));
double tmp;
if (K <= 800000.0) {
tmp = t_1;
} else if (K <= 3.5e+20) {
tmp = t_0;
} else if (K <= 4.8e+34) {
tmp = U;
} else if ((K <= 1.5e+241) || !(K <= 1.85e+254)) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = (-2.0 * J) * math.cos((K * 0.5)) t_1 = (-2.0 * J) * math.hypot(1.0, (0.5 * (U / J))) tmp = 0 if K <= 800000.0: tmp = t_1 elif K <= 3.5e+20: tmp = t_0 elif K <= 4.8e+34: tmp = U elif (K <= 1.5e+241) or not (K <= 1.85e+254): tmp = t_0 else: tmp = t_1 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) t_1 = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(0.5 * Float64(U / J)))) tmp = 0.0 if (K <= 800000.0) tmp = t_1; elseif (K <= 3.5e+20) tmp = t_0; elseif (K <= 4.8e+34) tmp = U; elseif ((K <= 1.5e+241) || !(K <= 1.85e+254)) tmp = t_0; else tmp = t_1; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = (-2.0 * J) * cos((K * 0.5)); t_1 = (-2.0 * J) * hypot(1.0, (0.5 * (U / J))); tmp = 0.0; if (K <= 800000.0) tmp = t_1; elseif (K <= 3.5e+20) tmp = t_0; elseif (K <= 4.8e+34) tmp = U; elseif ((K <= 1.5e+241) || ~((K <= 1.85e+254))) tmp = t_0; 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[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[K, 800000.0], t$95$1, If[LessEqual[K, 3.5e+20], t$95$0, If[LessEqual[K, 4.8e+34], U, If[Or[LessEqual[K, 1.5e+241], N[Not[LessEqual[K, 1.85e+254]], $MachinePrecision]], t$95$0, t$95$1]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
t_1 := \left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\\
\mathbf{if}\;K \leq 800000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;K \leq 3.5 \cdot 10^{+20}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;K \leq 4.8 \cdot 10^{+34}:\\
\;\;\;\;U\\
\mathbf{elif}\;K \leq 1.5 \cdot 10^{+241} \lor \neg \left(K \leq 1.85 \cdot 10^{+254}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if K < 8e5 or 1.50000000000000008e241 < K < 1.8499999999999999e254Initial program 73.1%
Simplified73.0%
Taylor expanded in K around 0 39.2%
associate-*r*39.2%
*-commutative39.2%
metadata-eval39.2%
unpow239.2%
unpow239.2%
times-frac52.4%
swap-sqr52.9%
associate-*r/52.9%
*-commutative52.9%
associate-*r/52.9%
associate-*r/52.9%
*-commutative52.9%
associate-*r/52.9%
unpow252.9%
associate-*r/52.9%
*-commutative52.9%
associate-*r/52.9%
Simplified52.9%
expm1-log1p-u51.8%
expm1-udef51.8%
metadata-eval51.8%
unpow251.8%
associate-*r/51.8%
associate-*r/51.8%
hypot-udef65.8%
associate-/l*65.8%
Applied egg-rr65.8%
expm1-def65.8%
expm1-log1p68.6%
associate-/l*68.7%
associate-*r/68.7%
Simplified68.7%
if 8e5 < K < 3.5e20 or 4.79999999999999974e34 < K < 1.50000000000000008e241 or 1.8499999999999999e254 < K Initial program 82.3%
Simplified82.3%
Taylor expanded in J around inf 57.9%
associate-*r*57.9%
*-commutative57.9%
Simplified57.9%
if 3.5e20 < K < 4.79999999999999974e34Initial program 62.8%
Simplified62.5%
Taylor expanded in U around -inf 20.8%
Final simplification65.1%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (* -2.0 J) (cos (* K 0.5)))))
(if (<= J -1.36e-90)
t_0
(if (<= J 1.55e-289) U (if (<= J 4.6e+14) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = (-2.0 * J) * cos((K * 0.5));
double tmp;
if (J <= -1.36e-90) {
tmp = t_0;
} else if (J <= 1.55e-289) {
tmp = U;
} else if (J <= 4.6e+14) {
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 = ((-2.0d0) * j) * cos((k * 0.5d0))
if (j <= (-1.36d-90)) then
tmp = t_0
else if (j <= 1.55d-289) then
tmp = u
else if (j <= 4.6d+14) 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 = (-2.0 * J) * Math.cos((K * 0.5));
double tmp;
if (J <= -1.36e-90) {
tmp = t_0;
} else if (J <= 1.55e-289) {
tmp = U;
} else if (J <= 4.6e+14) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = (-2.0 * J) * math.cos((K * 0.5)) tmp = 0 if J <= -1.36e-90: tmp = t_0 elif J <= 1.55e-289: tmp = U elif J <= 4.6e+14: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) tmp = 0.0 if (J <= -1.36e-90) tmp = t_0; elseif (J <= 1.55e-289) tmp = U; elseif (J <= 4.6e+14) tmp = Float64(-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 * 0.5)); tmp = 0.0; if (J <= -1.36e-90) tmp = t_0; elseif (J <= 1.55e-289) tmp = U; elseif (J <= 4.6e+14) 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[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.36e-90], t$95$0, If[LessEqual[J, 1.55e-289], U, If[LessEqual[J, 4.6e+14], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq -1.36 \cdot 10^{-90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 1.55 \cdot 10^{-289}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 4.6 \cdot 10^{+14}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.36000000000000011e-90 or 4.6e14 < J Initial program 91.8%
Simplified91.8%
Taylor expanded in J around inf 75.4%
associate-*r*75.4%
*-commutative75.4%
Simplified75.4%
if -1.36000000000000011e-90 < J < 1.55e-289Initial program 57.5%
Simplified57.4%
Taylor expanded in U around -inf 34.1%
if 1.55e-289 < J < 4.6e14Initial program 47.8%
Simplified47.7%
Taylor expanded in J around 0 47.4%
neg-mul-147.4%
Simplified47.4%
Final simplification61.3%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (+ (* -2.0 J) (* -0.25 (* U (/ U J))))))
(if (<= J -1.75e+57)
t_0
(if (<= J 1.55e-289) U (if (<= J 1.5e+30) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = (-2.0 * J) + (-0.25 * (U * (U / J)));
double tmp;
if (J <= -1.75e+57) {
tmp = t_0;
} else if (J <= 1.55e-289) {
tmp = U;
} else if (J <= 1.5e+30) {
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 = ((-2.0d0) * j) + ((-0.25d0) * (u * (u / j)))
if (j <= (-1.75d+57)) then
tmp = t_0
else if (j <= 1.55d-289) then
tmp = u
else if (j <= 1.5d+30) 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 = (-2.0 * J) + (-0.25 * (U * (U / J)));
double tmp;
if (J <= -1.75e+57) {
tmp = t_0;
} else if (J <= 1.55e-289) {
tmp = U;
} else if (J <= 1.5e+30) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = (-2.0 * J) + (-0.25 * (U * (U / J))) tmp = 0 if J <= -1.75e+57: tmp = t_0 elif J <= 1.55e-289: tmp = U elif J <= 1.5e+30: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(Float64(-2.0 * J) + Float64(-0.25 * Float64(U * Float64(U / J)))) tmp = 0.0 if (J <= -1.75e+57) tmp = t_0; elseif (J <= 1.55e-289) tmp = U; elseif (J <= 1.5e+30) tmp = Float64(-U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = (-2.0 * J) + (-0.25 * (U * (U / J))); tmp = 0.0; if (J <= -1.75e+57) tmp = t_0; elseif (J <= 1.55e-289) tmp = U; elseif (J <= 1.5e+30) 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[(-2.0 * J), $MachinePrecision] + N[(-0.25 * N[(U * N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.75e+57], t$95$0, If[LessEqual[J, 1.55e-289], U, If[LessEqual[J, 1.5e+30], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot J + -0.25 \cdot \left(U \cdot \frac{U}{J}\right)\\
\mathbf{if}\;J \leq -1.75 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 1.55 \cdot 10^{-289}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.5 \cdot 10^{+30}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.7499999999999999e57 or 1.49999999999999989e30 < J Initial program 98.2%
Simplified98.2%
Taylor expanded in K around 0 44.5%
associate-*r*44.5%
*-commutative44.5%
metadata-eval44.5%
unpow244.5%
unpow244.5%
times-frac55.5%
swap-sqr55.5%
associate-*r/55.5%
*-commutative55.5%
associate-*r/55.5%
associate-*r/55.5%
*-commutative55.5%
associate-*r/55.5%
unpow255.5%
associate-*r/55.5%
*-commutative55.5%
associate-*r/55.5%
Simplified55.5%
Taylor expanded in J around inf 42.6%
div-inv42.6%
unpow242.6%
associate-*l*46.6%
div-inv46.6%
Applied egg-rr46.6%
if -1.7499999999999999e57 < J < 1.55e-289Initial program 65.2%
Simplified65.1%
Taylor expanded in U around -inf 27.4%
if 1.55e-289 < J < 1.49999999999999989e30Initial program 49.4%
Simplified49.4%
Taylor expanded in J around 0 45.9%
neg-mul-145.9%
Simplified45.9%
Final simplification39.9%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2.65e+57) (* -2.0 J) (if (<= J 1.55e-289) U (if (<= J 1e+29) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2.65e+57) {
tmp = -2.0 * J;
} else if (J <= 1.55e-289) {
tmp = U;
} else if (J <= 1e+29) {
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 <= (-2.65d+57)) then
tmp = (-2.0d0) * j
else if (j <= 1.55d-289) then
tmp = u
else if (j <= 1d+29) 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 <= -2.65e+57) {
tmp = -2.0 * J;
} else if (J <= 1.55e-289) {
tmp = U;
} else if (J <= 1e+29) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2.65e+57: tmp = -2.0 * J elif J <= 1.55e-289: tmp = U elif J <= 1e+29: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2.65e+57) tmp = Float64(-2.0 * J); elseif (J <= 1.55e-289) tmp = U; elseif (J <= 1e+29) 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 <= -2.65e+57) tmp = -2.0 * J; elseif (J <= 1.55e-289) tmp = U; elseif (J <= 1e+29) 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, -2.65e+57], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, 1.55e-289], U, If[LessEqual[J, 1e+29], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.65 \cdot 10^{+57}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq 1.55 \cdot 10^{-289}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 10^{+29}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -2.64999999999999993e57 or 9.99999999999999914e28 < J Initial program 98.2%
Simplified98.2%
Taylor expanded in K around 0 44.5%
associate-*r*44.5%
*-commutative44.5%
metadata-eval44.5%
unpow244.5%
unpow244.5%
times-frac55.5%
swap-sqr55.5%
associate-*r/55.5%
*-commutative55.5%
associate-*r/55.5%
associate-*r/55.5%
*-commutative55.5%
associate-*r/55.5%
unpow255.5%
associate-*r/55.5%
*-commutative55.5%
associate-*r/55.5%
Simplified55.5%
Taylor expanded in J around inf 46.3%
*-commutative46.3%
Simplified46.3%
if -2.64999999999999993e57 < J < 1.55e-289Initial program 65.2%
Simplified65.1%
Taylor expanded in U around -inf 27.4%
if 1.55e-289 < J < 9.99999999999999914e28Initial program 49.4%
Simplified49.4%
Taylor expanded in J around 0 45.9%
neg-mul-145.9%
Simplified45.9%
Final simplification39.8%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J 1.55e-289) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= 1.55e-289) {
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 <= 1.55d-289) 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 <= 1.55e-289) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= 1.55e-289: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= 1.55e-289) 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 <= 1.55e-289) 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, 1.55e-289], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq 1.55 \cdot 10^{-289}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < 1.55e-289Initial program 77.1%
Simplified77.0%
Taylor expanded in U around -inf 21.8%
if 1.55e-289 < J Initial program 73.1%
Simplified73.0%
Taylor expanded in J around 0 27.8%
neg-mul-127.8%
Simplified27.8%
Final simplification24.6%
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 75.2%
Simplified75.1%
Taylor expanded in U around -inf 21.5%
Final simplification21.5%
herbie shell --seed 2023318
(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)))))