
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}
\end{array}
\end{array}
U_m = (fabs.f64 U)
J\_m = (fabs.f64 J)
J\_s = (copysign.f64 #s(literal 1 binary64) J)
(FPCore (J_s J_m K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* t_0 (* -2.0 J_m))
(sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J_m 2.0))) 2.0))))))
(* J_s (if (<= t_1 (- INFINITY)) (- U_m) (if (<= t_1 1e+293) t_1 U_m)))))U_m = fabs(U);
J\_m = fabs(J);
J\_s = copysign(1.0, J);
double code(double J_s, double J_m, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = (t_0 * (-2.0 * J_m)) * sqrt((1.0 + pow((U_m / (t_0 * (J_m * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_1 <= 1e+293) {
tmp = t_1;
} else {
tmp = U_m;
}
return J_s * tmp;
}
U_m = Math.abs(U);
J\_m = Math.abs(J);
J\_s = Math.copySign(1.0, J);
public static double code(double J_s, double J_m, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
double t_1 = (t_0 * (-2.0 * J_m)) * Math.sqrt((1.0 + Math.pow((U_m / (t_0 * (J_m * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U_m;
} else if (t_1 <= 1e+293) {
tmp = t_1;
} else {
tmp = U_m;
}
return J_s * tmp;
}
U_m = math.fabs(U) J\_m = math.fabs(J) J\_s = math.copysign(1.0, J) def code(J_s, J_m, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = (t_0 * (-2.0 * J_m)) * math.sqrt((1.0 + math.pow((U_m / (t_0 * (J_m * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U_m elif t_1 <= 1e+293: tmp = t_1 else: tmp = U_m return J_s * tmp
U_m = abs(U) J\_m = abs(J) J\_s = copysign(1.0, J) function code(J_s, J_m, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(t_0 * Float64(-2.0 * J_m)) * sqrt(Float64(1.0 + (Float64(U_m / Float64(t_0 * Float64(J_m * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_1 <= 1e+293) tmp = t_1; else tmp = U_m; end return Float64(J_s * tmp) end
U_m = abs(U); J\_m = abs(J); J\_s = sign(J) * abs(1.0); function tmp_2 = code(J_s, J_m, K, U_m) t_0 = cos((K / 2.0)); t_1 = (t_0 * (-2.0 * J_m)) * sqrt((1.0 + ((U_m / (t_0 * (J_m * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U_m; elseif (t_1 <= 1e+293) tmp = t_1; else tmp = U_m; end tmp_2 = J_s * tmp; end
U_m = N[Abs[U], $MachinePrecision]
J\_m = N[Abs[J], $MachinePrecision]
J\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[J]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[J$95$s_, J$95$m_, K_, U$95$m_] := 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$95$m), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U$95$m / N[(t$95$0 * N[(J$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(J$95$s * If[LessEqual[t$95$1, (-Infinity)], (-U$95$m), If[LessEqual[t$95$1, 1e+293], t$95$1, U$95$m]]), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
J\_m = \left|J\right|
\\
J\_s = \mathsf{copysign}\left(1, J\right)
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(t\_0 \cdot \left(-2 \cdot J\_m\right)\right) \cdot \sqrt{1 + {\left(\frac{U\_m}{t\_0 \cdot \left(J\_m \cdot 2\right)}\right)}^{2}}\\
J\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_1 \leq 10^{+293}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < -inf.0Initial program 5.7%
Simplified55.2%
Taylor expanded in J around 0 45.6%
neg-mul-145.6%
Simplified45.6%
if -inf.0 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < 9.9999999999999992e292Initial program 99.8%
if 9.9999999999999992e292 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) Initial program 14.8%
Simplified57.4%
Taylor expanded in U around -inf 49.0%
Final simplification84.0%
U_m = (fabs.f64 U)
J\_m = (fabs.f64 J)
J\_s = (copysign.f64 #s(literal 1 binary64) J)
(FPCore (J_s J_m K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(*
J_s
(if (<= U_m 1.4e+260)
(* J_m (* (* -2.0 t_0) (hypot 1.0 (/ (/ U_m 2.0) (* J_m t_0)))))
(- U_m)))))U_m = fabs(U);
J\_m = fabs(J);
J\_s = copysign(1.0, J);
double code(double J_s, double J_m, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (U_m <= 1.4e+260) {
tmp = J_m * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J_m * t_0))));
} else {
tmp = -U_m;
}
return J_s * tmp;
}
U_m = Math.abs(U);
J\_m = Math.abs(J);
J\_s = Math.copySign(1.0, J);
public static double code(double J_s, double J_m, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (U_m <= 1.4e+260) {
tmp = J_m * ((-2.0 * t_0) * Math.hypot(1.0, ((U_m / 2.0) / (J_m * t_0))));
} else {
tmp = -U_m;
}
return J_s * tmp;
}
U_m = math.fabs(U) J\_m = math.fabs(J) J\_s = math.copysign(1.0, J) def code(J_s, J_m, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if U_m <= 1.4e+260: tmp = J_m * ((-2.0 * t_0) * math.hypot(1.0, ((U_m / 2.0) / (J_m * t_0)))) else: tmp = -U_m return J_s * tmp
U_m = abs(U) J\_m = abs(J) J\_s = copysign(1.0, J) function code(J_s, J_m, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (U_m <= 1.4e+260) tmp = Float64(J_m * Float64(Float64(-2.0 * t_0) * hypot(1.0, Float64(Float64(U_m / 2.0) / Float64(J_m * t_0))))); else tmp = Float64(-U_m); end return Float64(J_s * tmp) end
U_m = abs(U); J\_m = abs(J); J\_s = sign(J) * abs(1.0); function tmp_2 = code(J_s, J_m, K, U_m) t_0 = cos((K / 2.0)); tmp = 0.0; if (U_m <= 1.4e+260) tmp = J_m * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J_m * t_0)))); else tmp = -U_m; end tmp_2 = J_s * tmp; end
U_m = N[Abs[U], $MachinePrecision]
J\_m = N[Abs[J], $MachinePrecision]
J\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[J]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[J$95$s_, J$95$m_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(J$95$s * If[LessEqual[U$95$m, 1.4e+260], N[(J$95$m * N[(N[(-2.0 * t$95$0), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / N[(J$95$m * t$95$0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
J\_m = \left|J\right|
\\
J\_s = \mathsf{copysign}\left(1, J\right)
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
J\_s \cdot \begin{array}{l}
\mathbf{if}\;U\_m \leq 1.4 \cdot 10^{+260}:\\
\;\;\;\;J\_m \cdot \left(\left(-2 \cdot t\_0\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J\_m \cdot t\_0}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
\end{array}
if U < 1.3999999999999999e260Initial program 75.3%
Simplified88.1%
if 1.3999999999999999e260 < U Initial program 28.5%
Simplified61.0%
Taylor expanded in J around 0 50.0%
neg-mul-150.0%
Simplified50.0%
U_m = (fabs.f64 U)
J\_m = (fabs.f64 J)
J\_s = (copysign.f64 #s(literal 1 binary64) J)
(FPCore (J_s J_m K U_m)
:precision binary64
(*
J_s
(if (<= U_m 9.2e+126)
(* J_m (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J_m))))
(- U_m))))U_m = fabs(U);
J\_m = fabs(J);
J\_s = copysign(1.0, J);
double code(double J_s, double J_m, double K, double U_m) {
double tmp;
if (U_m <= 9.2e+126) {
tmp = J_m * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J_m)));
} else {
tmp = -U_m;
}
return J_s * tmp;
}
U_m = Math.abs(U);
J\_m = Math.abs(J);
J\_s = Math.copySign(1.0, J);
public static double code(double J_s, double J_m, double K, double U_m) {
double tmp;
if (U_m <= 9.2e+126) {
tmp = J_m * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 2.0) / J_m)));
} else {
tmp = -U_m;
}
return J_s * tmp;
}
U_m = math.fabs(U) J\_m = math.fabs(J) J\_s = math.copysign(1.0, J) def code(J_s, J_m, K, U_m): tmp = 0 if U_m <= 9.2e+126: tmp = J_m * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 2.0) / J_m))) else: tmp = -U_m return J_s * tmp
U_m = abs(U) J\_m = abs(J) J\_s = copysign(1.0, J) function code(J_s, J_m, K, U_m) tmp = 0.0 if (U_m <= 9.2e+126) tmp = Float64(J_m * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J_m)))); else tmp = Float64(-U_m); end return Float64(J_s * tmp) end
U_m = abs(U); J\_m = abs(J); J\_s = sign(J) * abs(1.0); function tmp_2 = code(J_s, J_m, K, U_m) tmp = 0.0; if (U_m <= 9.2e+126) tmp = J_m * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J_m))); else tmp = -U_m; end tmp_2 = J_s * tmp; end
U_m = N[Abs[U], $MachinePrecision]
J\_m = N[Abs[J], $MachinePrecision]
J\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[J]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[J$95$s_, J$95$m_, K_, U$95$m_] := N[(J$95$s * If[LessEqual[U$95$m, 9.2e+126], N[(J$95$m * N[(N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / J$95$m), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]), $MachinePrecision]
\begin{array}{l}
U_m = \left|U\right|
\\
J\_m = \left|J\right|
\\
J\_s = \mathsf{copysign}\left(1, J\right)
\\
J\_s \cdot \begin{array}{l}
\mathbf{if}\;U\_m \leq 9.2 \cdot 10^{+126}:\\
\;\;\;\;J\_m \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 9.2000000000000002e126Initial program 79.5%
Simplified90.3%
Taylor expanded in K around 0 76.5%
if 9.2000000000000002e126 < U Initial program 43.7%
Simplified70.8%
Taylor expanded in J around 0 48.6%
neg-mul-148.6%
Simplified48.6%
U_m = (fabs.f64 U)
J\_m = (fabs.f64 J)
J\_s = (copysign.f64 #s(literal 1 binary64) J)
(FPCore (J_s J_m K U_m)
:precision binary64
(*
J_s
(if (<= U_m 230000000.0)
(* J_m (* -2.0 (cos (* K 0.5))))
(if (<= U_m 2.2e+128)
(* (* -2.0 J_m) (hypot 1.0 (/ (* U_m 0.5) J_m)))
(- U_m)))))U_m = fabs(U);
J\_m = fabs(J);
J\_s = copysign(1.0, J);
double code(double J_s, double J_m, double K, double U_m) {
double tmp;
if (U_m <= 230000000.0) {
tmp = J_m * (-2.0 * cos((K * 0.5)));
} else if (U_m <= 2.2e+128) {
tmp = (-2.0 * J_m) * hypot(1.0, ((U_m * 0.5) / J_m));
} else {
tmp = -U_m;
}
return J_s * tmp;
}
U_m = Math.abs(U);
J\_m = Math.abs(J);
J\_s = Math.copySign(1.0, J);
public static double code(double J_s, double J_m, double K, double U_m) {
double tmp;
if (U_m <= 230000000.0) {
tmp = J_m * (-2.0 * Math.cos((K * 0.5)));
} else if (U_m <= 2.2e+128) {
tmp = (-2.0 * J_m) * Math.hypot(1.0, ((U_m * 0.5) / J_m));
} else {
tmp = -U_m;
}
return J_s * tmp;
}
U_m = math.fabs(U) J\_m = math.fabs(J) J\_s = math.copysign(1.0, J) def code(J_s, J_m, K, U_m): tmp = 0 if U_m <= 230000000.0: tmp = J_m * (-2.0 * math.cos((K * 0.5))) elif U_m <= 2.2e+128: tmp = (-2.0 * J_m) * math.hypot(1.0, ((U_m * 0.5) / J_m)) else: tmp = -U_m return J_s * tmp
U_m = abs(U) J\_m = abs(J) J\_s = copysign(1.0, J) function code(J_s, J_m, K, U_m) tmp = 0.0 if (U_m <= 230000000.0) tmp = Float64(J_m * Float64(-2.0 * cos(Float64(K * 0.5)))); elseif (U_m <= 2.2e+128) tmp = Float64(Float64(-2.0 * J_m) * hypot(1.0, Float64(Float64(U_m * 0.5) / J_m))); else tmp = Float64(-U_m); end return Float64(J_s * tmp) end
U_m = abs(U); J\_m = abs(J); J\_s = sign(J) * abs(1.0); function tmp_2 = code(J_s, J_m, K, U_m) tmp = 0.0; if (U_m <= 230000000.0) tmp = J_m * (-2.0 * cos((K * 0.5))); elseif (U_m <= 2.2e+128) tmp = (-2.0 * J_m) * hypot(1.0, ((U_m * 0.5) / J_m)); else tmp = -U_m; end tmp_2 = J_s * tmp; end
U_m = N[Abs[U], $MachinePrecision]
J\_m = N[Abs[J], $MachinePrecision]
J\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[J]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[J$95$s_, J$95$m_, K_, U$95$m_] := N[(J$95$s * If[LessEqual[U$95$m, 230000000.0], N[(J$95$m * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 2.2e+128], N[(N[(-2.0 * J$95$m), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m * 0.5), $MachinePrecision] / J$95$m), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], (-U$95$m)]]), $MachinePrecision]
\begin{array}{l}
U_m = \left|U\right|
\\
J\_m = \left|J\right|
\\
J\_s = \mathsf{copysign}\left(1, J\right)
\\
J\_s \cdot \begin{array}{l}
\mathbf{if}\;U\_m \leq 230000000:\\
\;\;\;\;J\_m \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{elif}\;U\_m \leq 2.2 \cdot 10^{+128}:\\
\;\;\;\;\left(-2 \cdot J\_m\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m \cdot 0.5}{J\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 2.3e8Initial program 80.0%
Simplified89.9%
Taylor expanded in U around 0 58.1%
if 2.3e8 < U < 2.20000000000000017e128Initial program 74.5%
*-commutative74.5%
associate-*l*74.5%
unpow274.5%
hypot-1-def94.9%
associate-/r*94.7%
cos-neg94.7%
distribute-frac-neg94.7%
associate-/r*94.9%
associate-/r*94.7%
*-commutative94.7%
distribute-frac-neg94.7%
cos-neg94.7%
Simplified94.7%
log1p-expm1-u94.5%
div-inv94.5%
metadata-eval94.5%
Applied egg-rr94.5%
expm1-log1p-u94.4%
log1p-expm1-u94.6%
expm1-undefine94.6%
log1p-undefine94.7%
rem-exp-log94.7%
+-commutative94.7%
Applied egg-rr94.7%
Taylor expanded in K around 0 74.6%
*-commutative74.6%
associate-*l/74.6%
Simplified74.6%
Taylor expanded in K around 0 65.8%
*-commutative65.8%
Simplified65.8%
if 2.20000000000000017e128 < U Initial program 43.7%
Simplified70.8%
Taylor expanded in J around 0 48.6%
neg-mul-148.6%
Simplified48.6%
Final simplification56.9%
U_m = (fabs.f64 U)
J\_m = (fabs.f64 J)
J\_s = (copysign.f64 #s(literal 1 binary64) J)
(FPCore (J_s J_m K U_m)
:precision binary64
(*
J_s
(if (<= U_m 4200000000.0)
(* J_m (* -2.0 (cos (* K 0.5))))
(- (* J_m (* J_m (/ -2.0 U_m))) U_m))))U_m = fabs(U);
J\_m = fabs(J);
J\_s = copysign(1.0, J);
double code(double J_s, double J_m, double K, double U_m) {
double tmp;
if (U_m <= 4200000000.0) {
tmp = J_m * (-2.0 * cos((K * 0.5)));
} else {
tmp = (J_m * (J_m * (-2.0 / U_m))) - U_m;
}
return J_s * tmp;
}
U_m = abs(u)
J\_m = abs(j)
J\_s = copysign(1.0d0, j)
real(8) function code(j_s, j_m, k, u_m)
real(8), intent (in) :: j_s
real(8), intent (in) :: j_m
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: tmp
if (u_m <= 4200000000.0d0) then
tmp = j_m * ((-2.0d0) * cos((k * 0.5d0)))
else
tmp = (j_m * (j_m * ((-2.0d0) / u_m))) - u_m
end if
code = j_s * tmp
end function
U_m = Math.abs(U);
J\_m = Math.abs(J);
J\_s = Math.copySign(1.0, J);
public static double code(double J_s, double J_m, double K, double U_m) {
double tmp;
if (U_m <= 4200000000.0) {
tmp = J_m * (-2.0 * Math.cos((K * 0.5)));
} else {
tmp = (J_m * (J_m * (-2.0 / U_m))) - U_m;
}
return J_s * tmp;
}
U_m = math.fabs(U) J\_m = math.fabs(J) J\_s = math.copysign(1.0, J) def code(J_s, J_m, K, U_m): tmp = 0 if U_m <= 4200000000.0: tmp = J_m * (-2.0 * math.cos((K * 0.5))) else: tmp = (J_m * (J_m * (-2.0 / U_m))) - U_m return J_s * tmp
U_m = abs(U) J\_m = abs(J) J\_s = copysign(1.0, J) function code(J_s, J_m, K, U_m) tmp = 0.0 if (U_m <= 4200000000.0) tmp = Float64(J_m * Float64(-2.0 * cos(Float64(K * 0.5)))); else tmp = Float64(Float64(J_m * Float64(J_m * Float64(-2.0 / U_m))) - U_m); end return Float64(J_s * tmp) end
U_m = abs(U); J\_m = abs(J); J\_s = sign(J) * abs(1.0); function tmp_2 = code(J_s, J_m, K, U_m) tmp = 0.0; if (U_m <= 4200000000.0) tmp = J_m * (-2.0 * cos((K * 0.5))); else tmp = (J_m * (J_m * (-2.0 / U_m))) - U_m; end tmp_2 = J_s * tmp; end
U_m = N[Abs[U], $MachinePrecision]
J\_m = N[Abs[J], $MachinePrecision]
J\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[J]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[J$95$s_, J$95$m_, K_, U$95$m_] := N[(J$95$s * If[LessEqual[U$95$m, 4200000000.0], N[(J$95$m * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(J$95$m * N[(J$95$m * N[(-2.0 / U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
U_m = \left|U\right|
\\
J\_m = \left|J\right|
\\
J\_s = \mathsf{copysign}\left(1, J\right)
\\
J\_s \cdot \begin{array}{l}
\mathbf{if}\;U\_m \leq 4200000000:\\
\;\;\;\;J\_m \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J\_m \cdot \left(J\_m \cdot \frac{-2}{U\_m}\right) - U\_m\\
\end{array}
\end{array}
if U < 4.2e9Initial program 80.0%
Simplified89.9%
Taylor expanded in U around 0 58.1%
if 4.2e9 < U Initial program 52.4%
Simplified77.6%
Taylor expanded in J around 0 41.8%
neg-mul-141.8%
unsub-neg41.8%
*-commutative41.8%
associate-*l/41.8%
unpow241.8%
*-commutative41.8%
unpow241.8%
swap-sqr41.8%
unpow241.8%
*-commutative41.8%
Simplified41.8%
Taylor expanded in K around 0 41.8%
*-commutative41.8%
Simplified41.8%
associate-/l*41.8%
unpow241.8%
associate-*l*47.4%
Applied egg-rr47.4%
Final simplification55.3%
U_m = (fabs.f64 U) J\_m = (fabs.f64 J) J\_s = (copysign.f64 #s(literal 1 binary64) J) (FPCore (J_s J_m K U_m) :precision binary64 (* J_s (if (<= K 1.42e+29) (- (* J_m (* J_m (/ -2.0 U_m))) U_m) U_m)))
U_m = fabs(U);
J\_m = fabs(J);
J\_s = copysign(1.0, J);
double code(double J_s, double J_m, double K, double U_m) {
double tmp;
if (K <= 1.42e+29) {
tmp = (J_m * (J_m * (-2.0 / U_m))) - U_m;
} else {
tmp = U_m;
}
return J_s * tmp;
}
U_m = abs(u)
J\_m = abs(j)
J\_s = copysign(1.0d0, j)
real(8) function code(j_s, j_m, k, u_m)
real(8), intent (in) :: j_s
real(8), intent (in) :: j_m
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: tmp
if (k <= 1.42d+29) then
tmp = (j_m * (j_m * ((-2.0d0) / u_m))) - u_m
else
tmp = u_m
end if
code = j_s * tmp
end function
U_m = Math.abs(U);
J\_m = Math.abs(J);
J\_s = Math.copySign(1.0, J);
public static double code(double J_s, double J_m, double K, double U_m) {
double tmp;
if (K <= 1.42e+29) {
tmp = (J_m * (J_m * (-2.0 / U_m))) - U_m;
} else {
tmp = U_m;
}
return J_s * tmp;
}
U_m = math.fabs(U) J\_m = math.fabs(J) J\_s = math.copysign(1.0, J) def code(J_s, J_m, K, U_m): tmp = 0 if K <= 1.42e+29: tmp = (J_m * (J_m * (-2.0 / U_m))) - U_m else: tmp = U_m return J_s * tmp
U_m = abs(U) J\_m = abs(J) J\_s = copysign(1.0, J) function code(J_s, J_m, K, U_m) tmp = 0.0 if (K <= 1.42e+29) tmp = Float64(Float64(J_m * Float64(J_m * Float64(-2.0 / U_m))) - U_m); else tmp = U_m; end return Float64(J_s * tmp) end
U_m = abs(U); J\_m = abs(J); J\_s = sign(J) * abs(1.0); function tmp_2 = code(J_s, J_m, K, U_m) tmp = 0.0; if (K <= 1.42e+29) tmp = (J_m * (J_m * (-2.0 / U_m))) - U_m; else tmp = U_m; end tmp_2 = J_s * tmp; end
U_m = N[Abs[U], $MachinePrecision]
J\_m = N[Abs[J], $MachinePrecision]
J\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[J]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[J$95$s_, J$95$m_, K_, U$95$m_] := N[(J$95$s * If[LessEqual[K, 1.42e+29], N[(N[(J$95$m * N[(J$95$m * N[(-2.0 / U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U$95$m), $MachinePrecision], U$95$m]), $MachinePrecision]
\begin{array}{l}
U_m = \left|U\right|
\\
J\_m = \left|J\right|
\\
J\_s = \mathsf{copysign}\left(1, J\right)
\\
J\_s \cdot \begin{array}{l}
\mathbf{if}\;K \leq 1.42 \cdot 10^{+29}:\\
\;\;\;\;J\_m \cdot \left(J\_m \cdot \frac{-2}{U\_m}\right) - U\_m\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if K < 1.42e29Initial program 74.1%
Simplified87.4%
Taylor expanded in J around 0 28.4%
neg-mul-128.4%
unsub-neg28.4%
*-commutative28.4%
associate-*l/28.4%
unpow228.4%
*-commutative28.4%
unpow228.4%
swap-sqr28.4%
unpow228.4%
*-commutative28.4%
Simplified28.4%
Taylor expanded in K around 0 28.4%
*-commutative28.4%
Simplified28.4%
associate-/l*28.4%
unpow228.4%
associate-*l*30.4%
Applied egg-rr30.4%
if 1.42e29 < K Initial program 68.6%
Simplified84.1%
Taylor expanded in U around -inf 35.2%
U_m = (fabs.f64 U) J\_m = (fabs.f64 J) J\_s = (copysign.f64 #s(literal 1 binary64) J) (FPCore (J_s J_m K U_m) :precision binary64 (* J_s (if (<= K 1.42e+29) (- U_m) U_m)))
U_m = fabs(U);
J\_m = fabs(J);
J\_s = copysign(1.0, J);
double code(double J_s, double J_m, double K, double U_m) {
double tmp;
if (K <= 1.42e+29) {
tmp = -U_m;
} else {
tmp = U_m;
}
return J_s * tmp;
}
U_m = abs(u)
J\_m = abs(j)
J\_s = copysign(1.0d0, j)
real(8) function code(j_s, j_m, k, u_m)
real(8), intent (in) :: j_s
real(8), intent (in) :: j_m
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: tmp
if (k <= 1.42d+29) then
tmp = -u_m
else
tmp = u_m
end if
code = j_s * tmp
end function
U_m = Math.abs(U);
J\_m = Math.abs(J);
J\_s = Math.copySign(1.0, J);
public static double code(double J_s, double J_m, double K, double U_m) {
double tmp;
if (K <= 1.42e+29) {
tmp = -U_m;
} else {
tmp = U_m;
}
return J_s * tmp;
}
U_m = math.fabs(U) J\_m = math.fabs(J) J\_s = math.copysign(1.0, J) def code(J_s, J_m, K, U_m): tmp = 0 if K <= 1.42e+29: tmp = -U_m else: tmp = U_m return J_s * tmp
U_m = abs(U) J\_m = abs(J) J\_s = copysign(1.0, J) function code(J_s, J_m, K, U_m) tmp = 0.0 if (K <= 1.42e+29) tmp = Float64(-U_m); else tmp = U_m; end return Float64(J_s * tmp) end
U_m = abs(U); J\_m = abs(J); J\_s = sign(J) * abs(1.0); function tmp_2 = code(J_s, J_m, K, U_m) tmp = 0.0; if (K <= 1.42e+29) tmp = -U_m; else tmp = U_m; end tmp_2 = J_s * tmp; end
U_m = N[Abs[U], $MachinePrecision]
J\_m = N[Abs[J], $MachinePrecision]
J\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[J]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[J$95$s_, J$95$m_, K_, U$95$m_] := N[(J$95$s * If[LessEqual[K, 1.42e+29], (-U$95$m), U$95$m]), $MachinePrecision]
\begin{array}{l}
U_m = \left|U\right|
\\
J\_m = \left|J\right|
\\
J\_s = \mathsf{copysign}\left(1, J\right)
\\
J\_s \cdot \begin{array}{l}
\mathbf{if}\;K \leq 1.42 \cdot 10^{+29}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if K < 1.42e29Initial program 74.1%
Simplified87.4%
Taylor expanded in J around 0 30.3%
neg-mul-130.3%
Simplified30.3%
if 1.42e29 < K Initial program 68.6%
Simplified84.1%
Taylor expanded in U around -inf 35.2%
U_m = (fabs.f64 U) J\_m = (fabs.f64 J) J\_s = (copysign.f64 #s(literal 1 binary64) J) (FPCore (J_s J_m K U_m) :precision binary64 (* J_s U_m))
U_m = fabs(U);
J\_m = fabs(J);
J\_s = copysign(1.0, J);
double code(double J_s, double J_m, double K, double U_m) {
return J_s * U_m;
}
U_m = abs(u)
J\_m = abs(j)
J\_s = copysign(1.0d0, j)
real(8) function code(j_s, j_m, k, u_m)
real(8), intent (in) :: j_s
real(8), intent (in) :: j_m
real(8), intent (in) :: k
real(8), intent (in) :: u_m
code = j_s * u_m
end function
U_m = Math.abs(U);
J\_m = Math.abs(J);
J\_s = Math.copySign(1.0, J);
public static double code(double J_s, double J_m, double K, double U_m) {
return J_s * U_m;
}
U_m = math.fabs(U) J\_m = math.fabs(J) J\_s = math.copysign(1.0, J) def code(J_s, J_m, K, U_m): return J_s * U_m
U_m = abs(U) J\_m = abs(J) J\_s = copysign(1.0, J) function code(J_s, J_m, K, U_m) return Float64(J_s * U_m) end
U_m = abs(U); J\_m = abs(J); J\_s = sign(J) * abs(1.0); function tmp = code(J_s, J_m, K, U_m) tmp = J_s * U_m; end
U_m = N[Abs[U], $MachinePrecision]
J\_m = N[Abs[J], $MachinePrecision]
J\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[J]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[J$95$s_, J$95$m_, K_, U$95$m_] := N[(J$95$s * U$95$m), $MachinePrecision]
\begin{array}{l}
U_m = \left|U\right|
\\
J\_m = \left|J\right|
\\
J\_s = \mathsf{copysign}\left(1, J\right)
\\
J\_s \cdot U\_m
\end{array}
Initial program 72.8%
Simplified86.6%
Taylor expanded in U around -inf 29.2%
herbie shell --seed 2024135
(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)))))