
(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}
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (* J t_0))
(t_2
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_2 (- INFINITY))
(* -2.0 (* U 0.5))
(if (<= t_2 2e+297)
(* -2.0 (* t_1 (hypot 1.0 (/ U (* 2.0 t_1)))))
(* -2.0 (* U -0.5))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = J * t_0;
double t_2 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = -2.0 * (U * 0.5);
} else if (t_2 <= 2e+297) {
tmp = -2.0 * (t_1 * hypot(1.0, (U / (2.0 * t_1))));
} else {
tmp = -2.0 * (U * -0.5);
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = J * t_0;
double t_2 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = -2.0 * (U * 0.5);
} else if (t_2 <= 2e+297) {
tmp = -2.0 * (t_1 * Math.hypot(1.0, (U / (2.0 * t_1))));
} else {
tmp = -2.0 * (U * -0.5);
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = J * t_0 t_2 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_2 <= -math.inf: tmp = -2.0 * (U * 0.5) elif t_2 <= 2e+297: tmp = -2.0 * (t_1 * math.hypot(1.0, (U / (2.0 * t_1)))) else: tmp = -2.0 * (U * -0.5) return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(J * t_0) t_2 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(-2.0 * Float64(U * 0.5)); elseif (t_2 <= 2e+297) tmp = Float64(-2.0 * Float64(t_1 * hypot(1.0, Float64(U / Float64(2.0 * t_1))))); else tmp = Float64(-2.0 * Float64(U * -0.5)); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = J * t_0; t_2 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_2 <= -Inf) tmp = -2.0 * (U * 0.5); elseif (t_2 <= 2e+297) tmp = -2.0 * (t_1 * hypot(1.0, (U / (2.0 * t_1)))); else tmp = -2.0 * (U * -0.5); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(J * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+297], N[(-2.0 * N[(t$95$1 * N[Sqrt[1.0 ^ 2 + N[(U / N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := J \cdot t_0\\
t_2 := \left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+297}:\\
\;\;\;\;-2 \cdot \left(t_1 \cdot \mathsf{hypot}\left(1, \frac{U}{2 \cdot t_1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\
\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 5.1%
Simplified60.1%
Taylor expanded in J around 0 58.1%
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)))) < 2e297Initial 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 2e297 < (*.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.6%
Simplified52.7%
Taylor expanded in U around -inf 32.7%
*-commutative32.7%
Simplified32.7%
Final simplification86.7%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (* -2.0 (* J (* t_0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
(if (<= J -1.9e-217)
t_1
(if (<= J 7e-285)
(* -2.0 (* U -0.5))
(if (<= J 1.36e-220) (* -2.0 (* U 0.5)) t_1)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = -2.0 * (J * (t_0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
double tmp;
if (J <= -1.9e-217) {
tmp = t_1;
} else if (J <= 7e-285) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 1.36e-220) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = t_1;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = -2.0 * (J * (t_0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
double tmp;
if (J <= -1.9e-217) {
tmp = t_1;
} else if (J <= 7e-285) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 1.36e-220) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = t_1;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = -2.0 * (J * (t_0 * math.hypot(1.0, (U / (J * (2.0 * t_0)))))) tmp = 0 if J <= -1.9e-217: tmp = t_1 elif J <= 7e-285: tmp = -2.0 * (U * -0.5) elif J <= 1.36e-220: tmp = -2.0 * (U * 0.5) else: tmp = t_1 return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(-2.0 * Float64(J * Float64(t_0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))) tmp = 0.0 if (J <= -1.9e-217) tmp = t_1; elseif (J <= 7e-285) tmp = Float64(-2.0 * Float64(U * -0.5)); elseif (J <= 1.36e-220) tmp = Float64(-2.0 * Float64(U * 0.5)); else tmp = t_1; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = -2.0 * (J * (t_0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); tmp = 0.0; if (J <= -1.9e-217) tmp = t_1; elseif (J <= 7e-285) tmp = -2.0 * (U * -0.5); elseif (J <= 1.36e-220) tmp = -2.0 * (U * 0.5); else tmp = t_1; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(-2.0 * N[(J * N[(t$95$0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.9e-217], t$95$1, If[LessEqual[J, 7e-285], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.36e-220], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := -2 \cdot \left(J \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)\\
\mathbf{if}\;J \leq -1.9 \cdot 10^{-217}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;J \leq 7 \cdot 10^{-285}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 1.36 \cdot 10^{-220}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if J < -1.89999999999999993e-217 or 1.3600000000000001e-220 < J Initial program 83.7%
Simplified94.9%
if -1.89999999999999993e-217 < J < 7.0000000000000007e-285Initial program 34.7%
Simplified44.7%
Taylor expanded in U around -inf 32.7%
*-commutative32.7%
Simplified32.7%
if 7.0000000000000007e-285 < J < 1.3600000000000001e-220Initial program 23.3%
Simplified52.2%
Taylor expanded in J around 0 60.4%
Final simplification88.9%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* (* J (cos (/ K 2.0))) (hypot 1.0 (/ U (* J 2.0)))))))
(if (<= J -6.4e-152)
t_0
(if (<= J 7e-285)
(* -2.0 (- (* U -0.5) (/ J (/ U J))))
(if (<= J 5.8e-179) (* -2.0 (* U 0.5)) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, (U / (J * 2.0))));
double tmp;
if (J <= -6.4e-152) {
tmp = t_0;
} else if (J <= 7e-285) {
tmp = -2.0 * ((U * -0.5) - (J / (U / J)));
} else if (J <= 5.8e-179) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = -2.0 * ((J * Math.cos((K / 2.0))) * Math.hypot(1.0, (U / (J * 2.0))));
double tmp;
if (J <= -6.4e-152) {
tmp = t_0;
} else if (J <= 7e-285) {
tmp = -2.0 * ((U * -0.5) - (J / (U / J)));
} else if (J <= 5.8e-179) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * ((J * math.cos((K / 2.0))) * math.hypot(1.0, (U / (J * 2.0)))) tmp = 0 if J <= -6.4e-152: tmp = t_0 elif J <= 7e-285: tmp = -2.0 * ((U * -0.5) - (J / (U / J))) elif J <= 5.8e-179: tmp = -2.0 * (U * 0.5) else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(Float64(J * cos(Float64(K / 2.0))) * hypot(1.0, Float64(U / Float64(J * 2.0))))) tmp = 0.0 if (J <= -6.4e-152) tmp = t_0; elseif (J <= 7e-285) tmp = Float64(-2.0 * Float64(Float64(U * -0.5) - Float64(J / Float64(U / J)))); elseif (J <= 5.8e-179) tmp = Float64(-2.0 * Float64(U * 0.5)); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, (U / (J * 2.0)))); tmp = 0.0; if (J <= -6.4e-152) tmp = t_0; elseif (J <= 7e-285) tmp = -2.0 * ((U * -0.5) - (J / (U / J))); elseif (J <= 5.8e-179) tmp = -2.0 * (U * 0.5); else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -6.4e-152], t$95$0, If[LessEqual[J, 7e-285], N[(-2.0 * N[(N[(U * -0.5), $MachinePrecision] - N[(J / N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 5.8e-179], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\right)\\
\mathbf{if}\;J \leq -6.4 \cdot 10^{-152}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 7 \cdot 10^{-285}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5 - \frac{J}{\frac{U}{J}}\right)\\
\mathbf{elif}\;J \leq 5.8 \cdot 10^{-179}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -6.40000000000000025e-152 or 5.7999999999999998e-179 < J Initial program 87.1%
associate-*l*87.1%
associate-*l*87.1%
unpow287.1%
sqr-neg87.1%
distribute-frac-neg87.1%
distribute-frac-neg87.1%
unpow287.1%
Simplified96.7%
Taylor expanded in K around 0 81.8%
if -6.40000000000000025e-152 < J < 7.0000000000000007e-285Initial program 49.5%
associate-*l*49.5%
associate-*l*49.5%
unpow249.5%
sqr-neg49.5%
distribute-frac-neg49.5%
distribute-frac-neg49.5%
unpow249.5%
Simplified55.6%
Taylor expanded in K around 0 35.1%
Taylor expanded in K around 0 37.6%
Taylor expanded in U around -inf 35.7%
+-commutative35.7%
mul-1-neg35.7%
unsub-neg35.7%
*-commutative35.7%
unpow235.7%
associate-/l*35.7%
Simplified35.7%
if 7.0000000000000007e-285 < J < 5.7999999999999998e-179Initial program 24.3%
Simplified69.9%
Taylor expanded in J around 0 53.2%
Final simplification73.9%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= (/ K 2.0) 1000000000.0) (* -2.0 (* J (hypot 1.0 (/ U (* J 2.0))))) (* -2.0 (* J (cos (* K 0.5))))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if ((K / 2.0) <= 1000000000.0) {
tmp = -2.0 * (J * hypot(1.0, (U / (J * 2.0))));
} else {
tmp = -2.0 * (J * cos((K * 0.5)));
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if ((K / 2.0) <= 1000000000.0) {
tmp = -2.0 * (J * Math.hypot(1.0, (U / (J * 2.0))));
} else {
tmp = -2.0 * (J * Math.cos((K * 0.5)));
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if (K / 2.0) <= 1000000000.0: tmp = -2.0 * (J * math.hypot(1.0, (U / (J * 2.0)))) else: tmp = -2.0 * (J * math.cos((K * 0.5))) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 1000000000.0) tmp = Float64(-2.0 * Float64(J * hypot(1.0, Float64(U / Float64(J * 2.0))))); else tmp = Float64(-2.0 * Float64(J * cos(Float64(K * 0.5)))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if ((K / 2.0) <= 1000000000.0) tmp = -2.0 * (J * hypot(1.0, (U / (J * 2.0)))); else tmp = -2.0 * (J * cos((K * 0.5))); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 1000000000.0], N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 1000000000:\\
\;\;\;\;-2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if (/.f64 K 2) < 1e9Initial program 78.3%
associate-*l*78.3%
associate-*l*78.3%
unpow278.3%
sqr-neg78.3%
distribute-frac-neg78.3%
distribute-frac-neg78.3%
unpow278.3%
Simplified90.4%
Taylor expanded in K around 0 78.2%
Taylor expanded in K around 0 65.4%
if 1e9 < (/.f64 K 2) Initial program 75.7%
Simplified86.8%
Taylor expanded in J around inf 49.6%
Final simplification61.7%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* J (cos (* K 0.5))))))
(if (<= J -2e-117)
t_0
(if (<= J 4.4e-284)
(* -2.0 (* U -0.5))
(if (<= J 9.5e-138) (* -2.0 (* U 0.5)) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = -2.0 * (J * cos((K * 0.5)));
double tmp;
if (J <= -2e-117) {
tmp = t_0;
} else if (J <= 4.4e-284) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 9.5e-138) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
NOTE: U should be positive before calling this function
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
real(8) :: tmp
t_0 = (-2.0d0) * (j * cos((k * 0.5d0)))
if (j <= (-2d-117)) then
tmp = t_0
else if (j <= 4.4d-284) then
tmp = (-2.0d0) * (u * (-0.5d0))
else if (j <= 9.5d-138) then
tmp = (-2.0d0) * (u * 0.5d0)
else
tmp = t_0
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = -2.0 * (J * Math.cos((K * 0.5)));
double tmp;
if (J <= -2e-117) {
tmp = t_0;
} else if (J <= 4.4e-284) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 9.5e-138) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = -2.0 * (J * math.cos((K * 0.5))) tmp = 0 if J <= -2e-117: tmp = t_0 elif J <= 4.4e-284: tmp = -2.0 * (U * -0.5) elif J <= 9.5e-138: tmp = -2.0 * (U * 0.5) else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(-2.0 * Float64(J * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -2e-117) tmp = t_0; elseif (J <= 4.4e-284) tmp = Float64(-2.0 * Float64(U * -0.5)); elseif (J <= 9.5e-138) tmp = Float64(-2.0 * Float64(U * 0.5)); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = -2.0 * (J * cos((K * 0.5))); tmp = 0.0; if (J <= -2e-117) tmp = t_0; elseif (J <= 4.4e-284) tmp = -2.0 * (U * -0.5); elseif (J <= 9.5e-138) tmp = -2.0 * (U * 0.5); else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -2e-117], t$95$0, If[LessEqual[J, 4.4e-284], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 9.5e-138], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -2 \cdot 10^{-117}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 4.4 \cdot 10^{-284}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 9.5 \cdot 10^{-138}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -2.00000000000000006e-117 or 9.49999999999999997e-138 < J Initial program 90.6%
Simplified97.8%
Taylor expanded in J around inf 68.6%
if -2.00000000000000006e-117 < J < 4.4000000000000001e-284Initial program 46.3%
Simplified58.6%
Taylor expanded in U around -inf 34.8%
*-commutative34.8%
Simplified34.8%
if 4.4000000000000001e-284 < J < 9.49999999999999997e-138Initial program 30.0%
Simplified74.3%
Taylor expanded in J around 0 62.3%
Final simplification62.8%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= J -2.6e+102)
(* -2.0 J)
(if (<= J 7e-285)
(* -2.0 (* U -0.5))
(if (<= J 1.65e-78) (* -2.0 (* U 0.5)) (* -2.0 J)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2.6e+102) {
tmp = -2.0 * J;
} else if (J <= 7e-285) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 1.65e-78) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = -2.0 * J;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-2.6d+102)) then
tmp = (-2.0d0) * j
else if (j <= 7d-285) then
tmp = (-2.0d0) * (u * (-0.5d0))
else if (j <= 1.65d-78) then
tmp = (-2.0d0) * (u * 0.5d0)
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -2.6e+102) {
tmp = -2.0 * J;
} else if (J <= 7e-285) {
tmp = -2.0 * (U * -0.5);
} else if (J <= 1.65e-78) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2.6e+102: tmp = -2.0 * J elif J <= 7e-285: tmp = -2.0 * (U * -0.5) elif J <= 1.65e-78: tmp = -2.0 * (U * 0.5) else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2.6e+102) tmp = Float64(-2.0 * J); elseif (J <= 7e-285) tmp = Float64(-2.0 * Float64(U * -0.5)); elseif (J <= 1.65e-78) tmp = Float64(-2.0 * Float64(U * 0.5)); else tmp = Float64(-2.0 * J); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -2.6e+102) tmp = -2.0 * J; elseif (J <= 7e-285) tmp = -2.0 * (U * -0.5); elseif (J <= 1.65e-78) tmp = -2.0 * (U * 0.5); else tmp = -2.0 * J; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -2.6e+102], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, 7e-285], N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.65e-78], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.6 \cdot 10^{+102}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq 7 \cdot 10^{-285}:\\
\;\;\;\;-2 \cdot \left(U \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 1.65 \cdot 10^{-78}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -2.60000000000000006e102 or 1.64999999999999991e-78 < J Initial program 97.8%
Simplified99.7%
Taylor expanded in J around inf 77.9%
Taylor expanded in K around 0 45.5%
if -2.60000000000000006e102 < J < 7.0000000000000007e-285Initial program 58.6%
Simplified77.4%
Taylor expanded in U around -inf 25.4%
*-commutative25.4%
Simplified25.4%
if 7.0000000000000007e-285 < J < 1.64999999999999991e-78Initial program 49.9%
Simplified79.6%
Taylor expanded in J around 0 46.5%
Final simplification39.4%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 3.4e-34) (* -2.0 J) (* -2.0 (* U 0.5))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 3.4e-34) {
tmp = -2.0 * J;
} else {
tmp = -2.0 * (U * 0.5);
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (u <= 3.4d-34) then
tmp = (-2.0d0) * j
else
tmp = (-2.0d0) * (u * 0.5d0)
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 3.4e-34) {
tmp = -2.0 * J;
} else {
tmp = -2.0 * (U * 0.5);
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 3.4e-34: tmp = -2.0 * J else: tmp = -2.0 * (U * 0.5) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 3.4e-34) tmp = Float64(-2.0 * J); else tmp = Float64(-2.0 * Float64(U * 0.5)); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 3.4e-34) tmp = -2.0 * J; else tmp = -2.0 * (U * 0.5); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 3.4e-34], N[(-2.0 * J), $MachinePrecision], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 3.4 \cdot 10^{-34}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\end{array}
\end{array}
if U < 3.4000000000000001e-34Initial program 83.0%
Simplified91.8%
Taylor expanded in J around inf 60.1%
Taylor expanded in K around 0 36.6%
if 3.4000000000000001e-34 < U Initial program 57.8%
Simplified80.6%
Taylor expanded in J around 0 42.1%
Final simplification37.8%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (* -2.0 J))
U = abs(U);
double code(double J, double K, double U) {
return -2.0 * J;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
code = (-2.0d0) * j
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
return -2.0 * J;
}
U = abs(U) def code(J, K, U): return -2.0 * J
U = abs(U) function code(J, K, U) return Float64(-2.0 * J) end
U = abs(U) function tmp = code(J, K, U) tmp = -2.0 * J; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := N[(-2.0 * J), $MachinePrecision]
\begin{array}{l}
U = |U|\\
\\
-2 \cdot J
\end{array}
Initial program 77.7%
Simplified89.5%
Taylor expanded in J around inf 54.1%
Taylor expanded in K around 0 32.4%
Final simplification32.4%
herbie shell --seed 2023276
(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)))))