
(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 13 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+305)
t_1
(*
(- U_m)
(fma
-2.0
(* (pow (cos (* K 0.5)) 2.0) (/ (* J J) (* U_m U_m)))
-1.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) * 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+305) {
tmp = t_1;
} else {
tmp = -U_m * fma(-2.0, (pow(cos((K * 0.5)), 2.0) * ((J * J) / (U_m * U_m))), -1.0);
}
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+305) tmp = t_1; else tmp = Float64(Float64(-U_m) * fma(-2.0, Float64((cos(Float64(K * 0.5)) ^ 2.0) * Float64(Float64(J * J) / Float64(U_m * U_m))), -1.0)); end return 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+305], t$95$1, N[((-U$95$m) * N[(-2.0 * N[(N[Power[N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(J * J), $MachinePrecision] / N[(U$95$m * U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\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^{+305}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(-U\_m\right) \cdot \mathsf{fma}\left(-2, {\cos \left(K \cdot 0.5\right)}^{2} \cdot \frac{J \cdot J}{U\_m \cdot U\_m}, -1\right)\\
\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.3%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6450.4
Applied rewrites50.4%
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))))) < 5.00000000000000009e305Initial program 99.8%
if 5.00000000000000009e305 < (*.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.8%
Taylor expanded in U around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6446.5
Applied rewrites46.5%
Final simplification85.5%
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))
(t_2 (* t_1 (sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0)))))
(t_3 (cos (* K 0.5)))
(t_4
(*
J
(*
(* -2.0 t_3)
(sqrt (fma U_m (/ U_m (* (* J 2.0) (fma J (cos K) J))) 1.0))))))
(if (<= t_2 (- INFINITY))
(- U_m)
(if (<= t_2 -3e-95)
t_4
(if (<= t_2 1e-50)
(* t_1 (sqrt (+ 1.0 (pow (* 0.5 (/ U_m J)) 2.0))))
(if (<= t_2 5e+301)
t_4
(/ (* (- U_m) t_3) (sqrt (fma (cos K) 0.5 0.5)))))))))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;
double t_2 = t_1 * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double t_3 = cos((K * 0.5));
double t_4 = J * ((-2.0 * t_3) * sqrt(fma(U_m, (U_m / ((J * 2.0) * fma(J, cos(K), J))), 1.0)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_2 <= -3e-95) {
tmp = t_4;
} else if (t_2 <= 1e-50) {
tmp = t_1 * sqrt((1.0 + pow((0.5 * (U_m / J)), 2.0)));
} else if (t_2 <= 5e+301) {
tmp = t_4;
} else {
tmp = (-U_m * t_3) / sqrt(fma(cos(K), 0.5, 0.5));
}
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) * t_0) t_2 = Float64(t_1 * sqrt(Float64(1.0 + (Float64(U_m / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) t_3 = cos(Float64(K * 0.5)) t_4 = Float64(J * Float64(Float64(-2.0 * t_3) * sqrt(fma(U_m, Float64(U_m / Float64(Float64(J * 2.0) * fma(J, cos(K), J))), 1.0)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_2 <= -3e-95) tmp = t_4; elseif (t_2 <= 1e-50) tmp = Float64(t_1 * sqrt(Float64(1.0 + (Float64(0.5 * Float64(U_m / J)) ^ 2.0)))); elseif (t_2 <= 5e+301) tmp = t_4; else tmp = Float64(Float64(Float64(-U_m) * t_3) / sqrt(fma(cos(K), 0.5, 0.5))); end return 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] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * 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$3 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(J * N[(N[(-2.0 * t$95$3), $MachinePrecision] * N[Sqrt[N[(U$95$m * N[(U$95$m / N[(N[(J * 2.0), $MachinePrecision] * N[(J * N[Cos[K], $MachinePrecision] + J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], (-U$95$m), If[LessEqual[t$95$2, -3e-95], t$95$4, If[LessEqual[t$95$2, 1e-50], N[(t$95$1 * N[Sqrt[N[(1.0 + N[Power[N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+301], t$95$4, N[(N[((-U$95$m) * t$95$3), $MachinePrecision] / N[Sqrt[N[(N[Cos[K], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision]], $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 t\_0\\
t_2 := t\_1 \cdot \sqrt{1 + {\left(\frac{U\_m}{t\_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
t_3 := \cos \left(K \cdot 0.5\right)\\
t_4 := J \cdot \left(\left(-2 \cdot t\_3\right) \cdot \sqrt{\mathsf{fma}\left(U\_m, \frac{U\_m}{\left(J \cdot 2\right) \cdot \mathsf{fma}\left(J, \cos K, J\right)}, 1\right)}\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_2 \leq -3 \cdot 10^{-95}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_2 \leq 10^{-50}:\\
\;\;\;\;t\_1 \cdot \sqrt{1 + {\left(0.5 \cdot \frac{U\_m}{J}\right)}^{2}}\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+301}:\\
\;\;\;\;t\_4\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-U\_m\right) \cdot t\_3}{\sqrt{\mathsf{fma}\left(\cos K, 0.5, 0.5\right)}}\\
\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.3%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6450.4
Applied rewrites50.4%
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))))) < -3e-95 or 1.00000000000000001e-50 < (*.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))))) < 5.0000000000000004e301Initial program 99.8%
Applied rewrites94.9%
lift-fma.f64N/A
Applied rewrites99.7%
lift-fma.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites94.9%
if -3e-95 < (*.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))))) < 1.00000000000000001e-50Initial program 99.9%
Taylor expanded in K around 0
lower-*.f64N/A
lower-/.f6474.9
Applied rewrites74.9%
if 5.0000000000000004e301 < (*.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 12.5%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites10.4%
Taylor expanded in U around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f6443.4
Applied rewrites43.4%
Applied rewrites43.5%
Final simplification78.3%
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
(*
(cos (* K 0.5))
(* (* -2.0 J) (sqrt (fma (* U_m 0.25) (/ U_m (* J J)) 1.0))))))
(if (<= t_1 (- INFINITY))
(- U_m)
(if (<= t_1 -5e-130)
t_2
(if (<= t_1 1e-167)
(- U_m)
(if (<= t_1 5e+301) t_2 (* (* -2.0 J) (* (/ U_m J) -0.5))))))))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 = cos((K * 0.5)) * ((-2.0 * J) * sqrt(fma((U_m * 0.25), (U_m / (J * J)), 1.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_1 <= -5e-130) {
tmp = t_2;
} else if (t_1 <= 1e-167) {
tmp = -U_m;
} else if (t_1 <= 5e+301) {
tmp = t_2;
} else {
tmp = (-2.0 * J) * ((U_m / J) * -0.5);
}
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(cos(Float64(K * 0.5)) * Float64(Float64(-2.0 * J) * sqrt(fma(Float64(U_m * 0.25), Float64(U_m / Float64(J * J)), 1.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_1 <= -5e-130) tmp = t_2; elseif (t_1 <= 1e-167) tmp = Float64(-U_m); elseif (t_1 <= 5e+301) tmp = t_2; else tmp = Float64(Float64(-2.0 * J) * Float64(Float64(U_m / J) * -0.5)); end return 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[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[N[(N[(U$95$m * 0.25), $MachinePrecision] * N[(U$95$m / N[(J * J), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U$95$m), If[LessEqual[t$95$1, -5e-130], t$95$2, If[LessEqual[t$95$1, 1e-167], (-U$95$m), If[LessEqual[t$95$1, 5e+301], t$95$2, N[(N[(-2.0 * J), $MachinePrecision] * N[(N[(U$95$m / J), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]]]]]]
\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 := \cos \left(K \cdot 0.5\right) \cdot \left(\left(-2 \cdot J\right) \cdot \sqrt{\mathsf{fma}\left(U\_m \cdot 0.25, \frac{U\_m}{J \cdot J}, 1\right)}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-130}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-167}:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+301}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \left(\frac{U\_m}{J} \cdot -0.5\right)\\
\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.0 or -4.9999999999999996e-130 < (*.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))))) < 1e-167Initial program 31.1%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6446.8
Applied rewrites46.8%
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.9999999999999996e-130 or 1e-167 < (*.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))))) < 5.0000000000000004e301Initial program 99.8%
Taylor expanded in K around 0
lower-sqrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6476.8
Applied rewrites76.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.5%
if 5.0000000000000004e301 < (*.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 12.5%
Taylor expanded in K around 0
lower-sqrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f647.8
Applied rewrites7.8%
Taylor expanded in U around inf
Applied rewrites20.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites20.0%
Taylor expanded in U around -inf
lower-*.f64N/A
lower-/.f6430.0
Applied rewrites30.0%
Final simplification68.4%
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+187)
(* -2.0 J)
(if (<= t_1 -5e-62)
(* (* -2.0 J) (sqrt (fma 0.25 (/ (* U_m U_m) (* J J)) 1.0)))
(if (<= t_1 -1e-286) (- U_m) (* (* -2.0 J) (* (/ U_m J) -0.5))))))))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+187) {
tmp = -2.0 * J;
} else if (t_1 <= -5e-62) {
tmp = (-2.0 * J) * sqrt(fma(0.25, ((U_m * U_m) / (J * J)), 1.0));
} else if (t_1 <= -1e-286) {
tmp = -U_m;
} else {
tmp = (-2.0 * J) * ((U_m / J) * -0.5);
}
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+187) tmp = Float64(-2.0 * J); elseif (t_1 <= -5e-62) tmp = Float64(Float64(-2.0 * J) * sqrt(fma(0.25, Float64(Float64(U_m * U_m) / Float64(J * J)), 1.0))); elseif (t_1 <= -1e-286) tmp = Float64(-U_m); else tmp = Float64(Float64(-2.0 * J) * Float64(Float64(U_m / J) * -0.5)); end return 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+187], N[(-2.0 * J), $MachinePrecision], If[LessEqual[t$95$1, -5e-62], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[N[(0.25 * N[(N[(U$95$m * U$95$m), $MachinePrecision] / N[(J * J), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-286], (-U$95$m), N[(N[(-2.0 * J), $MachinePrecision] * N[(N[(U$95$m / J), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]]]]]
\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^{+187}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-62}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \sqrt{\mathsf{fma}\left(0.25, \frac{U\_m \cdot U\_m}{J \cdot J}, 1\right)}\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-286}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \left(\frac{U\_m}{J} \cdot -0.5\right)\\
\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.0 or -5.0000000000000002e-62 < (*.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))))) < -1.00000000000000005e-286Initial program 32.6%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6443.5
Applied rewrites43.5%
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))))) < -5.0000000000000001e187Initial program 99.8%
Taylor expanded in U around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6478.2
Applied rewrites78.2%
Taylor expanded in K around 0
Applied rewrites36.0%
Taylor expanded in J around inf
Applied rewrites39.0%
Taylor expanded in K around 0
Applied rewrites41.7%
if -5.0000000000000001e187 < (*.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))))) < -5.0000000000000002e-62Initial program 100.0%
Taylor expanded in K around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6451.2
Applied rewrites51.2%
if -1.00000000000000005e-286 < (*.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 73.4%
Taylor expanded in K around 0
lower-sqrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6449.3
Applied rewrites49.3%
Taylor expanded in U around inf
Applied rewrites13.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites15.4%
Taylor expanded in U around -inf
lower-*.f64N/A
lower-/.f6421.2
Applied rewrites21.2%
Final simplification32.4%
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 -1e-6)
(* -2.0 J)
(if (<= t_1 -1e-286) (- U_m) (* (* -2.0 J) (* (/ U_m J) -0.5)))))))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 <= -1e-6) {
tmp = -2.0 * J;
} else if (t_1 <= -1e-286) {
tmp = -U_m;
} else {
tmp = (-2.0 * J) * ((U_m / J) * -0.5);
}
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 <= -1e-6) {
tmp = -2.0 * J;
} else if (t_1 <= -1e-286) {
tmp = -U_m;
} else {
tmp = (-2.0 * J) * ((U_m / J) * -0.5);
}
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 <= -1e-6: tmp = -2.0 * J elif t_1 <= -1e-286: tmp = -U_m else: tmp = (-2.0 * J) * ((U_m / J) * -0.5) 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 <= -1e-6) tmp = Float64(-2.0 * J); elseif (t_1 <= -1e-286) tmp = Float64(-U_m); else tmp = Float64(Float64(-2.0 * J) * Float64(Float64(U_m / J) * -0.5)); 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 <= -1e-6) tmp = -2.0 * J; elseif (t_1 <= -1e-286) tmp = -U_m; else tmp = (-2.0 * J) * ((U_m / J) * -0.5); 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, -1e-6], N[(-2.0 * J), $MachinePrecision], If[LessEqual[t$95$1, -1e-286], (-U$95$m), N[(N[(-2.0 * J), $MachinePrecision] * N[(N[(U$95$m / J), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\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 -1 \cdot 10^{-6}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-286}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \left(\frac{U\_m}{J} \cdot -0.5\right)\\
\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.0 or -9.99999999999999955e-7 < (*.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))))) < -1.00000000000000005e-286Initial program 43.8%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6438.5
Applied rewrites38.5%
if -inf.0 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < -9.99999999999999955e-7Initial program 99.9%
Taylor expanded in U around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6483.6
Applied rewrites83.6%
Taylor expanded in K around 0
Applied rewrites40.2%
Taylor expanded in J around inf
Applied rewrites41.7%
Taylor expanded in K around 0
Applied rewrites45.1%
if -1.00000000000000005e-286 < (*.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 73.4%
Taylor expanded in K around 0
lower-sqrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6449.3
Applied rewrites49.3%
Taylor expanded in U around inf
Applied rewrites13.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites15.4%
Taylor expanded in U around -inf
lower-*.f64N/A
lower-/.f6421.2
Applied rewrites21.2%
Final simplification30.7%
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 5e+305)
(*
J
(*
(sqrt (fma (/ U_m (fma J 1.0 (* J (cos K)))) (/ U_m (* J 2.0)) 1.0))
(* -2.0 t_0)))
(*
(- U_m)
(fma -2.0 (* (pow t_0 2.0) (/ (* J J) (* U_m U_m))) -1.0))))))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 <= 5e+305) {
tmp = J * (sqrt(fma((U_m / fma(J, 1.0, (J * cos(K)))), (U_m / (J * 2.0)), 1.0)) * (-2.0 * t_0));
} else {
tmp = -U_m * fma(-2.0, (pow(t_0, 2.0) * ((J * J) / (U_m * U_m))), -1.0);
}
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 <= 5e+305) tmp = Float64(J * Float64(sqrt(fma(Float64(U_m / fma(J, 1.0, Float64(J * cos(K)))), Float64(U_m / Float64(J * 2.0)), 1.0)) * Float64(-2.0 * t_0))); else tmp = Float64(Float64(-U_m) * fma(-2.0, Float64((t_0 ^ 2.0) * Float64(Float64(J * J) / Float64(U_m * U_m))), -1.0)); end return 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, 5e+305], N[(J * N[(N[Sqrt[N[(N[(U$95$m / N[(J * 1.0 + N[(J * N[Cos[K], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-U$95$m) * N[(-2.0 * N[(N[Power[t$95$0, 2.0], $MachinePrecision] * N[(N[(J * J), $MachinePrecision] / N[(U$95$m * U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\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 5 \cdot 10^{+305}:\\
\;\;\;\;J \cdot \left(\sqrt{\mathsf{fma}\left(\frac{U\_m}{\mathsf{fma}\left(J, 1, J \cdot \cos K\right)}, \frac{U\_m}{J \cdot 2}, 1\right)} \cdot \left(-2 \cdot t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-U\_m\right) \cdot \mathsf{fma}\left(-2, {t\_0}^{2} \cdot \frac{J \cdot J}{U\_m \cdot U\_m}, -1\right)\\
\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.3%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6450.4
Applied rewrites50.4%
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))))) < 5.00000000000000009e305Initial program 99.8%
Applied rewrites83.8%
lift-fma.f64N/A
Applied rewrites99.7%
if 5.00000000000000009e305 < (*.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.8%
Taylor expanded in U around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6446.5
Applied rewrites46.5%
Final simplification85.4%
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 (cos (* K 0.5))))
(if (<= t_1 (- INFINITY))
(- U_m)
(if (<= t_1 5e+305)
(*
J
(*
(* -2.0 t_2)
(sqrt (fma (/ U_m (fma (cos K) J J)) (/ U_m (* J 2.0)) 1.0))))
(*
(- U_m)
(fma -2.0 (* (pow t_2 2.0) (/ (* J J) (* U_m U_m))) -1.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) * t_0) * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double t_2 = cos((K * 0.5));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_1 <= 5e+305) {
tmp = J * ((-2.0 * t_2) * sqrt(fma((U_m / fma(cos(K), J, J)), (U_m / (J * 2.0)), 1.0)));
} else {
tmp = -U_m * fma(-2.0, (pow(t_2, 2.0) * ((J * J) / (U_m * U_m))), -1.0);
}
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 = cos(Float64(K * 0.5)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_1 <= 5e+305) tmp = Float64(J * Float64(Float64(-2.0 * t_2) * sqrt(fma(Float64(U_m / fma(cos(K), J, J)), Float64(U_m / Float64(J * 2.0)), 1.0)))); else tmp = Float64(Float64(-U_m) * fma(-2.0, Float64((t_2 ^ 2.0) * Float64(Float64(J * J) / Float64(U_m * U_m))), -1.0)); end return 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[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U$95$m), If[LessEqual[t$95$1, 5e+305], N[(J * N[(N[(-2.0 * t$95$2), $MachinePrecision] * N[Sqrt[N[(N[(U$95$m / N[(N[Cos[K], $MachinePrecision] * J + J), $MachinePrecision]), $MachinePrecision] * N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-U$95$m) * N[(-2.0 * N[(N[Power[t$95$2, 2.0], $MachinePrecision] * N[(N[(J * J), $MachinePrecision] / N[(U$95$m * U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\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 := \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot t\_2\right) \cdot \sqrt{\mathsf{fma}\left(\frac{U\_m}{\mathsf{fma}\left(\cos K, J, J\right)}, \frac{U\_m}{J \cdot 2}, 1\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-U\_m\right) \cdot \mathsf{fma}\left(-2, {t\_2}^{2} \cdot \frac{J \cdot J}{U\_m \cdot U\_m}, -1\right)\\
\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.3%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6450.4
Applied rewrites50.4%
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))))) < 5.00000000000000009e305Initial program 99.8%
Applied rewrites83.8%
lift-fma.f64N/A
Applied rewrites99.7%
lift-fma.f64N/A
*-rgt-identityN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lower-fma.f6499.7
lift-*.f64N/A
*-rgt-identity99.7
Applied rewrites99.7%
if 5.00000000000000009e305 < (*.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.8%
Taylor expanded in U around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6446.5
Applied rewrites46.5%
Final simplification85.4%
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))
(t_2 (* t_1 (sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_2 (- INFINITY))
(- U_m)
(if (<= t_2 5e+301)
(* t_1 (sqrt (+ 1.0 (pow (* 0.5 (/ U_m J)) 2.0))))
(/ (* (- U_m) (cos (* K 0.5))) (sqrt (fma (cos K) 0.5 0.5)))))))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;
double t_2 = t_1 * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_2 <= 5e+301) {
tmp = t_1 * sqrt((1.0 + pow((0.5 * (U_m / J)), 2.0)));
} else {
tmp = (-U_m * cos((K * 0.5))) / sqrt(fma(cos(K), 0.5, 0.5));
}
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) * t_0) t_2 = Float64(t_1 * sqrt(Float64(1.0 + (Float64(U_m / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_2 <= 5e+301) tmp = Float64(t_1 * sqrt(Float64(1.0 + (Float64(0.5 * Float64(U_m / J)) ^ 2.0)))); else tmp = Float64(Float64(Float64(-U_m) * cos(Float64(K * 0.5))) / sqrt(fma(cos(K), 0.5, 0.5))); end return 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] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * 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$2, (-Infinity)], (-U$95$m), If[LessEqual[t$95$2, 5e+301], N[(t$95$1 * N[Sqrt[N[(1.0 + N[Power[N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[((-U$95$m) * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Cos[K], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision]], $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 t\_0\\
t_2 := t\_1 \cdot \sqrt{1 + {\left(\frac{U\_m}{t\_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+301}:\\
\;\;\;\;t\_1 \cdot \sqrt{1 + {\left(0.5 \cdot \frac{U\_m}{J}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-U\_m\right) \cdot \cos \left(K \cdot 0.5\right)}{\sqrt{\mathsf{fma}\left(\cos K, 0.5, 0.5\right)}}\\
\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.3%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6450.4
Applied rewrites50.4%
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))))) < 5.0000000000000004e301Initial program 99.8%
Taylor expanded in K around 0
lower-*.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
if 5.0000000000000004e301 < (*.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 12.5%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites10.4%
Taylor expanded in U around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f6443.4
Applied rewrites43.4%
Applied rewrites43.5%
Final simplification75.2%
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))
(t_2 (* t_1 (sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_2 (- INFINITY))
(- U_m)
(if (<= t_2 5e+301)
(* t_1 (sqrt (fma 0.25 (/ (* U_m (/ U_m J)) J) 1.0)))
(/ (* (- U_m) (cos (* K 0.5))) (sqrt (fma (cos K) 0.5 0.5)))))))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;
double t_2 = t_1 * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_2 <= 5e+301) {
tmp = t_1 * sqrt(fma(0.25, ((U_m * (U_m / J)) / J), 1.0));
} else {
tmp = (-U_m * cos((K * 0.5))) / sqrt(fma(cos(K), 0.5, 0.5));
}
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) * t_0) t_2 = Float64(t_1 * sqrt(Float64(1.0 + (Float64(U_m / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_2 <= 5e+301) tmp = Float64(t_1 * sqrt(fma(0.25, Float64(Float64(U_m * Float64(U_m / J)) / J), 1.0))); else tmp = Float64(Float64(Float64(-U_m) * cos(Float64(K * 0.5))) / sqrt(fma(cos(K), 0.5, 0.5))); end return 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] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * 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$2, (-Infinity)], (-U$95$m), If[LessEqual[t$95$2, 5e+301], N[(t$95$1 * N[Sqrt[N[(0.25 * N[(N[(U$95$m * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] / J), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[((-U$95$m) * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Cos[K], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision]], $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 t\_0\\
t_2 := t\_1 \cdot \sqrt{1 + {\left(\frac{U\_m}{t\_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+301}:\\
\;\;\;\;t\_1 \cdot \sqrt{\mathsf{fma}\left(0.25, \frac{U\_m \cdot \frac{U\_m}{J}}{J}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-U\_m\right) \cdot \cos \left(K \cdot 0.5\right)}{\sqrt{\mathsf{fma}\left(\cos K, 0.5, 0.5\right)}}\\
\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.3%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6450.4
Applied rewrites50.4%
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))))) < 5.0000000000000004e301Initial program 99.8%
Taylor expanded in K around 0
lower-sqrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6471.8
Applied rewrites71.8%
Applied rewrites86.2%
if 5.0000000000000004e301 < (*.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 12.5%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites10.4%
Taylor expanded in U around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f6443.4
Applied rewrites43.4%
Applied rewrites43.5%
Final simplification74.7%
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))
(t_2 (* t_1 (sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_2 (- INFINITY))
(- U_m)
(if (<= t_2 5e+301)
(* t_1 (sqrt (fma 0.25 (/ (* U_m (/ U_m J)) J) 1.0)))
(* (* -2.0 J) (* (/ U_m J) -0.5))))))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;
double t_2 = t_1 * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_2 <= 5e+301) {
tmp = t_1 * sqrt(fma(0.25, ((U_m * (U_m / J)) / J), 1.0));
} else {
tmp = (-2.0 * J) * ((U_m / J) * -0.5);
}
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) * t_0) t_2 = Float64(t_1 * sqrt(Float64(1.0 + (Float64(U_m / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_2 <= 5e+301) tmp = Float64(t_1 * sqrt(fma(0.25, Float64(Float64(U_m * Float64(U_m / J)) / J), 1.0))); else tmp = Float64(Float64(-2.0 * J) * Float64(Float64(U_m / J) * -0.5)); end return 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] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * 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$2, (-Infinity)], (-U$95$m), If[LessEqual[t$95$2, 5e+301], N[(t$95$1 * N[Sqrt[N[(0.25 * N[(N[(U$95$m * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] / J), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * J), $MachinePrecision] * N[(N[(U$95$m / J), $MachinePrecision] * -0.5), $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 t\_0\\
t_2 := t\_1 \cdot \sqrt{1 + {\left(\frac{U\_m}{t\_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+301}:\\
\;\;\;\;t\_1 \cdot \sqrt{\mathsf{fma}\left(0.25, \frac{U\_m \cdot \frac{U\_m}{J}}{J}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \left(\frac{U\_m}{J} \cdot -0.5\right)\\
\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.3%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6450.4
Applied rewrites50.4%
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))))) < 5.0000000000000004e301Initial program 99.8%
Taylor expanded in K around 0
lower-sqrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6471.8
Applied rewrites71.8%
Applied rewrites86.2%
if 5.0000000000000004e301 < (*.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 12.5%
Taylor expanded in K around 0
lower-sqrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f647.8
Applied rewrites7.8%
Taylor expanded in U around inf
Applied rewrites20.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites20.0%
Taylor expanded in U around -inf
lower-*.f64N/A
lower-/.f6430.0
Applied rewrites30.0%
Final simplification72.5%
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+301)
(* (* -2.0 J) (cos (* K 0.5)))
(* (* -2.0 J) (* (/ U_m J) -0.5))))))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+301) {
tmp = (-2.0 * J) * cos((K * 0.5));
} else {
tmp = (-2.0 * J) * ((U_m / J) * -0.5);
}
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+301) {
tmp = (-2.0 * J) * Math.cos((K * 0.5));
} else {
tmp = (-2.0 * J) * ((U_m / J) * -0.5);
}
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+301: tmp = (-2.0 * J) * math.cos((K * 0.5)) else: tmp = (-2.0 * J) * ((U_m / J) * -0.5) 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+301) tmp = Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))); else tmp = Float64(Float64(-2.0 * J) * Float64(Float64(U_m / J) * -0.5)); 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+301) tmp = (-2.0 * J) * cos((K * 0.5)); else tmp = (-2.0 * J) * ((U_m / J) * -0.5); 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+301], N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * J), $MachinePrecision] * N[(N[(U$95$m / J), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]]]
\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^{+301}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \left(\frac{U\_m}{J} \cdot -0.5\right)\\
\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.3%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6450.4
Applied rewrites50.4%
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))))) < 5.0000000000000004e301Initial program 99.8%
Taylor expanded in U around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f6473.0
Applied rewrites73.0%
if 5.0000000000000004e301 < (*.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 12.5%
Taylor expanded in K around 0
lower-sqrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f647.8
Applied rewrites7.8%
Taylor expanded in U around inf
Applied rewrites20.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites20.0%
Taylor expanded in U around -inf
lower-*.f64N/A
lower-/.f6430.0
Applied rewrites30.0%
Final simplification63.1%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 2e+39) (- U_m) (* -2.0 J)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 2e+39) {
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 <= 2d+39) 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 <= 2e+39) {
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 <= 2e+39: 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 <= 2e+39) 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 <= 2e+39) 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, 2e+39], (-U$95$m), N[(-2.0 * J), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 2 \cdot 10^{+39}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 1.99999999999999988e39Initial program 66.2%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6431.6
Applied rewrites31.6%
if 1.99999999999999988e39 < J Initial program 98.2%
Taylor expanded in U around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6480.1
Applied rewrites80.1%
Taylor expanded in K around 0
Applied rewrites38.6%
Taylor expanded in J around inf
Applied rewrites41.0%
Taylor expanded in K around 0
Applied rewrites43.5%
Final simplification34.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 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 73.7%
Taylor expanded in U around inf
mul-1-negN/A
lower-neg.f6426.8
Applied rewrites26.8%
herbie shell --seed 2024227
(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)))))