
(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 10 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
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY))
(- U)
(if (<= t_1 INFINITY)
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ U (* J (* 2.0 t_0)))))
U))))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) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
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.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
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.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U elif t_1 <= math.inf: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0)))) else: tmp = U return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = 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_1 <= Float64(-Inf)) tmp = Float64(-U); elseif (t_1 <= Inf) tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))); else tmp = U; 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) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U; elseif (t_1 <= Inf) tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0)))); else tmp = U; 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[(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$1, (-Infinity)], (-U), If[LessEqual[t$95$1, Infinity], N[(N[(J * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], U]]]]
\begin{array}{l}
U = |U|\\
\\
\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}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-U\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot t_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\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.7%
*-commutative5.7%
associate-*l*5.7%
associate-*r*5.7%
*-commutative5.7%
associate-*l*5.7%
*-commutative5.7%
unpow25.7%
hypot-1-def57.2%
*-commutative57.2%
associate-*l*57.2%
Simplified57.2%
Taylor expanded in J around 0 48.9%
neg-mul-148.9%
Simplified48.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)))) < +inf.0Initial program 89.2%
*-commutative89.2%
associate-*l*89.2%
unpow289.2%
hypot-1-def95.5%
*-commutative95.5%
associate-*l*95.5%
Simplified95.5%
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)))) Initial program 78.4%
*-commutative78.4%
associate-*l*78.4%
associate-*r*78.4%
*-commutative78.4%
associate-*l*78.4%
*-commutative78.4%
unpow278.4%
hypot-1-def90.5%
*-commutative90.5%
associate-*l*90.5%
Simplified90.5%
Taylor expanded in U around -inf 28.1%
Final simplification89.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* J (* t_0 (* -2.0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return J * (t_0 * (-2.0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) return J * (t_0 * (-2.0 * math.hypot(1.0, (U / (J * (2.0 * t_0))))))
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); 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]}, N[(J * N[(t$95$0 * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
J \cdot \left(t_0 \cdot \left(-2 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)
\end{array}
\end{array}
Initial program 78.4%
*-commutative78.4%
associate-*l*78.4%
associate-*r*78.4%
*-commutative78.4%
associate-*l*78.4%
*-commutative78.4%
unpow278.4%
hypot-1-def90.5%
*-commutative90.5%
associate-*l*90.5%
Simplified90.5%
Final simplification90.5%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (* U (/ 0.5 (* J (cos (* K 0.5))))))))
U = abs(U);
double code(double J, double K, double U) {
return (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U * (0.5 / (J * cos((K * 0.5))))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
return (J * (-2.0 * Math.cos((K / 2.0)))) * Math.hypot(1.0, (U * (0.5 / (J * Math.cos((K * 0.5))))));
}
U = abs(U) def code(J, K, U): return (J * (-2.0 * math.cos((K / 2.0)))) * math.hypot(1.0, (U * (0.5 / (J * math.cos((K * 0.5))))))
U = abs(U) function code(J, K, U) return Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(U * Float64(0.5 / Float64(J * cos(Float64(K * 0.5))))))) end
U = abs(U) function tmp = code(J, K, U) tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U * (0.5 / (J * cos((K * 0.5)))))); end
NOTE: U should be positive before calling this function code[J_, K_, U_] := N[(N[(J * N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U * N[(0.5 / N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
U = |U|\\
\\
\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, U \cdot \frac{0.5}{J \cdot \cos \left(K \cdot 0.5\right)}\right)
\end{array}
Initial program 78.4%
*-commutative78.4%
associate-*l*78.4%
unpow278.4%
hypot-1-def90.6%
*-commutative90.6%
associate-*l*90.6%
Simplified90.6%
Taylor expanded in U around 0 90.6%
*-commutative90.6%
metadata-eval90.6%
times-frac90.6%
*-commutative90.6%
associate-*r*90.6%
associate-*r/90.6%
associate-*r*90.6%
*-commutative90.6%
*-commutative90.6%
associate-/r*90.6%
metadata-eval90.6%
*-commutative90.6%
Simplified90.6%
Final simplification90.6%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (or (<= J -1.06e-243) (not (<= J 1.05e-105))) (* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (/ U (* J 2.0)))) (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if ((J <= -1.06e-243) || !(J <= 1.05e-105)) {
tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0)));
} else {
tmp = -U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if ((J <= -1.06e-243) || !(J <= 1.05e-105)) {
tmp = (J * (-2.0 * Math.cos((K / 2.0)))) * Math.hypot(1.0, (U / (J * 2.0)));
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if (J <= -1.06e-243) or not (J <= 1.05e-105): tmp = (J * (-2.0 * math.cos((K / 2.0)))) * math.hypot(1.0, (U / (J * 2.0))) else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if ((J <= -1.06e-243) || !(J <= 1.05e-105)) tmp = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(U / Float64(J * 2.0)))); else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if ((J <= -1.06e-243) || ~((J <= 1.05e-105))) tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0))); else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[Or[LessEqual[J, -1.06e-243], N[Not[LessEqual[J, 1.05e-105]], $MachinePrecision]], N[(N[(J * N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.06 \cdot 10^{-243} \lor \neg \left(J \leq 1.05 \cdot 10^{-105}\right):\\
\;\;\;\;\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -1.06e-243 or 1.05e-105 < J Initial program 86.9%
*-commutative86.9%
associate-*l*86.9%
unpow286.9%
hypot-1-def98.0%
*-commutative98.0%
associate-*l*98.0%
Simplified98.0%
Taylor expanded in K around 0 85.2%
if -1.06e-243 < J < 1.05e-105Initial program 39.9%
*-commutative39.9%
associate-*l*39.9%
associate-*r*39.9%
*-commutative39.9%
associate-*l*39.9%
*-commutative39.9%
unpow239.9%
hypot-1-def56.8%
*-commutative56.8%
associate-*l*56.8%
Simplified56.8%
Taylor expanded in J around 0 45.0%
neg-mul-145.0%
Simplified45.0%
Final simplification78.0%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= K 2.75e-11)
(* J (* -2.0 (sqrt (fma 0.25 (* (/ U J) (/ U J)) 1.0))))
(if (or (<= K 1.08e+74) (not (<= K 4e+87)))
(* J (* -2.0 (cos (* K 0.5))))
U)))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (K <= 2.75e-11) {
tmp = J * (-2.0 * sqrt(fma(0.25, ((U / J) * (U / J)), 1.0)));
} else if ((K <= 1.08e+74) || !(K <= 4e+87)) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else {
tmp = U;
}
return tmp;
}
U = abs(U) function code(J, K, U) tmp = 0.0 if (K <= 2.75e-11) tmp = Float64(J * Float64(-2.0 * sqrt(fma(0.25, Float64(Float64(U / J) * Float64(U / J)), 1.0)))); elseif ((K <= 1.08e+74) || !(K <= 4e+87)) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); else tmp = U; end return tmp end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[K, 2.75e-11], N[(J * N[(-2.0 * N[Sqrt[N[(0.25 * N[(N[(U / J), $MachinePrecision] * N[(U / J), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[K, 1.08e+74], N[Not[LessEqual[K, 4e+87]], $MachinePrecision]], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], U]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;K \leq 2.75 \cdot 10^{-11}:\\
\;\;\;\;J \cdot \left(-2 \cdot \sqrt{\mathsf{fma}\left(0.25, \frac{U}{J} \cdot \frac{U}{J}, 1\right)}\right)\\
\mathbf{elif}\;K \leq 1.08 \cdot 10^{+74} \lor \neg \left(K \leq 4 \cdot 10^{+87}\right):\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if K < 2.74999999999999987e-11Initial program 79.3%
*-commutative79.3%
associate-*l*79.3%
associate-*r*79.3%
*-commutative79.3%
associate-*l*79.2%
*-commutative79.2%
unpow279.2%
hypot-1-def90.5%
*-commutative90.5%
associate-*l*90.5%
Simplified90.5%
Taylor expanded in K around 0 42.1%
associate-*r*42.1%
*-commutative42.1%
+-commutative42.1%
fma-def42.1%
unpow242.1%
unpow242.1%
times-frac58.4%
Simplified58.4%
if 2.74999999999999987e-11 < K < 1.08e74 or 3.9999999999999998e87 < K Initial program 76.1%
*-commutative76.1%
associate-*l*76.1%
associate-*r*76.1%
*-commutative76.1%
associate-*l*76.1%
*-commutative76.1%
unpow276.1%
hypot-1-def91.8%
*-commutative91.8%
associate-*l*91.8%
Simplified91.8%
Taylor expanded in U around 0 53.1%
if 1.08e74 < K < 3.9999999999999998e87Initial program 68.6%
*-commutative68.6%
associate-*l*68.6%
associate-*r*68.6%
*-commutative68.6%
associate-*l*68.6%
*-commutative68.6%
unpow268.6%
hypot-1-def68.6%
*-commutative68.6%
associate-*l*68.6%
Simplified68.6%
Taylor expanded in U around -inf 100.0%
Final simplification57.6%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -1.2e+43)
t_0
(if (<= J -4e-310) U (if (<= J 3.6e+23) (- U) t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -1.2e+43) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 3.6e+23) {
tmp = -U;
} 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 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-1.2d+43)) then
tmp = t_0
else if (j <= (-4d-310)) then
tmp = u
else if (j <= 3.6d+23) then
tmp = -u
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 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (J <= -1.2e+43) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 3.6e+23) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -1.2e+43: tmp = t_0 elif J <= -4e-310: tmp = U elif J <= 3.6e+23: tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -1.2e+43) tmp = t_0; elseif (J <= -4e-310) tmp = U; elseif (J <= 3.6e+23) tmp = Float64(-U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (J <= -1.2e+43) tmp = t_0; elseif (J <= -4e-310) tmp = U; elseif (J <= 3.6e+23) tmp = -U; 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[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.2e+43], t$95$0, If[LessEqual[J, -4e-310], U, If[LessEqual[J, 3.6e+23], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -1.2 \cdot 10^{+43}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 3.6 \cdot 10^{+23}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -1.20000000000000012e43 or 3.5999999999999998e23 < J Initial program 98.4%
*-commutative98.4%
associate-*l*98.4%
associate-*r*98.4%
*-commutative98.4%
associate-*l*98.4%
*-commutative98.4%
unpow298.4%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 80.3%
if -1.20000000000000012e43 < J < -3.999999999999988e-310Initial program 58.8%
*-commutative58.8%
associate-*l*58.8%
associate-*r*58.8%
*-commutative58.8%
associate-*l*58.7%
*-commutative58.7%
unpow258.7%
hypot-1-def84.1%
*-commutative84.1%
associate-*l*84.1%
Simplified84.1%
Taylor expanded in U around -inf 40.2%
if -3.999999999999988e-310 < J < 3.5999999999999998e23Initial program 58.0%
*-commutative58.0%
associate-*l*58.0%
associate-*r*58.0%
*-commutative58.0%
associate-*l*58.0%
*-commutative58.0%
unpow258.0%
hypot-1-def78.3%
*-commutative78.3%
associate-*l*78.3%
Simplified78.3%
Taylor expanded in J around 0 34.8%
neg-mul-134.8%
Simplified34.8%
Final simplification59.0%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= J -5.7e+147)
(* -2.0 J)
(if (<= J -1.7e-243)
(* J (+ (/ U J) -1.0))
(if (<= J 6.5e+23) (- U) (* -2.0 J)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -5.7e+147) {
tmp = -2.0 * J;
} else if (J <= -1.7e-243) {
tmp = J * ((U / J) + -1.0);
} else if (J <= 6.5e+23) {
tmp = -U;
} 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 <= (-5.7d+147)) then
tmp = (-2.0d0) * j
else if (j <= (-1.7d-243)) then
tmp = j * ((u / j) + (-1.0d0))
else if (j <= 6.5d+23) then
tmp = -u
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 <= -5.7e+147) {
tmp = -2.0 * J;
} else if (J <= -1.7e-243) {
tmp = J * ((U / J) + -1.0);
} else if (J <= 6.5e+23) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -5.7e+147: tmp = -2.0 * J elif J <= -1.7e-243: tmp = J * ((U / J) + -1.0) elif J <= 6.5e+23: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -5.7e+147) tmp = Float64(-2.0 * J); elseif (J <= -1.7e-243) tmp = Float64(J * Float64(Float64(U / J) + -1.0)); elseif (J <= 6.5e+23) tmp = Float64(-U); 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 <= -5.7e+147) tmp = -2.0 * J; elseif (J <= -1.7e-243) tmp = J * ((U / J) + -1.0); elseif (J <= 6.5e+23) tmp = -U; 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, -5.7e+147], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -1.7e-243], N[(J * N[(N[(U / J), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 6.5e+23], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -5.7 \cdot 10^{+147}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -1.7 \cdot 10^{-243}:\\
\;\;\;\;J \cdot \left(\frac{U}{J} + -1\right)\\
\mathbf{elif}\;J \leq 6.5 \cdot 10^{+23}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -5.69999999999999991e147 or 6.4999999999999996e23 < J Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*l*99.8%
*-commutative99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 49.4%
associate-*r*49.4%
*-commutative49.4%
+-commutative49.4%
fma-def49.4%
unpow249.4%
unpow249.4%
times-frac64.3%
Simplified64.3%
Taylor expanded in J around inf 50.7%
if -5.69999999999999991e147 < J < -1.69999999999999998e-243Initial program 73.9%
*-commutative73.9%
associate-*l*73.9%
associate-*r*73.9%
*-commutative73.9%
associate-*l*73.8%
*-commutative73.8%
unpow273.8%
hypot-1-def95.9%
*-commutative95.9%
associate-*l*95.9%
Simplified95.9%
expm1-log1p-u25.1%
associate-*r*25.1%
*-commutative25.1%
associate-*l*25.1%
div-inv25.1%
metadata-eval25.1%
*-commutative25.1%
*-commutative25.1%
associate-*l*25.1%
div-inv25.1%
metadata-eval25.1%
*-commutative25.1%
Applied egg-rr25.1%
expm1-udef25.0%
log1p-udef25.1%
add-exp-log95.9%
associate-*r*95.9%
associate-/r*95.9%
Applied egg-rr95.9%
Taylor expanded in U around -inf 38.8%
if -1.69999999999999998e-243 < J < 6.4999999999999996e23Initial program 51.8%
*-commutative51.8%
associate-*l*51.8%
associate-*r*51.8%
*-commutative51.8%
associate-*l*51.8%
*-commutative51.8%
unpow251.8%
hypot-1-def71.4%
*-commutative71.4%
associate-*l*71.4%
Simplified71.4%
Taylor expanded in J around 0 37.4%
neg-mul-137.4%
Simplified37.4%
Final simplification43.4%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -1.25e+147) (* -2.0 J) (if (<= J -4e-310) U (if (<= J 5.1e+23) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.25e+147) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 5.1e+23) {
tmp = -U;
} 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 <= (-1.25d+147)) then
tmp = (-2.0d0) * j
else if (j <= (-4d-310)) then
tmp = u
else if (j <= 5.1d+23) then
tmp = -u
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 <= -1.25e+147) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 5.1e+23) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.25e+147: tmp = -2.0 * J elif J <= -4e-310: tmp = U elif J <= 5.1e+23: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.25e+147) tmp = Float64(-2.0 * J); elseif (J <= -4e-310) tmp = U; elseif (J <= 5.1e+23) tmp = Float64(-U); 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 <= -1.25e+147) tmp = -2.0 * J; elseif (J <= -4e-310) tmp = U; elseif (J <= 5.1e+23) tmp = -U; 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, -1.25e+147], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -4e-310], U, If[LessEqual[J, 5.1e+23], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.25 \cdot 10^{+147}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 5.1 \cdot 10^{+23}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -1.2500000000000001e147 or 5.10000000000000021e23 < J Initial program 99.0%
*-commutative99.0%
associate-*l*99.0%
associate-*r*99.0%
*-commutative99.0%
associate-*l*99.0%
*-commutative99.0%
unpow299.0%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 48.6%
associate-*r*48.6%
*-commutative48.6%
+-commutative48.6%
fma-def48.6%
unpow248.6%
unpow248.6%
times-frac63.3%
Simplified63.3%
Taylor expanded in J around inf 49.9%
if -1.2500000000000001e147 < J < -3.999999999999988e-310Initial program 66.8%
*-commutative66.8%
associate-*l*66.8%
associate-*r*66.8%
*-commutative66.8%
associate-*l*66.7%
*-commutative66.7%
unpow266.7%
hypot-1-def87.6%
*-commutative87.6%
associate-*l*87.6%
Simplified87.6%
Taylor expanded in U around -inf 37.5%
if -3.999999999999988e-310 < J < 5.10000000000000021e23Initial program 58.0%
*-commutative58.0%
associate-*l*58.0%
associate-*r*58.0%
*-commutative58.0%
associate-*l*58.0%
*-commutative58.0%
unpow258.0%
hypot-1-def78.3%
*-commutative78.3%
associate-*l*78.3%
Simplified78.3%
Taylor expanded in J around 0 34.8%
neg-mul-134.8%
Simplified34.8%
Final simplification42.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -4e-310) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -4e-310) {
tmp = U;
} else {
tmp = -U;
}
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 <= (-4d-310)) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -4e-310) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -4e-310: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -4e-310) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -4e-310) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -4e-310], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -3.999999999999988e-310Initial program 76.4%
*-commutative76.4%
associate-*l*76.4%
associate-*r*76.4%
*-commutative76.4%
associate-*l*76.3%
*-commutative76.3%
unpow276.3%
hypot-1-def91.4%
*-commutative91.4%
associate-*l*91.4%
Simplified91.4%
Taylor expanded in U around -inf 29.7%
if -3.999999999999988e-310 < J Initial program 80.4%
*-commutative80.4%
associate-*l*80.4%
associate-*r*80.4%
*-commutative80.4%
associate-*l*80.3%
*-commutative80.3%
unpow280.3%
hypot-1-def89.8%
*-commutative89.8%
associate-*l*89.8%
Simplified89.8%
Taylor expanded in J around 0 22.0%
neg-mul-122.0%
Simplified22.0%
Final simplification25.8%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 U)
U = abs(U);
double code(double J, double K, double U) {
return U;
}
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 = u
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
return U;
}
U = abs(U) def code(J, K, U): return U
U = abs(U) function code(J, K, U) return U end
U = abs(U) function tmp = code(J, K, U) tmp = U; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := U
\begin{array}{l}
U = |U|\\
\\
U
\end{array}
Initial program 78.4%
*-commutative78.4%
associate-*l*78.4%
associate-*r*78.4%
*-commutative78.4%
associate-*l*78.4%
*-commutative78.4%
unpow278.4%
hypot-1-def90.5%
*-commutative90.5%
associate-*l*90.5%
Simplified90.5%
Taylor expanded in U around -inf 28.1%
Final simplification28.1%
herbie shell --seed 2023230
(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)))))