
(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 9 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 5e+304) 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 <= 5e+304) {
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 <= 5e+304) {
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 <= 5e+304: 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 <= 5e+304) 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 <= 5e+304) 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, 5e+304], 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 5 \cdot 10^{+304}:\\
\;\;\;\;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 6.0%
Simplified50.4%
Taylor expanded in J around 0 63.6%
neg-mul-163.6%
Simplified63.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))))) < 4.9999999999999997e304Initial program 99.8%
if 4.9999999999999997e304 < (*.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.7%
Simplified57.8%
Taylor expanded in U around -inf 60.3%
Final simplification89.4%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U_m 6.4e+198)
(* J (* (* -2.0 t_0) (hypot 1.0 (/ (/ U_m 2.0) (* J t_0)))))
(- U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (U_m <= 6.4e+198) {
tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J * t_0))));
} 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 tmp;
if (U_m <= 6.4e+198) {
tmp = J * ((-2.0 * t_0) * Math.hypot(1.0, ((U_m / 2.0) / (J * t_0))));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if U_m <= 6.4e+198: tmp = J * ((-2.0 * t_0) * math.hypot(1.0, ((U_m / 2.0) / (J * t_0)))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (U_m <= 6.4e+198) tmp = Float64(J * Float64(Float64(-2.0 * t_0) * hypot(1.0, Float64(Float64(U_m / 2.0) / Float64(J * t_0))))); else tmp = Float64(-U_m); 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 (U_m <= 6.4e+198) tmp = J * ((-2.0 * t_0) * hypot(1.0, ((U_m / 2.0) / (J * t_0)))); 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]}, If[LessEqual[U$95$m, 6.4e+198], 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], (-U$95$m)]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U\_m \leq 6.4 \cdot 10^{+198}:\\
\;\;\;\;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)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 6.3999999999999997e198Initial program 78.6%
Simplified91.5%
if 6.3999999999999997e198 < U Initial program 37.4%
Simplified53.7%
Taylor expanded in J around 0 50.7%
neg-mul-150.7%
Simplified50.7%
Final simplification87.1%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* J (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J))))))
(if (<= U_m 1.8e+35)
t_0
(if (<= U_m 1.15e+82)
(/ (* J U_m) (- J))
(if (<= U_m 1.2e+184) t_0 (- U_m))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J)));
double tmp;
if (U_m <= 1.8e+35) {
tmp = t_0;
} else if (U_m <= 1.15e+82) {
tmp = (J * U_m) / -J;
} else if (U_m <= 1.2e+184) {
tmp = t_0;
} 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 = J * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 2.0) / J)));
double tmp;
if (U_m <= 1.8e+35) {
tmp = t_0;
} else if (U_m <= 1.15e+82) {
tmp = (J * U_m) / -J;
} else if (U_m <= 1.2e+184) {
tmp = t_0;
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = J * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 2.0) / J))) tmp = 0 if U_m <= 1.8e+35: tmp = t_0 elif U_m <= 1.15e+82: tmp = (J * U_m) / -J elif U_m <= 1.2e+184: tmp = t_0 else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(J * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J)))) tmp = 0.0 if (U_m <= 1.8e+35) tmp = t_0; elseif (U_m <= 1.15e+82) tmp = Float64(Float64(J * U_m) / Float64(-J)); elseif (U_m <= 1.2e+184) tmp = t_0; else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J))); tmp = 0.0; if (U_m <= 1.8e+35) tmp = t_0; elseif (U_m <= 1.15e+82) tmp = (J * U_m) / -J; elseif (U_m <= 1.2e+184) tmp = t_0; 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[(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]}, If[LessEqual[U$95$m, 1.8e+35], t$95$0, If[LessEqual[U$95$m, 1.15e+82], N[(N[(J * U$95$m), $MachinePrecision] / (-J)), $MachinePrecision], If[LessEqual[U$95$m, 1.2e+184], t$95$0, (-U$95$m)]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := 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)\\
\mathbf{if}\;U\_m \leq 1.8 \cdot 10^{+35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;U\_m \leq 1.15 \cdot 10^{+82}:\\
\;\;\;\;\frac{J \cdot U\_m}{-J}\\
\mathbf{elif}\;U\_m \leq 1.2 \cdot 10^{+184}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1.8e35 or 1.14999999999999994e82 < U < 1.19999999999999998e184Initial program 79.7%
Simplified91.1%
Taylor expanded in K around 0 81.3%
if 1.8e35 < U < 1.14999999999999994e82Initial program 72.0%
Simplified99.8%
Taylor expanded in U around inf 29.4%
associate-*r/29.4%
neg-mul-129.4%
Simplified29.4%
distribute-frac-neg29.4%
distribute-frac-neg229.4%
associate-*r/29.2%
Applied egg-rr29.2%
if 1.19999999999999998e184 < U Initial program 38.2%
Simplified60.7%
Taylor expanded in J around 0 49.3%
neg-mul-149.3%
Simplified49.3%
Final simplification75.8%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= U_m 1.8e+35)
(* (* -2.0 (cos (* K 0.5))) (* J (hypot 1.0 (* 0.5 (/ U_m J)))))
(if (<= U_m 1.2e+75)
(/ (* J U_m) (- J))
(if (<= U_m 1.08e+184)
(* J (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J))))
(- U_m)))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.8e+35) {
tmp = (-2.0 * cos((K * 0.5))) * (J * hypot(1.0, (0.5 * (U_m / J))));
} else if (U_m <= 1.2e+75) {
tmp = (J * U_m) / -J;
} else if (U_m <= 1.08e+184) {
tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J)));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.8e+35) {
tmp = (-2.0 * Math.cos((K * 0.5))) * (J * Math.hypot(1.0, (0.5 * (U_m / J))));
} else if (U_m <= 1.2e+75) {
tmp = (J * U_m) / -J;
} else if (U_m <= 1.08e+184) {
tmp = J * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 2.0) / J)));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 1.8e+35: tmp = (-2.0 * math.cos((K * 0.5))) * (J * math.hypot(1.0, (0.5 * (U_m / J)))) elif U_m <= 1.2e+75: tmp = (J * U_m) / -J elif U_m <= 1.08e+184: tmp = J * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 2.0) / J))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 1.8e+35) tmp = Float64(Float64(-2.0 * cos(Float64(K * 0.5))) * Float64(J * hypot(1.0, Float64(0.5 * Float64(U_m / J))))); elseif (U_m <= 1.2e+75) tmp = Float64(Float64(J * U_m) / Float64(-J)); elseif (U_m <= 1.08e+184) tmp = Float64(J * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J)))); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (U_m <= 1.8e+35) tmp = (-2.0 * cos((K * 0.5))) * (J * hypot(1.0, (0.5 * (U_m / J)))); elseif (U_m <= 1.2e+75) tmp = (J * U_m) / -J; elseif (U_m <= 1.08e+184) tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J))); else tmp = -U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 1.8e+35], N[(N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(J * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 1.2e+75], N[(N[(J * U$95$m), $MachinePrecision] / (-J)), $MachinePrecision], If[LessEqual[U$95$m, 1.08e+184], 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], (-U$95$m)]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 1.8 \cdot 10^{+35}:\\
\;\;\;\;\left(-2 \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U\_m}{J}\right)\right)\\
\mathbf{elif}\;U\_m \leq 1.2 \cdot 10^{+75}:\\
\;\;\;\;\frac{J \cdot U\_m}{-J}\\
\mathbf{elif}\;U\_m \leq 1.08 \cdot 10^{+184}:\\
\;\;\;\;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)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1.8e35Initial program 82.7%
Simplified93.0%
Applied egg-rr91.2%
Taylor expanded in K around 0 80.6%
rem-cube-cbrt82.1%
*-commutative82.1%
associate-*l*82.1%
rem-cube-cbrt79.4%
*-commutative79.4%
rem-cube-cbrt82.1%
*-commutative82.1%
div-inv82.1%
associate-*l*82.1%
associate-*l/82.1%
*-un-lft-identity82.1%
Applied egg-rr82.1%
if 1.8e35 < U < 1.2e75Initial program 72.0%
Simplified99.8%
Taylor expanded in U around inf 29.4%
associate-*r/29.4%
neg-mul-129.4%
Simplified29.4%
distribute-frac-neg29.4%
distribute-frac-neg229.4%
associate-*r/29.2%
Applied egg-rr29.2%
if 1.2e75 < U < 1.07999999999999993e184Initial program 54.3%
Simplified75.0%
Taylor expanded in K around 0 75.0%
if 1.07999999999999993e184 < U Initial program 38.2%
Simplified60.7%
Taylor expanded in J around 0 49.3%
neg-mul-149.3%
Simplified49.3%
Final simplification75.8%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* -2.0 (* J (hypot 1.0 (* 0.5 (/ U_m J))))))
(t_1 (* (* -2.0 J) (cos (* K 0.5)))))
(if (<= U_m 4.5e-139)
t_1
(if (<= U_m 7.8e-115)
t_0
(if (<= U_m 22000000000.0) t_1 (if (<= U_m 1.4e+180) t_0 (- U_m)))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = -2.0 * (J * hypot(1.0, (0.5 * (U_m / J))));
double t_1 = (-2.0 * J) * cos((K * 0.5));
double tmp;
if (U_m <= 4.5e-139) {
tmp = t_1;
} else if (U_m <= 7.8e-115) {
tmp = t_0;
} else if (U_m <= 22000000000.0) {
tmp = t_1;
} else if (U_m <= 1.4e+180) {
tmp = t_0;
} 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 = -2.0 * (J * Math.hypot(1.0, (0.5 * (U_m / J))));
double t_1 = (-2.0 * J) * Math.cos((K * 0.5));
double tmp;
if (U_m <= 4.5e-139) {
tmp = t_1;
} else if (U_m <= 7.8e-115) {
tmp = t_0;
} else if (U_m <= 22000000000.0) {
tmp = t_1;
} else if (U_m <= 1.4e+180) {
tmp = t_0;
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = -2.0 * (J * math.hypot(1.0, (0.5 * (U_m / J)))) t_1 = (-2.0 * J) * math.cos((K * 0.5)) tmp = 0 if U_m <= 4.5e-139: tmp = t_1 elif U_m <= 7.8e-115: tmp = t_0 elif U_m <= 22000000000.0: tmp = t_1 elif U_m <= 1.4e+180: tmp = t_0 else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(-2.0 * Float64(J * hypot(1.0, Float64(0.5 * Float64(U_m / J))))) t_1 = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) tmp = 0.0 if (U_m <= 4.5e-139) tmp = t_1; elseif (U_m <= 7.8e-115) tmp = t_0; elseif (U_m <= 22000000000.0) tmp = t_1; elseif (U_m <= 1.4e+180) tmp = t_0; else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = -2.0 * (J * hypot(1.0, (0.5 * (U_m / J)))); t_1 = (-2.0 * J) * cos((K * 0.5)); tmp = 0.0; if (U_m <= 4.5e-139) tmp = t_1; elseif (U_m <= 7.8e-115) tmp = t_0; elseif (U_m <= 22000000000.0) tmp = t_1; elseif (U_m <= 1.4e+180) tmp = t_0; 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[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U$95$m, 4.5e-139], t$95$1, If[LessEqual[U$95$m, 7.8e-115], t$95$0, If[LessEqual[U$95$m, 22000000000.0], t$95$1, If[LessEqual[U$95$m, 1.4e+180], t$95$0, (-U$95$m)]]]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U\_m}{J}\right)\right)\\
t_1 := \left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;U\_m \leq 4.5 \cdot 10^{-139}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;U\_m \leq 7.8 \cdot 10^{-115}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;U\_m \leq 22000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;U\_m \leq 1.4 \cdot 10^{+180}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 4.50000000000000023e-139 or 7.7999999999999997e-115 < U < 2.2e10Initial program 83.3%
Simplified92.6%
Taylor expanded in J around inf 65.5%
associate-*r*65.5%
*-commutative65.5%
*-commutative65.5%
*-commutative65.5%
*-commutative65.5%
*-commutative65.5%
Simplified65.5%
if 4.50000000000000023e-139 < U < 7.7999999999999997e-115 or 2.2e10 < U < 1.40000000000000006e180Initial program 62.9%
Simplified85.2%
Applied egg-rr83.4%
rem-cube-cbrt85.0%
*-commutative85.0%
add-sqr-sqrt38.6%
associate-*r*38.6%
Applied egg-rr38.6%
Taylor expanded in K around 0 40.1%
metadata-eval40.1%
metadata-eval40.1%
unpow240.1%
unpow240.1%
times-frac50.2%
swap-sqr50.2%
hypot-undefine72.5%
Simplified72.5%
if 1.40000000000000006e180 < U Initial program 37.2%
Simplified61.9%
Taylor expanded in J around 0 47.9%
neg-mul-147.9%
Simplified47.9%
Final simplification64.2%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* (* -2.0 J) (cos (* K 0.5)))))
(if (<= U_m 1.65e+27)
t_0
(if (<= U_m 1e+121)
(/ (* J U_m) (- J))
(if (<= U_m 9e+158) t_0 (- U_m))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = (-2.0 * J) * cos((K * 0.5));
double tmp;
if (U_m <= 1.65e+27) {
tmp = t_0;
} else if (U_m <= 1e+121) {
tmp = (J * U_m) / -J;
} else if (U_m <= 9e+158) {
tmp = t_0;
} else {
tmp = -U_m;
}
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) :: t_0
real(8) :: tmp
t_0 = ((-2.0d0) * j) * cos((k * 0.5d0))
if (u_m <= 1.65d+27) then
tmp = t_0
else if (u_m <= 1d+121) then
tmp = (j * u_m) / -j
else if (u_m <= 9d+158) then
tmp = t_0
else
tmp = -u_m
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = (-2.0 * J) * Math.cos((K * 0.5));
double tmp;
if (U_m <= 1.65e+27) {
tmp = t_0;
} else if (U_m <= 1e+121) {
tmp = (J * U_m) / -J;
} else if (U_m <= 9e+158) {
tmp = t_0;
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = (-2.0 * J) * math.cos((K * 0.5)) tmp = 0 if U_m <= 1.65e+27: tmp = t_0 elif U_m <= 1e+121: tmp = (J * U_m) / -J elif U_m <= 9e+158: tmp = t_0 else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) tmp = 0.0 if (U_m <= 1.65e+27) tmp = t_0; elseif (U_m <= 1e+121) tmp = Float64(Float64(J * U_m) / Float64(-J)); elseif (U_m <= 9e+158) tmp = t_0; else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = (-2.0 * J) * cos((K * 0.5)); tmp = 0.0; if (U_m <= 1.65e+27) tmp = t_0; elseif (U_m <= 1e+121) tmp = (J * U_m) / -J; elseif (U_m <= 9e+158) tmp = t_0; 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[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U$95$m, 1.65e+27], t$95$0, If[LessEqual[U$95$m, 1e+121], N[(N[(J * U$95$m), $MachinePrecision] / (-J)), $MachinePrecision], If[LessEqual[U$95$m, 9e+158], t$95$0, (-U$95$m)]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;U\_m \leq 1.65 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;U\_m \leq 10^{+121}:\\
\;\;\;\;\frac{J \cdot U\_m}{-J}\\
\mathbf{elif}\;U\_m \leq 9 \cdot 10^{+158}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1.6499999999999999e27 or 1.00000000000000004e121 < U < 9.00000000000000092e158Initial program 82.6%
Simplified92.2%
Taylor expanded in J around inf 64.5%
associate-*r*64.5%
*-commutative64.5%
*-commutative64.5%
*-commutative64.5%
*-commutative64.5%
*-commutative64.5%
Simplified64.5%
if 1.6499999999999999e27 < U < 1.00000000000000004e121Initial program 59.3%
Simplified84.7%
Taylor expanded in U around inf 23.2%
associate-*r/23.2%
neg-mul-123.2%
Simplified23.2%
distribute-frac-neg23.2%
distribute-frac-neg223.2%
associate-*r/28.2%
Applied egg-rr28.2%
if 9.00000000000000092e158 < U Initial program 38.0%
Simplified64.3%
Taylor expanded in J around 0 41.9%
neg-mul-141.9%
Simplified41.9%
Final simplification58.4%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 1.7e+26) (* -2.0 J) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.7e+26) {
tmp = -2.0 * J;
} else {
tmp = -U_m;
}
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 (u_m <= 1.7d+26) then
tmp = (-2.0d0) * j
else
tmp = -u_m
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 (U_m <= 1.7e+26) {
tmp = -2.0 * J;
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 1.7e+26: tmp = -2.0 * J else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 1.7e+26) tmp = Float64(-2.0 * J); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (U_m <= 1.7e+26) tmp = -2.0 * J; else tmp = -U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 1.7e+26], N[(-2.0 * J), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 1.7 \cdot 10^{+26}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1.7000000000000001e26Initial program 83.1%
Simplified93.0%
Applied egg-rr91.2%
Taylor expanded in J around inf 63.3%
Taylor expanded in K around 0 38.3%
rem-cube-cbrt39.5%
Simplified39.5%
if 1.7000000000000001e26 < U Initial program 47.1%
Simplified70.7%
Taylor expanded in J around 0 34.2%
neg-mul-134.2%
Simplified34.2%
Final simplification38.2%
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 74.1%
Simplified87.4%
Taylor expanded in J around 0 25.7%
neg-mul-125.7%
Simplified25.7%
Final simplification25.7%
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 74.1%
Simplified87.4%
Taylor expanded in U around -inf 25.2%
Final simplification25.2%
herbie shell --seed 2024073
(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)))))