
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}
\end{array}
\end{array}
U_m = (fabs.f64 U)
(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)))))
(t_2 (* J t_0)))
(if (<= t_1 (- INFINITY))
(- U_m)
(if (<= t_1 5e+304)
(* -2.0 (* t_2 (hypot 1.0 (/ (/ U_m 2.0) t_2))))
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 t_2 = J * t_0;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_1 <= 5e+304) {
tmp = -2.0 * (t_2 * hypot(1.0, ((U_m / 2.0) / t_2)));
} 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 t_2 = J * t_0;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U_m;
} else if (t_1 <= 5e+304) {
tmp = -2.0 * (t_2 * Math.hypot(1.0, ((U_m / 2.0) / t_2)));
} 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))) t_2 = J * t_0 tmp = 0 if t_1 <= -math.inf: tmp = -U_m elif t_1 <= 5e+304: tmp = -2.0 * (t_2 * math.hypot(1.0, ((U_m / 2.0) / t_2))) 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)))) t_2 = Float64(J * t_0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_1 <= 5e+304) tmp = Float64(-2.0 * Float64(t_2 * hypot(1.0, Float64(Float64(U_m / 2.0) / t_2)))); 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))); t_2 = J * t_0; tmp = 0.0; if (t_1 <= -Inf) tmp = -U_m; elseif (t_1 <= 5e+304) tmp = -2.0 * (t_2 * hypot(1.0, ((U_m / 2.0) / t_2))); 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]}, Block[{t$95$2 = N[(J * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U$95$m), If[LessEqual[t$95$1, 5e+304], N[(-2.0 * N[(t$95$2 * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / t$95$2), $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)\\
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}}\\
t_2 := J \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;-2 \cdot \left(t\_2 \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{t\_2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < -inf.0Initial program 6.0%
Simplified6.0%
Taylor expanded in J around 0 66.9%
mul-1-neg66.9%
Simplified66.9%
if -inf.0 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < 4.9999999999999997e304Initial program 99.8%
associate-*l*99.8%
associate-*l*99.8%
unpow299.8%
sqr-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg99.8%
unpow299.8%
Simplified99.8%
if 4.9999999999999997e304 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) Initial program 5.9%
Simplified5.9%
Taylor expanded in U around -inf 40.4%
Final simplification86.7%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (cos (* K 0.5))))
(if (<= t_0 -0.795)
(+ (* -2.0 (* J t_1)) (* -0.25 (* (/ U_m t_1) (/ U_m J))))
(if (<= t_0 -0.02) U_m (* -2.0 (* J (hypot 1.0 (/ (/ U_m 2.0) J))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = cos((K * 0.5));
double tmp;
if (t_0 <= -0.795) {
tmp = (-2.0 * (J * t_1)) + (-0.25 * ((U_m / t_1) * (U_m / J)));
} else if (t_0 <= -0.02) {
tmp = U_m;
} else {
tmp = -2.0 * (J * 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 t_0 = Math.cos((K / 2.0));
double t_1 = Math.cos((K * 0.5));
double tmp;
if (t_0 <= -0.795) {
tmp = (-2.0 * (J * t_1)) + (-0.25 * ((U_m / t_1) * (U_m / J)));
} else if (t_0 <= -0.02) {
tmp = U_m;
} else {
tmp = -2.0 * (J * Math.hypot(1.0, ((U_m / 2.0) / J)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = math.cos((K * 0.5)) tmp = 0 if t_0 <= -0.795: tmp = (-2.0 * (J * t_1)) + (-0.25 * ((U_m / t_1) * (U_m / J))) elif t_0 <= -0.02: tmp = U_m else: tmp = -2.0 * (J * math.hypot(1.0, ((U_m / 2.0) / J))) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = cos(Float64(K * 0.5)) tmp = 0.0 if (t_0 <= -0.795) tmp = Float64(Float64(-2.0 * Float64(J * t_1)) + Float64(-0.25 * Float64(Float64(U_m / t_1) * Float64(U_m / J)))); elseif (t_0 <= -0.02) tmp = U_m; else tmp = Float64(-2.0 * Float64(J * 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) t_0 = cos((K / 2.0)); t_1 = cos((K * 0.5)); tmp = 0.0; if (t_0 <= -0.795) tmp = (-2.0 * (J * t_1)) + (-0.25 * ((U_m / t_1) * (U_m / J))); elseif (t_0 <= -0.02) tmp = U_m; else tmp = -2.0 * (J * 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_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.795], N[(N[(-2.0 * N[(J * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(N[(U$95$m / t$95$1), $MachinePrecision] * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.02], U$95$m, N[(-2.0 * N[(J * 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}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq -0.795:\\
\;\;\;\;-2 \cdot \left(J \cdot t\_1\right) + -0.25 \cdot \left(\frac{U\_m}{t\_1} \cdot \frac{U\_m}{J}\right)\\
\mathbf{elif}\;t\_0 \leq -0.02:\\
\;\;\;\;U\_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.79500000000000004Initial program 75.1%
Simplified75.1%
Taylor expanded in J around inf 61.6%
unpow261.6%
*-commutative61.6%
times-frac61.6%
Applied egg-rr61.6%
if -0.79500000000000004 < (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 75.8%
Simplified75.8%
Taylor expanded in U around -inf 27.8%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 73.7%
associate-*l*73.7%
associate-*l*73.7%
unpow273.7%
sqr-neg73.7%
distribute-frac-neg73.7%
distribute-frac-neg73.7%
unpow273.7%
Simplified90.5%
Taylor expanded in K around 0 69.1%
Taylor expanded in K around 0 80.6%
Final simplification70.6%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.795)
(* -2.0 (* J (cos (* K 0.5))))
(if (<= t_0 -0.02) U_m (* -2.0 (* J (hypot 1.0 (/ (/ U_m 2.0) 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.795) {
tmp = -2.0 * (J * cos((K * 0.5)));
} else if (t_0 <= -0.02) {
tmp = U_m;
} else {
tmp = -2.0 * (J * 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 t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= -0.795) {
tmp = -2.0 * (J * Math.cos((K * 0.5)));
} else if (t_0 <= -0.02) {
tmp = U_m;
} else {
tmp = -2.0 * (J * Math.hypot(1.0, ((U_m / 2.0) / 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.795: tmp = -2.0 * (J * math.cos((K * 0.5))) elif t_0 <= -0.02: tmp = U_m else: tmp = -2.0 * (J * math.hypot(1.0, ((U_m / 2.0) / 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.795) tmp = Float64(-2.0 * Float64(J * cos(Float64(K * 0.5)))); elseif (t_0 <= -0.02) tmp = U_m; else tmp = Float64(-2.0 * Float64(J * 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) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= -0.795) tmp = -2.0 * (J * cos((K * 0.5))); elseif (t_0 <= -0.02) tmp = U_m; else tmp = -2.0 * (J * 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_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.795], N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.02], U$95$m, N[(-2.0 * N[(J * 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}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.795:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{elif}\;t\_0 \leq -0.02:\\
\;\;\;\;U\_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{2}}{J}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.79500000000000004Initial program 75.1%
associate-*l*75.1%
associate-*l*75.1%
unpow275.1%
sqr-neg75.1%
distribute-frac-neg75.1%
distribute-frac-neg75.1%
unpow275.1%
Simplified89.2%
Taylor expanded in U around 0 61.1%
if -0.79500000000000004 < (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 75.8%
Simplified75.8%
Taylor expanded in U around -inf 27.8%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 73.7%
associate-*l*73.7%
associate-*l*73.7%
unpow273.7%
sqr-neg73.7%
distribute-frac-neg73.7%
distribute-frac-neg73.7%
unpow273.7%
Simplified90.5%
Taylor expanded in K around 0 69.1%
Taylor expanded in K around 0 80.6%
Final simplification70.5%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* -2.0 (+ (* U_m 0.5) (* J (/ J U_m)))))
(t_1 (* -2.0 (* J (cos (* K 0.5))))))
(if (<= U_m 70000000.0)
t_1
(if (<= U_m 1.15e+57)
t_0
(if (<= U_m 2.4e+82)
t_1
(if (<= U_m 5.6e+133) t_0 (if (<= U_m 1.25e+160) t_1 (- U_m))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = -2.0 * ((U_m * 0.5) + (J * (J / U_m)));
double t_1 = -2.0 * (J * cos((K * 0.5)));
double tmp;
if (U_m <= 70000000.0) {
tmp = t_1;
} else if (U_m <= 1.15e+57) {
tmp = t_0;
} else if (U_m <= 2.4e+82) {
tmp = t_1;
} else if (U_m <= 5.6e+133) {
tmp = t_0;
} else if (U_m <= 1.25e+160) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = (-2.0d0) * ((u_m * 0.5d0) + (j * (j / u_m)))
t_1 = (-2.0d0) * (j * cos((k * 0.5d0)))
if (u_m <= 70000000.0d0) then
tmp = t_1
else if (u_m <= 1.15d+57) then
tmp = t_0
else if (u_m <= 2.4d+82) then
tmp = t_1
else if (u_m <= 5.6d+133) then
tmp = t_0
else if (u_m <= 1.25d+160) then
tmp = t_1
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 * ((U_m * 0.5) + (J * (J / U_m)));
double t_1 = -2.0 * (J * Math.cos((K * 0.5)));
double tmp;
if (U_m <= 70000000.0) {
tmp = t_1;
} else if (U_m <= 1.15e+57) {
tmp = t_0;
} else if (U_m <= 2.4e+82) {
tmp = t_1;
} else if (U_m <= 5.6e+133) {
tmp = t_0;
} else if (U_m <= 1.25e+160) {
tmp = t_1;
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = -2.0 * ((U_m * 0.5) + (J * (J / U_m))) t_1 = -2.0 * (J * math.cos((K * 0.5))) tmp = 0 if U_m <= 70000000.0: tmp = t_1 elif U_m <= 1.15e+57: tmp = t_0 elif U_m <= 2.4e+82: tmp = t_1 elif U_m <= 5.6e+133: tmp = t_0 elif U_m <= 1.25e+160: tmp = t_1 else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(-2.0 * Float64(Float64(U_m * 0.5) + Float64(J * Float64(J / U_m)))) t_1 = Float64(-2.0 * Float64(J * cos(Float64(K * 0.5)))) tmp = 0.0 if (U_m <= 70000000.0) tmp = t_1; elseif (U_m <= 1.15e+57) tmp = t_0; elseif (U_m <= 2.4e+82) tmp = t_1; elseif (U_m <= 5.6e+133) tmp = t_0; elseif (U_m <= 1.25e+160) tmp = t_1; 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 * ((U_m * 0.5) + (J * (J / U_m))); t_1 = -2.0 * (J * cos((K * 0.5))); tmp = 0.0; if (U_m <= 70000000.0) tmp = t_1; elseif (U_m <= 1.15e+57) tmp = t_0; elseif (U_m <= 2.4e+82) tmp = t_1; elseif (U_m <= 5.6e+133) tmp = t_0; elseif (U_m <= 1.25e+160) 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[(-2.0 * N[(N[(U$95$m * 0.5), $MachinePrecision] + N[(J * N[(J / U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U$95$m, 70000000.0], t$95$1, If[LessEqual[U$95$m, 1.15e+57], t$95$0, If[LessEqual[U$95$m, 2.4e+82], t$95$1, If[LessEqual[U$95$m, 5.6e+133], t$95$0, If[LessEqual[U$95$m, 1.25e+160], t$95$1, (-U$95$m)]]]]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := -2 \cdot \left(U\_m \cdot 0.5 + J \cdot \frac{J}{U\_m}\right)\\
t_1 := -2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;U\_m \leq 70000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;U\_m \leq 1.15 \cdot 10^{+57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;U\_m \leq 2.4 \cdot 10^{+82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;U\_m \leq 5.6 \cdot 10^{+133}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;U\_m \leq 1.25 \cdot 10^{+160}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 7e7 or 1.1499999999999999e57 < U < 2.39999999999999998e82 or 5.60000000000000033e133 < U < 1.25e160Initial program 80.7%
associate-*l*80.7%
associate-*l*80.7%
unpow280.7%
sqr-neg80.7%
distribute-frac-neg80.7%
distribute-frac-neg80.7%
unpow280.7%
Simplified93.8%
Taylor expanded in U around 0 59.8%
if 7e7 < U < 1.1499999999999999e57 or 2.39999999999999998e82 < U < 5.60000000000000033e133Initial program 62.4%
associate-*l*62.4%
associate-*l*62.4%
unpow262.4%
sqr-neg62.4%
distribute-frac-neg62.4%
distribute-frac-neg62.4%
unpow262.4%
Simplified83.8%
Taylor expanded in K around 0 58.6%
Taylor expanded in K around 0 72.5%
Taylor expanded in U around inf 39.8%
div-inv39.8%
unpow239.8%
associate-*l*39.8%
div-inv39.8%
Applied egg-rr39.8%
if 1.25e160 < U Initial program 42.0%
Simplified42.0%
Taylor expanded in J around 0 46.1%
mul-1-neg46.1%
Simplified46.1%
Final simplification56.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 1.2e-114) (* -2.0 J) (* -2.0 (+ (* U_m 0.5) (* J (/ J U_m))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.2e-114) {
tmp = -2.0 * J;
} else {
tmp = -2.0 * ((U_m * 0.5) + (J * (J / 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.2d-114) then
tmp = (-2.0d0) * j
else
tmp = (-2.0d0) * ((u_m * 0.5d0) + (j * (j / 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.2e-114) {
tmp = -2.0 * J;
} else {
tmp = -2.0 * ((U_m * 0.5) + (J * (J / U_m)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 1.2e-114: tmp = -2.0 * J else: tmp = -2.0 * ((U_m * 0.5) + (J * (J / U_m))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 1.2e-114) tmp = Float64(-2.0 * J); else tmp = Float64(-2.0 * Float64(Float64(U_m * 0.5) + Float64(J * Float64(J / 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.2e-114) tmp = -2.0 * J; else tmp = -2.0 * ((U_m * 0.5) + (J * (J / 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.2e-114], N[(-2.0 * J), $MachinePrecision], N[(-2.0 * N[(N[(U$95$m * 0.5), $MachinePrecision] + N[(J * N[(J / U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 1.2 \cdot 10^{-114}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U\_m \cdot 0.5 + J \cdot \frac{J}{U\_m}\right)\\
\end{array}
\end{array}
if U < 1.2000000000000001e-114Initial program 80.4%
associate-*l*80.4%
associate-*l*80.4%
unpow280.4%
sqr-neg80.4%
distribute-frac-neg80.4%
distribute-frac-neg80.4%
unpow280.4%
Simplified93.0%
Taylor expanded in U around 0 60.1%
Taylor expanded in K around 0 36.8%
if 1.2000000000000001e-114 < U Initial program 63.1%
associate-*l*63.1%
associate-*l*63.1%
unpow263.1%
sqr-neg63.1%
distribute-frac-neg63.1%
distribute-frac-neg63.1%
unpow263.1%
Simplified85.6%
Taylor expanded in K around 0 45.5%
Taylor expanded in K around 0 56.4%
Taylor expanded in U around inf 35.1%
div-inv35.1%
unpow235.1%
associate-*l*37.3%
div-inv37.3%
Applied egg-rr37.3%
Final simplification37.0%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 1e-114) (* -2.0 J) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1e-114) {
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 <= 1d-114) 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 <= 1e-114) {
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 <= 1e-114: 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 <= 1e-114) 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 <= 1e-114) 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, 1e-114], N[(-2.0 * J), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 10^{-114}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1.0000000000000001e-114Initial program 80.4%
associate-*l*80.4%
associate-*l*80.4%
unpow280.4%
sqr-neg80.4%
distribute-frac-neg80.4%
distribute-frac-neg80.4%
unpow280.4%
Simplified93.0%
Taylor expanded in U around 0 60.1%
Taylor expanded in K around 0 36.8%
if 1.0000000000000001e-114 < U Initial program 63.1%
Simplified63.1%
Taylor expanded in J around 0 37.2%
mul-1-neg37.2%
Simplified37.2%
Final simplification37.0%
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.2%
Simplified74.2%
Taylor expanded in J around 0 30.1%
mul-1-neg30.1%
Simplified30.1%
Final simplification30.1%
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.2%
Simplified74.2%
Taylor expanded in U around -inf 25.5%
Final simplification25.5%
herbie shell --seed 2024027
(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)))))