
(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 12 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)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY)) (- U_m) (if (<= t_1 2e+303) t_1 U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_1 <= 2e+303) {
tmp = t_1;
} else {
tmp = U_m;
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U_m;
} else if (t_1 <= 2e+303) {
tmp = t_1;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U_m / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U_m elif t_1 <= 2e+303: tmp = t_1 else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U_m / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_1 <= 2e+303) tmp = t_1; else tmp = U_m; end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U_m / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U_m; elseif (t_1 <= 2e+303) tmp = t_1; else tmp = U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, 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), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U$95$m / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U$95$m), If[LessEqual[t$95$1, 2e+303], t$95$1, U$95$m]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U\_m}{t\_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+303}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\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%
Simplified51.4%
Taylor expanded in J around 0 49.1%
neg-mul-149.1%
Simplified49.1%
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))))) < 2e303Initial program 99.8%
if 2e303 < (*.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 5.4%
Simplified52.7%
Taylor expanded in U around -inf 42.1%
Final simplification84.4%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.31)
(* (* (* -2.0 J) t_0) (+ 1.0 (* (* (/ U_m J) (/ U_m J)) 0.125)))
(if (<= t_0 -0.015)
U_m
(if (<= t_0 0.955)
(* J (* -2.0 (cos (* K 0.5))))
(* (* -2.0 J) (hypot 1.0 (/ (* U_m 0.5) J))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.31) {
tmp = ((-2.0 * J) * t_0) * (1.0 + (((U_m / J) * (U_m / J)) * 0.125));
} else if (t_0 <= -0.015) {
tmp = U_m;
} else if (t_0 <= 0.955) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else {
tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= -0.31) {
tmp = ((-2.0 * J) * t_0) * (1.0 + (((U_m / J) * (U_m / J)) * 0.125));
} else if (t_0 <= -0.015) {
tmp = U_m;
} else if (t_0 <= 0.955) {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
} else {
tmp = (-2.0 * J) * Math.hypot(1.0, ((U_m * 0.5) / J));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= -0.31: tmp = ((-2.0 * J) * t_0) * (1.0 + (((U_m / J) * (U_m / J)) * 0.125)) elif t_0 <= -0.015: tmp = U_m elif t_0 <= 0.955: tmp = J * (-2.0 * math.cos((K * 0.5))) else: tmp = (-2.0 * J) * math.hypot(1.0, ((U_m * 0.5) / J)) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.31) tmp = Float64(Float64(Float64(-2.0 * J) * t_0) * Float64(1.0 + Float64(Float64(Float64(U_m / J) * Float64(U_m / J)) * 0.125))); elseif (t_0 <= -0.015) tmp = U_m; elseif (t_0 <= 0.955) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); else tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(Float64(U_m * 0.5) / J))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= -0.31) tmp = ((-2.0 * J) * t_0) * (1.0 + (((U_m / J) * (U_m / J)) * 0.125)); elseif (t_0 <= -0.015) tmp = U_m; elseif (t_0 <= 0.955) tmp = J * (-2.0 * cos((K * 0.5))); else tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J)); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.31], N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 + N[(N[(N[(U$95$m / J), $MachinePrecision] * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.015], U$95$m, If[LessEqual[t$95$0, 0.955], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.31:\\
\;\;\;\;\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \left(1 + \left(\frac{U\_m}{J} \cdot \frac{U\_m}{J}\right) \cdot 0.125\right)\\
\mathbf{elif}\;t\_0 \leq -0.015:\\
\;\;\;\;U\_m\\
\mathbf{elif}\;t\_0 \leq 0.955:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m \cdot 0.5}{J}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.309999999999999998Initial program 80.1%
Taylor expanded in K around 0 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in U around 0 62.0%
*-commutative62.0%
Simplified62.0%
Applied egg-rr67.1%
if -0.309999999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.014999999999999999Initial program 70.2%
Simplified75.9%
Taylor expanded in U around -inf 32.7%
if -0.014999999999999999 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.95499999999999996Initial program 78.4%
Simplified88.8%
Taylor expanded in U around 0 64.5%
if 0.95499999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 68.7%
Taylor expanded in K around 0 67.2%
*-commutative67.2%
Simplified67.2%
unpow267.2%
hypot-1-def82.1%
*-un-lft-identity82.1%
*-commutative82.1%
times-frac82.1%
metadata-eval82.1%
metadata-eval82.1%
times-frac82.1%
*-commutative82.1%
*-un-lft-identity82.1%
Applied egg-rr82.1%
Taylor expanded in K around 0 83.6%
Final simplification73.4%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= J 2.65e-214)
(- U_m)
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ (/ U_m (* J 2.0)) t_0))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (J <= 2.65e-214) {
tmp = -U_m;
} else {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, ((U_m / (J * 2.0)) / t_0));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (J <= 2.65e-214) {
tmp = -U_m;
} else {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, ((U_m / (J * 2.0)) / t_0));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if J <= 2.65e-214: tmp = -U_m else: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, ((U_m / (J * 2.0)) / t_0)) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (J <= 2.65e-214) tmp = Float64(-U_m); else tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(Float64(U_m / Float64(J * 2.0)) / t_0))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = 0.0; if (J <= 2.65e-214) tmp = -U_m; else tmp = (J * (-2.0 * t_0)) * hypot(1.0, ((U_m / (J * 2.0)) / t_0)); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[J, 2.65e-214], (-U$95$m), N[(N[(J * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;J \leq 2.65 \cdot 10^{-214}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot t\_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{J \cdot 2}}{t\_0}\right)\\
\end{array}
\end{array}
if J < 2.65000000000000003e-214Initial program 67.0%
Simplified80.2%
Taylor expanded in J around 0 30.7%
neg-mul-130.7%
Simplified30.7%
if 2.65000000000000003e-214 < J Initial program 81.3%
*-commutative81.3%
associate-*l*82.1%
unpow282.1%
hypot-1-def94.5%
associate-/r*94.5%
cos-neg94.5%
distribute-frac-neg94.5%
associate-/r*94.5%
associate-/r*94.5%
*-commutative94.5%
distribute-frac-neg94.5%
cos-neg94.5%
Simplified94.5%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= J 4.5e-214)
(- U_m)
(* J (* (* -2.0 t_0) (hypot 1.0 (/ (/ U_m 2.0) (* J t_0))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (J <= 4.5e-214) {
tmp = -U_m;
} else {
tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J * t_0))));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (J <= 4.5e-214) {
tmp = -U_m;
} else {
tmp = J * ((-2.0 * t_0) * Math.hypot(1.0, ((U_m / 2.0) / (J * t_0))));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if J <= 4.5e-214: tmp = -U_m else: tmp = J * ((-2.0 * t_0) * math.hypot(1.0, ((U_m / 2.0) / (J * t_0)))) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (J <= 4.5e-214) tmp = Float64(-U_m); else tmp = Float64(J * Float64(Float64(-2.0 * t_0) * hypot(1.0, Float64(Float64(U_m / 2.0) / Float64(J * t_0))))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = 0.0; if (J <= 4.5e-214) tmp = -U_m; else tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J * t_0)))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[J, 4.5e-214], (-U$95$m), N[(J * N[(N[(-2.0 * t$95$0), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / N[(J * t$95$0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;J \leq 4.5 \cdot 10^{-214}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot t\_0\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J \cdot t\_0}\right)\right)\\
\end{array}
\end{array}
if J < 4.5000000000000001e-214Initial program 67.0%
Simplified80.2%
Taylor expanded in J around 0 30.7%
neg-mul-130.7%
Simplified30.7%
if 4.5000000000000001e-214 < J Initial program 81.3%
Simplified94.5%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= J 7e-211)
(- U_m)
(*
J
(*
(* -2.0 (cos (/ K 2.0)))
(hypot 1.0 (* (/ U_m J) (/ 0.5 (cos (* K 0.5)))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 7e-211) {
tmp = -U_m;
} else {
tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / J) * (0.5 / cos((K * 0.5))))));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 7e-211) {
tmp = -U_m;
} else {
tmp = J * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / J) * (0.5 / Math.cos((K * 0.5))))));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 7e-211: tmp = -U_m else: tmp = J * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / J) * (0.5 / math.cos((K * 0.5)))))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 7e-211) tmp = Float64(-U_m); else tmp = Float64(J * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / J) * Float64(0.5 / cos(Float64(K * 0.5))))))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 7e-211) tmp = -U_m; else tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / J) * (0.5 / cos((K * 0.5)))))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 7e-211], (-U$95$m), N[(J * N[(N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / J), $MachinePrecision] * N[(0.5 / N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 7 \cdot 10^{-211}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m}{J} \cdot \frac{0.5}{\cos \left(K \cdot 0.5\right)}\right)\right)\\
\end{array}
\end{array}
if J < 7e-211Initial program 66.6%
Simplified80.3%
Taylor expanded in J around 0 30.5%
neg-mul-130.5%
Simplified30.5%
if 7e-211 < J Initial program 82.0%
Simplified94.4%
div-inv94.4%
metadata-eval94.4%
times-frac94.4%
div-inv94.4%
metadata-eval94.4%
Applied egg-rr94.4%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 9.5e-186) (- U_m) (* J (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 9.5e-186) {
tmp = -U_m;
} else {
tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 9.5e-186) {
tmp = -U_m;
} else {
tmp = J * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 2.0) / J)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 9.5e-186: tmp = -U_m else: tmp = J * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 2.0) / J))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 9.5e-186) tmp = Float64(-U_m); else tmp = Float64(J * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 9.5e-186) tmp = -U_m; else tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 9.5e-186], (-U$95$m), N[(J * 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), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 9.5 \cdot 10^{-186}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J}\right)\right)\\
\end{array}
\end{array}
if J < 9.4999999999999998e-186Initial program 65.4%
Simplified79.9%
Taylor expanded in J around 0 30.0%
neg-mul-130.0%
Simplified30.0%
if 9.4999999999999998e-186 < J Initial program 84.8%
Simplified96.0%
Taylor expanded in K around 0 86.0%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= K 18000.0) (* (* -2.0 J) (hypot 1.0 (/ (* U_m 0.5) J))) (* J (* -2.0 (cos (* K 0.5))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (K <= 18000.0) {
tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J));
} else {
tmp = J * (-2.0 * cos((K * 0.5)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (K <= 18000.0) {
tmp = (-2.0 * J) * Math.hypot(1.0, ((U_m * 0.5) / J));
} else {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if K <= 18000.0: tmp = (-2.0 * J) * math.hypot(1.0, ((U_m * 0.5) / J)) else: tmp = J * (-2.0 * math.cos((K * 0.5))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (K <= 18000.0) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(Float64(U_m * 0.5) / J))); else tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (K <= 18000.0) tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J)); else tmp = J * (-2.0 * cos((K * 0.5))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[K, 18000.0], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 18000:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m \cdot 0.5}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if K < 18000Initial program 70.3%
Taylor expanded in K around 0 65.4%
*-commutative65.4%
Simplified65.4%
unpow265.4%
hypot-1-def76.2%
*-un-lft-identity76.2%
*-commutative76.2%
times-frac76.2%
metadata-eval76.2%
metadata-eval76.2%
times-frac76.2%
*-commutative76.2%
*-un-lft-identity76.2%
Applied egg-rr76.2%
Taylor expanded in K around 0 62.5%
if 18000 < K Initial program 83.4%
Simplified88.7%
Taylor expanded in U around 0 57.4%
Final simplification61.4%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= K 730000.0) (* J (* -2.0 (hypot 1.0 (* U_m (/ 0.5 J))))) (* J (* -2.0 (cos (* K 0.5))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (K <= 730000.0) {
tmp = J * (-2.0 * hypot(1.0, (U_m * (0.5 / J))));
} else {
tmp = J * (-2.0 * cos((K * 0.5)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (K <= 730000.0) {
tmp = J * (-2.0 * Math.hypot(1.0, (U_m * (0.5 / J))));
} else {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if K <= 730000.0: tmp = J * (-2.0 * math.hypot(1.0, (U_m * (0.5 / J)))) else: tmp = J * (-2.0 * math.cos((K * 0.5))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (K <= 730000.0) tmp = Float64(J * Float64(-2.0 * hypot(1.0, Float64(U_m * Float64(0.5 / J))))); else tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (K <= 730000.0) tmp = J * (-2.0 * hypot(1.0, (U_m * (0.5 / J)))); else tmp = J * (-2.0 * cos((K * 0.5))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[K, 730000.0], N[(J * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(U$95$m * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 730000:\\
\;\;\;\;J \cdot \left(-2 \cdot \mathsf{hypot}\left(1, U\_m \cdot \frac{0.5}{J}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if K < 7.3e5Initial program 70.3%
Simplified85.5%
div-inv85.5%
metadata-eval85.5%
times-frac85.5%
div-inv85.5%
metadata-eval85.5%
Applied egg-rr85.5%
Taylor expanded in K around 0 40.1%
metadata-eval40.1%
unpow240.1%
unpow240.1%
times-frac49.5%
swap-sqr49.5%
associate-*r/49.5%
*-commutative49.5%
associate-*r/49.5%
*-commutative49.5%
unpow249.5%
metadata-eval49.5%
unpow249.5%
hypot-undefine62.5%
associate-/l*62.4%
Simplified62.4%
if 7.3e5 < K Initial program 83.4%
Simplified88.7%
Taylor expanded in U around 0 57.4%
Final simplification61.4%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 4.6e-73) (- U_m) (* J (* -2.0 (cos (* K 0.5))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 4.6e-73) {
tmp = -U_m;
} else {
tmp = J * (-2.0 * cos((K * 0.5)));
}
return tmp;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: tmp
if (j <= 4.6d-73) then
tmp = -u_m
else
tmp = j * ((-2.0d0) * cos((k * 0.5d0)))
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 4.6e-73) {
tmp = -U_m;
} else {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 4.6e-73: tmp = -U_m else: tmp = J * (-2.0 * math.cos((K * 0.5))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 4.6e-73) tmp = Float64(-U_m); else tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 4.6e-73) tmp = -U_m; else tmp = J * (-2.0 * cos((K * 0.5))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 4.6e-73], (-U$95$m), N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 4.6 \cdot 10^{-73}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if J < 4.59999999999999977e-73Initial program 66.9%
Simplified80.7%
Taylor expanded in J around 0 34.4%
neg-mul-134.4%
Simplified34.4%
if 4.59999999999999977e-73 < J Initial program 88.4%
Simplified99.8%
Taylor expanded in U around 0 78.3%
Final simplification46.7%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= J 26.0) (and (not (<= J 1.35e+31)) (<= J 5.2e+70))) (- U_m) (* -2.0 J)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if ((J <= 26.0) || (!(J <= 1.35e+31) && (J <= 5.2e+70))) {
tmp = -U_m;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: tmp
if ((j <= 26.0d0) .or. (.not. (j <= 1.35d+31)) .and. (j <= 5.2d+70)) then
tmp = -u_m
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if ((J <= 26.0) || (!(J <= 1.35e+31) && (J <= 5.2e+70))) {
tmp = -U_m;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if (J <= 26.0) or (not (J <= 1.35e+31) and (J <= 5.2e+70)): tmp = -U_m else: tmp = -2.0 * J return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if ((J <= 26.0) || (!(J <= 1.35e+31) && (J <= 5.2e+70))) tmp = Float64(-U_m); else tmp = Float64(-2.0 * J); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if ((J <= 26.0) || (~((J <= 1.35e+31)) && (J <= 5.2e+70))) tmp = -U_m; else tmp = -2.0 * J; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[Or[LessEqual[J, 26.0], And[N[Not[LessEqual[J, 1.35e+31]], $MachinePrecision], LessEqual[J, 5.2e+70]]], (-U$95$m), N[(-2.0 * J), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 26 \lor \neg \left(J \leq 1.35 \cdot 10^{+31}\right) \land J \leq 5.2 \cdot 10^{+70}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 26 or 1.34999999999999993e31 < J < 5.2000000000000001e70Initial program 67.7%
Simplified83.3%
Taylor expanded in J around 0 32.0%
neg-mul-132.0%
Simplified32.0%
if 26 < J < 1.34999999999999993e31 or 5.2000000000000001e70 < J Initial program 98.0%
Simplified99.9%
Taylor expanded in U around 0 92.7%
Taylor expanded in K around 0 53.1%
Final simplification35.6%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (- U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
return -U_m;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
code = -u_m
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
return -U_m;
}
U_m = math.fabs(U) def code(J, K, U_m): return -U_m
U_m = abs(U) function code(J, K, U_m) return Float64(-U_m) end
U_m = abs(U); function tmp = code(J, K, U_m) tmp = -U_m; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := (-U$95$m)
\begin{array}{l}
U_m = \left|U\right|
\\
-U\_m
\end{array}
Initial program 72.9%
Simplified86.1%
Taylor expanded in J around 0 27.5%
neg-mul-127.5%
Simplified27.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 U_m)
U_m = fabs(U);
double code(double J, double K, double U_m) {
return U_m;
}
U_m = abs(u)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
code = u_m
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
return U_m;
}
U_m = math.fabs(U) def code(J, K, U_m): return U_m
U_m = abs(U) function code(J, K, U_m) return U_m end
U_m = abs(U); function tmp = code(J, K, U_m) tmp = U_m; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := U$95$m
\begin{array}{l}
U_m = \left|U\right|
\\
U\_m
\end{array}
Initial program 72.9%
Simplified86.1%
Taylor expanded in U around -inf 22.7%
herbie shell --seed 2024089
(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)))))