
(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 7 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 0.5)))
(t_1 (cos (/ K 2.0)))
(t_2
(*
(* (* -2.0 J) t_1)
(sqrt (+ 1.0 (pow (/ U_m (* t_1 (* J 2.0))) 2.0))))))
(if (<= t_2 (- INFINITY))
(- U_m)
(if (<= t_2 4e+302)
(* J (* (hypot 1.0 (* -0.5 (/ (/ U_m J) t_0))) (* -2.0 t_0)))
U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K * 0.5));
double t_1 = cos((K / 2.0));
double t_2 = ((-2.0 * J) * t_1) * sqrt((1.0 + pow((U_m / (t_1 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_2 <= 4e+302) {
tmp = J * (hypot(1.0, (-0.5 * ((U_m / J) / t_0))) * (-2.0 * 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 * 0.5));
double t_1 = Math.cos((K / 2.0));
double t_2 = ((-2.0 * J) * t_1) * Math.sqrt((1.0 + Math.pow((U_m / (t_1 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = -U_m;
} else if (t_2 <= 4e+302) {
tmp = J * (Math.hypot(1.0, (-0.5 * ((U_m / J) / t_0))) * (-2.0 * t_0));
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K * 0.5)) t_1 = math.cos((K / 2.0)) t_2 = ((-2.0 * J) * t_1) * math.sqrt((1.0 + math.pow((U_m / (t_1 * (J * 2.0))), 2.0))) tmp = 0 if t_2 <= -math.inf: tmp = -U_m elif t_2 <= 4e+302: tmp = J * (math.hypot(1.0, (-0.5 * ((U_m / J) / t_0))) * (-2.0 * t_0)) else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K * 0.5)) t_1 = cos(Float64(K / 2.0)) t_2 = Float64(Float64(Float64(-2.0 * J) * t_1) * sqrt(Float64(1.0 + (Float64(U_m / Float64(t_1 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_2 <= 4e+302) tmp = Float64(J * Float64(hypot(1.0, Float64(-0.5 * Float64(Float64(U_m / J) / t_0))) * Float64(-2.0 * t_0))); else tmp = U_m; end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K * 0.5)); t_1 = cos((K / 2.0)); t_2 = ((-2.0 * J) * t_1) * sqrt((1.0 + ((U_m / (t_1 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_2 <= -Inf) tmp = -U_m; elseif (t_2 <= 4e+302) tmp = J * (hypot(1.0, (-0.5 * ((U_m / J) / t_0))) * (-2.0 * 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 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$1), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U$95$m / N[(t$95$1 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], (-U$95$m), If[LessEqual[t$95$2, 4e+302], N[(J * N[(N[Sqrt[1.0 ^ 2 + N[(-0.5 * N[(N[(U$95$m / J), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], U$95$m]]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := \cos \left(\frac{K}{2}\right)\\
t_2 := \left(\left(-2 \cdot J\right) \cdot t\_1\right) \cdot \sqrt{1 + {\left(\frac{U\_m}{t\_1 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+302}:\\
\;\;\;\;J \cdot \left(\mathsf{hypot}\left(1, -0.5 \cdot \frac{\frac{U\_m}{J}}{t\_0}\right) \cdot \left(-2 \cdot t\_0\right)\right)\\
\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 4.6%
Simplified73.6%
Taylor expanded in J around 0 38.6%
neg-mul-138.6%
Simplified38.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.0000000000000003e302Initial program 99.8%
unpow299.8%
hypot-1-def99.8%
associate-/r*99.8%
cos-neg99.8%
distribute-frac-neg99.8%
associate-/r*99.8%
hypot-1-def99.8%
unpow299.8%
Simplified99.8%
log1p-expm1-u99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Applied egg-rr99.8%
unpow199.8%
*-lft-identity99.8%
times-frac99.8%
metadata-eval99.8%
*-commutative99.8%
associate-/r*99.8%
*-commutative99.8%
Simplified99.8%
if 4.0000000000000003e302 < (*.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%
Simplified61.9%
Taylor expanded in U around -inf 45.1%
Final simplification82.8%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (* (* -2.0 J) (cos (* K 0.5)))))
(if (<= t_0 -0.8326)
t_1
(if (<= t_0 -0.22)
U_m
(if (<= t_0 1.0)
t_1
(* (* -2.0 J) (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 t_1 = (-2.0 * J) * cos((K * 0.5));
double tmp;
if (t_0 <= -0.8326) {
tmp = t_1;
} else if (t_0 <= -0.22) {
tmp = U_m;
} else if (t_0 <= 1.0) {
tmp = t_1;
} else {
tmp = (-2.0 * J) * 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 t_1 = (-2.0 * J) * Math.cos((K * 0.5));
double tmp;
if (t_0 <= -0.8326) {
tmp = t_1;
} else if (t_0 <= -0.22) {
tmp = U_m;
} else if (t_0 <= 1.0) {
tmp = t_1;
} else {
tmp = (-2.0 * J) * 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)) t_1 = (-2.0 * J) * math.cos((K * 0.5)) tmp = 0 if t_0 <= -0.8326: tmp = t_1 elif t_0 <= -0.22: tmp = U_m elif t_0 <= 1.0: tmp = t_1 else: tmp = (-2.0 * J) * 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)) t_1 = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) tmp = 0.0 if (t_0 <= -0.8326) tmp = t_1; elseif (t_0 <= -0.22) tmp = U_m; elseif (t_0 <= 1.0) tmp = t_1; else tmp = Float64(Float64(-2.0 * J) * 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)); t_1 = (-2.0 * J) * cos((K * 0.5)); tmp = 0.0; if (t_0 <= -0.8326) tmp = t_1; elseif (t_0 <= -0.22) tmp = U_m; elseif (t_0 <= 1.0) tmp = t_1; else tmp = (-2.0 * J) * 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]}, Block[{t$95$1 = N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.8326], t$95$1, If[LessEqual[t$95$0, -0.22], U$95$m, If[LessEqual[t$95$0, 1.0], t$95$1, N[(N[(-2.0 * J), $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)\\
t_1 := \left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq -0.8326:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -0.22:\\
\;\;\;\;U\_m\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{J \cdot 2}}{t\_0}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.83260000000000001 or -0.220000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 1Initial program 75.5%
Simplified90.2%
Taylor expanded in J around inf 55.4%
associate-*r*55.4%
Simplified55.4%
if -0.83260000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.220000000000000001Initial program 44.8%
Simplified87.3%
Taylor expanded in U around -inf 39.9%
if 1 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 71.8%
unpow271.8%
hypot-1-def90.0%
associate-/r*89.9%
cos-neg89.9%
distribute-frac-neg89.9%
associate-/r*90.0%
hypot-1-def71.8%
unpow271.8%
Simplified89.9%
Taylor expanded in K around 0 48.7%
Final simplification53.5%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U_m 6.8e+245)
(* 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.8e+245) {
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.8e+245) {
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.8e+245: 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.8e+245) 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.8e+245) 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.8e+245], 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.8 \cdot 10^{+245}:\\
\;\;\;\;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.79999999999999996e245Initial program 73.8%
Simplified92.1%
if 6.79999999999999996e245 < U Initial program 25.1%
Simplified40.8%
Taylor expanded in J around 0 27.4%
neg-mul-127.4%
Simplified27.4%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 1400.0) (* (* -2.0 J) (cos (* K 0.5))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1400.0) {
tmp = (-2.0 * J) * cos((K * 0.5));
} 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 <= 1400.0d0) then
tmp = ((-2.0d0) * j) * cos((k * 0.5d0))
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 <= 1400.0) {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 1400.0: tmp = (-2.0 * J) * math.cos((K * 0.5)) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 1400.0) tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))); 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 <= 1400.0) tmp = (-2.0 * J) * cos((K * 0.5)); 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, 1400.0], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 1400:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1400Initial program 77.7%
Simplified92.6%
Taylor expanded in J around inf 61.5%
associate-*r*61.5%
Simplified61.5%
if 1400 < U Initial program 52.0%
Simplified80.7%
Taylor expanded in J around 0 29.7%
neg-mul-129.7%
Simplified29.7%
Final simplification54.2%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 5.6e+29) (- U_m) (* -2.0 J)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 5.6e+29) {
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 <= 5.6d+29) 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 <= 5.6e+29) {
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 <= 5.6e+29: 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 <= 5.6e+29) 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 <= 5.6e+29) 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[LessEqual[J, 5.6e+29], (-U$95$m), N[(-2.0 * J), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 5.6 \cdot 10^{+29}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 5.5999999999999999e29Initial program 63.8%
Simplified86.6%
Taylor expanded in J around 0 30.5%
neg-mul-130.5%
Simplified30.5%
if 5.5999999999999999e29 < J Initial program 95.6%
Simplified99.8%
Taylor expanded in J around inf 82.2%
associate-*r*82.2%
Simplified82.2%
Taylor expanded in K around 0 49.9%
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 71.8%
Simplified89.9%
Taylor expanded in J around 0 25.4%
neg-mul-125.4%
Simplified25.4%
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 71.8%
Simplified89.9%
Taylor expanded in U around -inf 27.0%
herbie shell --seed 2024158
(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)))))