
(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}
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
(*
(* (* -2.0 J_m) t_0)
(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+295) 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 = ((-2.0 * J_m) * t_0) * 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+295) {
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 = ((-2.0 * J_m) * t_0) * 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+295) {
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 = ((-2.0 * J_m) * t_0) * 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+295: 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(Float64(-2.0 * J_m) * t_0) * 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+295) 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 = ((-2.0 * J_m) * t_0) * 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+295) 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[(N[(-2.0 * J$95$m), $MachinePrecision] * t$95$0), $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+295], 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(\left(-2 \cdot J\_m\right) \cdot t\_0\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^{+295}:\\
\;\;\;\;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.6%
Simplified50.3%
Taylor expanded in J around 0 55.6%
neg-mul-155.6%
Simplified55.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.9999999999999998e294Initial program 99.8%
if 9.9999999999999998e294 < (*.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 9.9%
Simplified65.5%
Taylor expanded in U around -inf 61.3%
Final simplification87.1%
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 (<= J_m 1.75e-200)
(- U_m)
(* J_m (* (* -2.0 t_0) (hypot 1.0 (/ (/ U_m 2.0) (* J_m t_0)))))))))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 (J_m <= 1.75e-200) {
tmp = -U_m;
} else {
tmp = J_m * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J_m * t_0))));
}
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 (J_m <= 1.75e-200) {
tmp = -U_m;
} else {
tmp = J_m * ((-2.0 * t_0) * Math.hypot(1.0, ((U_m / 2.0) / (J_m * t_0))));
}
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 J_m <= 1.75e-200: tmp = -U_m else: tmp = J_m * ((-2.0 * t_0) * math.hypot(1.0, ((U_m / 2.0) / (J_m * t_0)))) 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 (J_m <= 1.75e-200) tmp = Float64(-U_m); else tmp = Float64(J_m * Float64(Float64(-2.0 * t_0) * hypot(1.0, Float64(Float64(U_m / 2.0) / Float64(J_m * t_0))))); 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 (J_m <= 1.75e-200) tmp = -U_m; else tmp = J_m * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J_m * t_0)))); 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[J$95$m, 1.75e-200], (-U$95$m), 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]]), $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}\;J\_m \leq 1.75 \cdot 10^{-200}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;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)\\
\end{array}
\end{array}
\end{array}
if J < 1.75000000000000011e-200Initial program 65.1%
Simplified80.5%
Taylor expanded in J around 0 25.9%
neg-mul-125.9%
Simplified25.9%
if 1.75000000000000011e-200 < J Initial program 80.0%
Simplified95.5%
Final simplification55.5%
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 (<= J_m 6.2e-199)
(- U_m)
(*
J_m
(*
(* -2.0 (cos (/ K 2.0)))
(hypot 1.0 (/ (/ U_m (cos (* K 0.5))) (* -2.0 J_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 (J_m <= 6.2e-199) {
tmp = -U_m;
} else {
tmp = J_m * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / cos((K * 0.5))) / (-2.0 * J_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 (J_m <= 6.2e-199) {
tmp = -U_m;
} else {
tmp = J_m * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / Math.cos((K * 0.5))) / (-2.0 * J_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 J_m <= 6.2e-199: tmp = -U_m else: tmp = J_m * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / math.cos((K * 0.5))) / (-2.0 * J_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 (J_m <= 6.2e-199) tmp = Float64(-U_m); else tmp = Float64(J_m * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / cos(Float64(K * 0.5))) / Float64(-2.0 * J_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 (J_m <= 6.2e-199) tmp = -U_m; else tmp = J_m * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / cos((K * 0.5))) / (-2.0 * J_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[J$95$m, 6.2e-199], (-U$95$m), 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 / N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(-2.0 * J$95$m), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $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}\;J\_m \leq 6.2 \cdot 10^{-199}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;J\_m \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{\cos \left(K \cdot 0.5\right)}}{-2 \cdot J\_m}\right)\right)\\
\end{array}
\end{array}
if J < 6.20000000000000024e-199Initial program 65.1%
Simplified80.5%
Taylor expanded in J around 0 25.9%
neg-mul-125.9%
Simplified25.9%
if 6.20000000000000024e-199 < J Initial program 80.0%
Simplified95.5%
associate-/r*95.5%
associate-*l*95.5%
add-cube-cbrt95.0%
associate-/l*94.9%
pow294.9%
*-commutative94.9%
*-commutative94.9%
add-sqr-sqrt94.9%
div-inv94.9%
metadata-eval94.9%
sqrt-unprod83.1%
swap-sqr83.1%
metadata-eval83.1%
metadata-eval83.1%
swap-sqr83.1%
*-commutative83.1%
*-commutative83.1%
sqrt-unprod0.0%
add-sqr-sqrt94.9%
*-commutative94.9%
Applied egg-rr94.9%
associate-/r*94.9%
associate-*r/94.9%
associate-*r/94.9%
unpow294.9%
rem-3cbrt-lft95.5%
*-commutative95.5%
*-commutative95.5%
Simplified95.5%
Final simplification55.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 (<= J_m 2.5e-197)
(- U_m)
(if (or (<= J_m 1.55e-148) (not (<= J_m 1.5e-62)))
(* J_m (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J_m))))
(- (/ (* -2.0 (pow (* J_m (cos (* K 0.5))) 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 (J_m <= 2.5e-197) {
tmp = -U_m;
} else if ((J_m <= 1.55e-148) || !(J_m <= 1.5e-62)) {
tmp = J_m * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J_m)));
} else {
tmp = ((-2.0 * pow((J_m * cos((K * 0.5))), 2.0)) / U_m) - 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 (J_m <= 2.5e-197) {
tmp = -U_m;
} else if ((J_m <= 1.55e-148) || !(J_m <= 1.5e-62)) {
tmp = J_m * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 2.0) / J_m)));
} else {
tmp = ((-2.0 * Math.pow((J_m * Math.cos((K * 0.5))), 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 J_m <= 2.5e-197: tmp = -U_m elif (J_m <= 1.55e-148) or not (J_m <= 1.5e-62): tmp = J_m * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 2.0) / J_m))) else: tmp = ((-2.0 * math.pow((J_m * math.cos((K * 0.5))), 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 (J_m <= 2.5e-197) tmp = Float64(-U_m); elseif ((J_m <= 1.55e-148) || !(J_m <= 1.5e-62)) 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(Float64(Float64(-2.0 * (Float64(J_m * cos(Float64(K * 0.5))) ^ 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 (J_m <= 2.5e-197) tmp = -U_m; elseif ((J_m <= 1.55e-148) || ~((J_m <= 1.5e-62))) tmp = J_m * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J_m))); else tmp = ((-2.0 * ((J_m * cos((K * 0.5))) ^ 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[J$95$m, 2.5e-197], (-U$95$m), If[Or[LessEqual[J$95$m, 1.55e-148], N[Not[LessEqual[J$95$m, 1.5e-62]], $MachinePrecision]], 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], N[(N[(N[(-2.0 * N[Power[N[(J$95$m * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / U$95$m), $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}\;J\_m \leq 2.5 \cdot 10^{-197}:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;J\_m \leq 1.55 \cdot 10^{-148} \lor \neg \left(J\_m \leq 1.5 \cdot 10^{-62}\right):\\
\;\;\;\;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}:\\
\;\;\;\;\frac{-2 \cdot {\left(J\_m \cdot \cos \left(K \cdot 0.5\right)\right)}^{2}}{U\_m} - U\_m\\
\end{array}
\end{array}
if J < 2.5000000000000001e-197Initial program 65.1%
Simplified80.5%
Taylor expanded in J around 0 25.9%
neg-mul-125.9%
Simplified25.9%
if 2.5000000000000001e-197 < J < 1.5500000000000001e-148 or 1.5000000000000001e-62 < J Initial program 86.1%
Simplified96.7%
Taylor expanded in K around 0 86.7%
if 1.5500000000000001e-148 < J < 1.5000000000000001e-62Initial program 54.3%
Simplified90.8%
Taylor expanded in J around 0 27.5%
neg-mul-127.5%
unsub-neg27.5%
associate-*r/27.5%
unpow227.5%
*-commutative27.5%
unpow227.5%
swap-sqr27.5%
unpow227.5%
*-commutative27.5%
Simplified27.5%
Final simplification46.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
(let* ((t_0 (cos (* K 0.5))))
(*
J_s
(if (<= J_m 9.5e-197)
(- U_m)
(if (<= J_m 7.5e-148)
(* J_m (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J_m))))
(if (<= J_m 2e-62)
(- (/ (* -2.0 (pow (* J_m t_0) 2.0)) U_m) U_m)
(* (* J_m (* -2.0 t_0)) (hypot 1.0 (/ (* U_m 0.5) J_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 * 0.5));
double tmp;
if (J_m <= 9.5e-197) {
tmp = -U_m;
} else if (J_m <= 7.5e-148) {
tmp = J_m * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J_m)));
} else if (J_m <= 2e-62) {
tmp = ((-2.0 * pow((J_m * t_0), 2.0)) / U_m) - U_m;
} else {
tmp = (J_m * (-2.0 * t_0)) * hypot(1.0, ((U_m * 0.5) / J_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 * 0.5));
double tmp;
if (J_m <= 9.5e-197) {
tmp = -U_m;
} else if (J_m <= 7.5e-148) {
tmp = J_m * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 2.0) / J_m)));
} else if (J_m <= 2e-62) {
tmp = ((-2.0 * Math.pow((J_m * t_0), 2.0)) / U_m) - U_m;
} else {
tmp = (J_m * (-2.0 * t_0)) * Math.hypot(1.0, ((U_m * 0.5) / J_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 * 0.5)) tmp = 0 if J_m <= 9.5e-197: tmp = -U_m elif J_m <= 7.5e-148: tmp = J_m * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 2.0) / J_m))) elif J_m <= 2e-62: tmp = ((-2.0 * math.pow((J_m * t_0), 2.0)) / U_m) - U_m else: tmp = (J_m * (-2.0 * t_0)) * math.hypot(1.0, ((U_m * 0.5) / J_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 * 0.5)) tmp = 0.0 if (J_m <= 9.5e-197) tmp = Float64(-U_m); elseif (J_m <= 7.5e-148) tmp = Float64(J_m * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J_m)))); elseif (J_m <= 2e-62) tmp = Float64(Float64(Float64(-2.0 * (Float64(J_m * t_0) ^ 2.0)) / U_m) - U_m); else tmp = Float64(Float64(J_m * Float64(-2.0 * t_0)) * hypot(1.0, Float64(Float64(U_m * 0.5) / J_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 * 0.5)); tmp = 0.0; if (J_m <= 9.5e-197) tmp = -U_m; elseif (J_m <= 7.5e-148) tmp = J_m * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J_m))); elseif (J_m <= 2e-62) tmp = ((-2.0 * ((J_m * t_0) ^ 2.0)) / U_m) - U_m; else tmp = (J_m * (-2.0 * t_0)) * hypot(1.0, ((U_m * 0.5) / J_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 * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(J$95$s * If[LessEqual[J$95$m, 9.5e-197], (-U$95$m), If[LessEqual[J$95$m, 7.5e-148], 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], If[LessEqual[J$95$m, 2e-62], N[(N[(N[(-2.0 * N[Power[N[(J$95$m * t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / U$95$m), $MachinePrecision] - U$95$m), $MachinePrecision], N[(N[(J$95$m * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m * 0.5), $MachinePrecision] / J$95$m), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]]]), $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(K \cdot 0.5\right)\\
J\_s \cdot \begin{array}{l}
\mathbf{if}\;J\_m \leq 9.5 \cdot 10^{-197}:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;J\_m \leq 7.5 \cdot 10^{-148}:\\
\;\;\;\;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{elif}\;J\_m \leq 2 \cdot 10^{-62}:\\
\;\;\;\;\frac{-2 \cdot {\left(J\_m \cdot t\_0\right)}^{2}}{U\_m} - U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(J\_m \cdot \left(-2 \cdot t\_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m \cdot 0.5}{J\_m}\right)\\
\end{array}
\end{array}
\end{array}
if J < 9.5000000000000003e-197Initial program 65.1%
Simplified80.5%
Taylor expanded in J around 0 25.9%
neg-mul-125.9%
Simplified25.9%
if 9.5000000000000003e-197 < J < 7.5000000000000005e-148Initial program 45.0%
Simplified85.1%
Taylor expanded in K around 0 65.4%
if 7.5000000000000005e-148 < J < 2.0000000000000001e-62Initial program 54.3%
Simplified90.8%
Taylor expanded in J around 0 27.5%
neg-mul-127.5%
unsub-neg27.5%
associate-*r/27.5%
unpow227.5%
*-commutative27.5%
unpow227.5%
swap-sqr27.5%
unpow227.5%
*-commutative27.5%
Simplified27.5%
if 2.0000000000000001e-62 < J Initial program 92.6%
Simplified98.5%
Taylor expanded in K around 0 90.1%
Taylor expanded in K around inf 65.9%
associate-*r*65.9%
*-commutative65.9%
*-commutative65.9%
associate-*l*65.9%
*-commutative65.9%
*-commutative65.9%
metadata-eval65.9%
unpow265.9%
unpow265.9%
times-frac86.1%
swap-sqr86.1%
metadata-eval86.1%
hypot-undefine90.1%
associate-*r/90.1%
*-commutative90.1%
Simplified90.1%
Final simplification46.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 (<= J_m 4.35e-44)
(- (/ (* -2.0 (pow (* J_m (cos (* K 0.5))) 2.0)) U_m) U_m)
(*
J_m
(*
(* -2.0 (cos (/ K 2.0)))
(+ 1.0 (* (* (/ U_m J_m) (/ U_m J_m)) 0.125)))))))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 (J_m <= 4.35e-44) {
tmp = ((-2.0 * pow((J_m * cos((K * 0.5))), 2.0)) / U_m) - U_m;
} else {
tmp = J_m * ((-2.0 * cos((K / 2.0))) * (1.0 + (((U_m / J_m) * (U_m / J_m)) * 0.125)));
}
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 (j_m <= 4.35d-44) then
tmp = (((-2.0d0) * ((j_m * cos((k * 0.5d0))) ** 2.0d0)) / u_m) - u_m
else
tmp = j_m * (((-2.0d0) * cos((k / 2.0d0))) * (1.0d0 + (((u_m / j_m) * (u_m / j_m)) * 0.125d0)))
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 (J_m <= 4.35e-44) {
tmp = ((-2.0 * Math.pow((J_m * Math.cos((K * 0.5))), 2.0)) / U_m) - U_m;
} else {
tmp = J_m * ((-2.0 * Math.cos((K / 2.0))) * (1.0 + (((U_m / J_m) * (U_m / J_m)) * 0.125)));
}
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 J_m <= 4.35e-44: tmp = ((-2.0 * math.pow((J_m * math.cos((K * 0.5))), 2.0)) / U_m) - U_m else: tmp = J_m * ((-2.0 * math.cos((K / 2.0))) * (1.0 + (((U_m / J_m) * (U_m / J_m)) * 0.125))) 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 (J_m <= 4.35e-44) tmp = Float64(Float64(Float64(-2.0 * (Float64(J_m * cos(Float64(K * 0.5))) ^ 2.0)) / U_m) - U_m); else tmp = Float64(J_m * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * Float64(1.0 + Float64(Float64(Float64(U_m / J_m) * Float64(U_m / J_m)) * 0.125)))); 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 (J_m <= 4.35e-44) tmp = ((-2.0 * ((J_m * cos((K * 0.5))) ^ 2.0)) / U_m) - U_m; else tmp = J_m * ((-2.0 * cos((K / 2.0))) * (1.0 + (((U_m / J_m) * (U_m / J_m)) * 0.125))); 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[J$95$m, 4.35e-44], N[(N[(N[(-2.0 * N[Power[N[(J$95$m * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / U$95$m), $MachinePrecision] - U$95$m), $MachinePrecision], N[(J$95$m * N[(N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(N[(U$95$m / J$95$m), $MachinePrecision] * N[(U$95$m / J$95$m), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}\;J\_m \leq 4.35 \cdot 10^{-44}:\\
\;\;\;\;\frac{-2 \cdot {\left(J\_m \cdot \cos \left(K \cdot 0.5\right)\right)}^{2}}{U\_m} - U\_m\\
\mathbf{else}:\\
\;\;\;\;J\_m \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \left(1 + \left(\frac{U\_m}{J\_m} \cdot \frac{U\_m}{J\_m}\right) \cdot 0.125\right)\right)\\
\end{array}
\end{array}
if J < 4.3500000000000002e-44Initial program 62.7%
Simplified82.1%
Taylor expanded in J around 0 26.2%
neg-mul-126.2%
unsub-neg26.2%
associate-*r/26.2%
unpow226.2%
*-commutative26.2%
unpow226.2%
swap-sqr26.2%
unpow226.2%
*-commutative26.2%
Simplified26.2%
if 4.3500000000000002e-44 < J Initial program 92.5%
Simplified98.5%
Taylor expanded in K around 0 89.9%
Taylor expanded in U around 0 63.9%
*-commutative63.9%
Simplified63.9%
unpow263.9%
unpow263.9%
frac-times75.0%
Applied egg-rr75.0%
Final simplification40.5%
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 (<= J_m 3.9e-44)
(- (/ (* -2.0 (pow J_m 2.0)) U_m) U_m)
(*
J_m
(*
(* -2.0 (cos (/ K 2.0)))
(+ 1.0 (* (* (/ U_m J_m) (/ U_m J_m)) 0.125)))))))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 (J_m <= 3.9e-44) {
tmp = ((-2.0 * pow(J_m, 2.0)) / U_m) - U_m;
} else {
tmp = J_m * ((-2.0 * cos((K / 2.0))) * (1.0 + (((U_m / J_m) * (U_m / J_m)) * 0.125)));
}
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 (j_m <= 3.9d-44) then
tmp = (((-2.0d0) * (j_m ** 2.0d0)) / u_m) - u_m
else
tmp = j_m * (((-2.0d0) * cos((k / 2.0d0))) * (1.0d0 + (((u_m / j_m) * (u_m / j_m)) * 0.125d0)))
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 (J_m <= 3.9e-44) {
tmp = ((-2.0 * Math.pow(J_m, 2.0)) / U_m) - U_m;
} else {
tmp = J_m * ((-2.0 * Math.cos((K / 2.0))) * (1.0 + (((U_m / J_m) * (U_m / J_m)) * 0.125)));
}
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 J_m <= 3.9e-44: tmp = ((-2.0 * math.pow(J_m, 2.0)) / U_m) - U_m else: tmp = J_m * ((-2.0 * math.cos((K / 2.0))) * (1.0 + (((U_m / J_m) * (U_m / J_m)) * 0.125))) 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 (J_m <= 3.9e-44) tmp = Float64(Float64(Float64(-2.0 * (J_m ^ 2.0)) / U_m) - U_m); else tmp = Float64(J_m * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * Float64(1.0 + Float64(Float64(Float64(U_m / J_m) * Float64(U_m / J_m)) * 0.125)))); 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 (J_m <= 3.9e-44) tmp = ((-2.0 * (J_m ^ 2.0)) / U_m) - U_m; else tmp = J_m * ((-2.0 * cos((K / 2.0))) * (1.0 + (((U_m / J_m) * (U_m / J_m)) * 0.125))); 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[J$95$m, 3.9e-44], N[(N[(N[(-2.0 * N[Power[J$95$m, 2.0], $MachinePrecision]), $MachinePrecision] / U$95$m), $MachinePrecision] - U$95$m), $MachinePrecision], N[(J$95$m * N[(N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(N[(U$95$m / J$95$m), $MachinePrecision] * N[(U$95$m / J$95$m), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}\;J\_m \leq 3.9 \cdot 10^{-44}:\\
\;\;\;\;\frac{-2 \cdot {J\_m}^{2}}{U\_m} - U\_m\\
\mathbf{else}:\\
\;\;\;\;J\_m \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \left(1 + \left(\frac{U\_m}{J\_m} \cdot \frac{U\_m}{J\_m}\right) \cdot 0.125\right)\right)\\
\end{array}
\end{array}
if J < 3.9000000000000002e-44Initial program 62.7%
Simplified82.1%
Taylor expanded in J around 0 26.2%
neg-mul-126.2%
unsub-neg26.2%
associate-*r/26.2%
unpow226.2%
*-commutative26.2%
unpow226.2%
swap-sqr26.2%
unpow226.2%
*-commutative26.2%
Simplified26.2%
Taylor expanded in K around 0 26.2%
if 3.9000000000000002e-44 < J Initial program 92.5%
Simplified98.5%
Taylor expanded in K around 0 89.9%
Taylor expanded in U around 0 63.9%
*-commutative63.9%
Simplified63.9%
unpow263.9%
unpow263.9%
frac-times75.0%
Applied egg-rr75.0%
Final simplification40.5%
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 (<= J_m 4.8e-13)
(- (/ (* -2.0 (pow J_m 2.0)) U_m) U_m)
(* (* -2.0 J_m) (cos (* K 0.5))))))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 (J_m <= 4.8e-13) {
tmp = ((-2.0 * pow(J_m, 2.0)) / U_m) - U_m;
} else {
tmp = (-2.0 * J_m) * cos((K * 0.5));
}
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 (j_m <= 4.8d-13) then
tmp = (((-2.0d0) * (j_m ** 2.0d0)) / u_m) - u_m
else
tmp = ((-2.0d0) * j_m) * cos((k * 0.5d0))
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 (J_m <= 4.8e-13) {
tmp = ((-2.0 * Math.pow(J_m, 2.0)) / U_m) - U_m;
} else {
tmp = (-2.0 * J_m) * Math.cos((K * 0.5));
}
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 J_m <= 4.8e-13: tmp = ((-2.0 * math.pow(J_m, 2.0)) / U_m) - U_m else: tmp = (-2.0 * J_m) * math.cos((K * 0.5)) 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 (J_m <= 4.8e-13) tmp = Float64(Float64(Float64(-2.0 * (J_m ^ 2.0)) / U_m) - U_m); else tmp = Float64(Float64(-2.0 * J_m) * cos(Float64(K * 0.5))); 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 (J_m <= 4.8e-13) tmp = ((-2.0 * (J_m ^ 2.0)) / U_m) - U_m; else tmp = (-2.0 * J_m) * cos((K * 0.5)); 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[J$95$m, 4.8e-13], N[(N[(N[(-2.0 * N[Power[J$95$m, 2.0], $MachinePrecision]), $MachinePrecision] / U$95$m), $MachinePrecision] - U$95$m), $MachinePrecision], N[(N[(-2.0 * J$95$m), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $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}\;J\_m \leq 4.8 \cdot 10^{-13}:\\
\;\;\;\;\frac{-2 \cdot {J\_m}^{2}}{U\_m} - U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\_m\right) \cdot \cos \left(K \cdot 0.5\right)\\
\end{array}
\end{array}
if J < 4.7999999999999997e-13Initial program 61.8%
Simplified81.9%
Taylor expanded in J around 0 26.3%
neg-mul-126.3%
unsub-neg26.3%
associate-*r/26.3%
unpow226.3%
*-commutative26.3%
unpow226.3%
swap-sqr26.3%
unpow226.3%
*-commutative26.3%
Simplified26.3%
Taylor expanded in K around 0 26.3%
if 4.7999999999999997e-13 < J Initial program 96.0%
Simplified99.7%
Taylor expanded in J around inf 77.3%
associate-*r*77.3%
*-commutative77.3%
*-commutative77.3%
*-commutative77.3%
*-commutative77.3%
*-commutative77.3%
Simplified77.3%
Final simplification40.7%
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 (<= J_m 7.2e-16) (- U_m) (* (* -2.0 J_m) (cos (* K 0.5))))))
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 (J_m <= 7.2e-16) {
tmp = -U_m;
} else {
tmp = (-2.0 * J_m) * cos((K * 0.5));
}
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 (j_m <= 7.2d-16) then
tmp = -u_m
else
tmp = ((-2.0d0) * j_m) * cos((k * 0.5d0))
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 (J_m <= 7.2e-16) {
tmp = -U_m;
} else {
tmp = (-2.0 * J_m) * Math.cos((K * 0.5));
}
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 J_m <= 7.2e-16: tmp = -U_m else: tmp = (-2.0 * J_m) * math.cos((K * 0.5)) 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 (J_m <= 7.2e-16) tmp = Float64(-U_m); else tmp = Float64(Float64(-2.0 * J_m) * cos(Float64(K * 0.5))); 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 (J_m <= 7.2e-16) tmp = -U_m; else tmp = (-2.0 * J_m) * cos((K * 0.5)); 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[J$95$m, 7.2e-16], (-U$95$m), N[(N[(-2.0 * J$95$m), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $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}\;J\_m \leq 7.2 \cdot 10^{-16}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\_m\right) \cdot \cos \left(K \cdot 0.5\right)\\
\end{array}
\end{array}
if J < 7.19999999999999965e-16Initial program 61.8%
Simplified81.9%
Taylor expanded in J around 0 26.2%
neg-mul-126.2%
Simplified26.2%
if 7.19999999999999965e-16 < J Initial program 96.0%
Simplified99.7%
Taylor expanded in J around inf 77.3%
associate-*r*77.3%
*-commutative77.3%
*-commutative77.3%
*-commutative77.3%
*-commutative77.3%
*-commutative77.3%
Simplified77.3%
Final simplification40.5%
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 * Float64(-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 \left(-U\_m\right)
\end{array}
Initial program 71.4%
Simplified86.9%
Taylor expanded in J around 0 22.6%
neg-mul-122.6%
Simplified22.6%
Final simplification22.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 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 71.4%
Simplified86.9%
Taylor expanded in U around -inf 29.4%
Final simplification29.4%
herbie shell --seed 2024059
(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)))))