
(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 9 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
(*
(* t_0 (* -2.0 J))
(sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY)) (- U_m) (if (<= t_1 1e+299) t_1 U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = (t_0 * (-2.0 * J)) * 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+299) {
tmp = t_1;
} else {
tmp = U_m;
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
double t_1 = (t_0 * (-2.0 * J)) * 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+299) {
tmp = t_1;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = (t_0 * (-2.0 * J)) * 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+299: tmp = t_1 else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(t_0 * Float64(-2.0 * J)) * 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+299) tmp = t_1; else tmp = U_m; end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); t_1 = (t_0 * (-2.0 * J)) * 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+299) tmp = t_1; else tmp = U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[(-2.0 * J), $MachinePrecision]), $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+299], t$95$1, U$95$m]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(t_0 \cdot \left(-2 \cdot J\right)\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 10^{+299}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;U_m\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < -inf.0Initial program 5.4%
Simplified5.4%
Taylor expanded in J around 0 69.4%
mul-1-neg69.4%
Simplified69.4%
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)))) < 1.0000000000000001e299Initial program 99.8%
if 1.0000000000000001e299 < (*.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 7.9%
Simplified7.9%
Taylor expanded in U around -inf 52.8%
Final simplification87.8%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* J (cos (/ K 2.0)))))
(if (<= J 4.2e-199)
(- U_m)
(* -2.0 (* t_0 (hypot 1.0 (/ (/ U_m 2.0) t_0)))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = J * cos((K / 2.0));
double tmp;
if (J <= 4.2e-199) {
tmp = -U_m;
} else {
tmp = -2.0 * (t_0 * hypot(1.0, ((U_m / 2.0) / t_0)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = J * Math.cos((K / 2.0));
double tmp;
if (J <= 4.2e-199) {
tmp = -U_m;
} else {
tmp = -2.0 * (t_0 * Math.hypot(1.0, ((U_m / 2.0) / t_0)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = J * math.cos((K / 2.0)) tmp = 0 if J <= 4.2e-199: tmp = -U_m else: tmp = -2.0 * (t_0 * math.hypot(1.0, ((U_m / 2.0) / t_0))) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(J * cos(Float64(K / 2.0))) tmp = 0.0 if (J <= 4.2e-199) tmp = Float64(-U_m); else tmp = Float64(-2.0 * Float64(t_0 * hypot(1.0, Float64(Float64(U_m / 2.0) / t_0)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = J * cos((K / 2.0)); tmp = 0.0; if (J <= 4.2e-199) tmp = -U_m; else tmp = -2.0 * (t_0 * hypot(1.0, ((U_m / 2.0) / t_0))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, 4.2e-199], (-U$95$m), N[(-2.0 * N[(t$95$0 * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := J \cdot \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;J \leq 4.2 \cdot 10^{-199}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(t_0 \cdot \mathsf{hypot}\left(1, \frac{\frac{U_m}{2}}{t_0}\right)\right)\\
\end{array}
\end{array}
if J < 4.20000000000000004e-199Initial program 63.2%
Simplified63.2%
Taylor expanded in J around 0 32.4%
mul-1-neg32.4%
Simplified32.4%
if 4.20000000000000004e-199 < J Initial program 81.7%
associate-*l*81.7%
associate-*l*81.7%
unpow281.7%
sqr-neg81.7%
distribute-frac-neg81.7%
distribute-frac-neg81.7%
unpow281.7%
Simplified94.7%
Final simplification58.9%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 9e-82) (- U_m) (* -2.0 (* (* J (hypot 1.0 (* U_m (/ 0.5 J)))) (cos (* K 0.5))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 9e-82) {
tmp = -U_m;
} else {
tmp = -2.0 * ((J * hypot(1.0, (U_m * (0.5 / J)))) * cos((K * 0.5)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 9e-82) {
tmp = -U_m;
} else {
tmp = -2.0 * ((J * Math.hypot(1.0, (U_m * (0.5 / J)))) * Math.cos((K * 0.5)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 9e-82: tmp = -U_m else: tmp = -2.0 * ((J * math.hypot(1.0, (U_m * (0.5 / J)))) * math.cos((K * 0.5))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 9e-82) tmp = Float64(-U_m); else tmp = Float64(-2.0 * Float64(Float64(J * hypot(1.0, Float64(U_m * Float64(0.5 / J)))) * cos(Float64(K * 0.5)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 9e-82) tmp = -U_m; else tmp = -2.0 * ((J * hypot(1.0, (U_m * (0.5 / J)))) * cos((K * 0.5))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 9e-82], (-U$95$m), N[(-2.0 * N[(N[(J * N[Sqrt[1.0 ^ 2 + N[(U$95$m * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 9 \cdot 10^{-82}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\left(J \cdot \mathsf{hypot}\left(1, U_m \cdot \frac{0.5}{J}\right)\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if J < 8.9999999999999997e-82Initial program 62.7%
Simplified62.7%
Taylor expanded in J around 0 34.9%
mul-1-neg34.9%
Simplified34.9%
if 8.9999999999999997e-82 < J Initial program 87.0%
associate-*l*87.0%
associate-*l*87.0%
unpow287.0%
sqr-neg87.0%
distribute-frac-neg87.0%
distribute-frac-neg87.0%
unpow287.0%
Simplified99.8%
add-sqr-sqrt68.9%
pow268.9%
Applied egg-rr68.9%
Taylor expanded in K around 0 62.6%
unpow262.6%
add-sqr-sqrt85.5%
*-commutative85.5%
*-commutative85.5%
associate-*r*85.5%
*-commutative85.5%
clear-num85.5%
div-inv85.5%
associate-/r/85.5%
Applied egg-rr85.5%
Final simplification52.3%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 9e-82) (- U_m) (* -2.0 (* (* J (cos (/ K 2.0))) (hypot 1.0 (/ (/ U_m 2.0) J))))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 9e-82) {
tmp = -U_m;
} else {
tmp = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 9e-82) {
tmp = -U_m;
} else {
tmp = -2.0 * ((J * Math.cos((K / 2.0))) * Math.hypot(1.0, ((U_m / 2.0) / J)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 9e-82: tmp = -U_m else: tmp = -2.0 * ((J * math.cos((K / 2.0))) * math.hypot(1.0, ((U_m / 2.0) / J))) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 9e-82) tmp = Float64(-U_m); else tmp = Float64(-2.0 * Float64(Float64(J * cos(Float64(K / 2.0))) * hypot(1.0, Float64(Float64(U_m / 2.0) / J)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 9e-82) tmp = -U_m; else tmp = -2.0 * ((J * cos((K / 2.0))) * hypot(1.0, ((U_m / 2.0) / J))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 9e-82], (-U$95$m), N[(-2.0 * N[(N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 9 \cdot 10^{-82}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\left(J \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U_m}{2}}{J}\right)\right)\\
\end{array}
\end{array}
if J < 8.9999999999999997e-82Initial program 62.7%
Simplified62.7%
Taylor expanded in J around 0 34.9%
mul-1-neg34.9%
Simplified34.9%
if 8.9999999999999997e-82 < J Initial program 87.0%
associate-*l*87.0%
associate-*l*87.0%
unpow287.0%
sqr-neg87.0%
distribute-frac-neg87.0%
distribute-frac-neg87.0%
unpow287.0%
Simplified99.8%
Taylor expanded in K around 0 85.5%
Final simplification52.3%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= J 2.45e-80)
(- U_m)
(if (<= J 2.1e+81)
(* (* -2.0 J) (hypot 1.0 (* 0.5 (/ U_m J))))
(* (cos (* K 0.5)) (* -2.0 J)))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 2.45e-80) {
tmp = -U_m;
} else if (J <= 2.1e+81) {
tmp = (-2.0 * J) * hypot(1.0, (0.5 * (U_m / J)));
} else {
tmp = cos((K * 0.5)) * (-2.0 * J);
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 2.45e-80) {
tmp = -U_m;
} else if (J <= 2.1e+81) {
tmp = (-2.0 * J) * Math.hypot(1.0, (0.5 * (U_m / J)));
} else {
tmp = Math.cos((K * 0.5)) * (-2.0 * J);
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 2.45e-80: tmp = -U_m elif J <= 2.1e+81: tmp = (-2.0 * J) * math.hypot(1.0, (0.5 * (U_m / J))) else: tmp = math.cos((K * 0.5)) * (-2.0 * J) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 2.45e-80) tmp = Float64(-U_m); elseif (J <= 2.1e+81) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(0.5 * Float64(U_m / J)))); else tmp = Float64(cos(Float64(K * 0.5)) * 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 <= 2.45e-80) tmp = -U_m; elseif (J <= 2.1e+81) tmp = (-2.0 * J) * hypot(1.0, (0.5 * (U_m / J))); else tmp = cos((K * 0.5)) * (-2.0 * J); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 2.45e-80], (-U$95$m), If[LessEqual[J, 2.1e+81], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 2.45 \cdot 10^{-80}:\\
\;\;\;\;-U_m\\
\mathbf{elif}\;J \leq 2.1 \cdot 10^{+81}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U_m}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(-2 \cdot J\right)\\
\end{array}
\end{array}
if J < 2.44999999999999995e-80Initial program 62.7%
Simplified62.7%
Taylor expanded in J around 0 34.9%
mul-1-neg34.9%
Simplified34.9%
if 2.44999999999999995e-80 < J < 2.0999999999999999e81Initial program 64.8%
Simplified64.8%
Taylor expanded in K around 0 25.9%
associate-*r*25.9%
metadata-eval25.9%
unpow225.9%
associate-/r*25.8%
unpow225.8%
associate-*r/28.9%
associate-*l/34.8%
swap-sqr34.8%
unpow234.8%
Simplified34.8%
expm1-log1p-u14.2%
expm1-udef7.9%
associate-*l*7.9%
unpow27.9%
hypot-1-def7.9%
Applied egg-rr7.9%
expm1-def14.2%
expm1-log1p61.3%
associate-*r*61.3%
*-commutative61.3%
Simplified61.3%
if 2.0999999999999999e81 < J Initial program 99.8%
Simplified99.7%
Taylor expanded in J around inf 88.6%
associate-*r*88.6%
Simplified88.6%
Final simplification49.9%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 2.8e+38) (- U_m) (* (cos (* K 0.5)) (* -2.0 J))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 2.8e+38) {
tmp = -U_m;
} else {
tmp = cos((K * 0.5)) * (-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 <= 2.8d+38) then
tmp = -u_m
else
tmp = cos((k * 0.5d0)) * ((-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 <= 2.8e+38) {
tmp = -U_m;
} else {
tmp = Math.cos((K * 0.5)) * (-2.0 * J);
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 2.8e+38: tmp = -U_m else: tmp = math.cos((K * 0.5)) * (-2.0 * J) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 2.8e+38) tmp = Float64(-U_m); else tmp = Float64(cos(Float64(K * 0.5)) * 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 <= 2.8e+38) tmp = -U_m; else tmp = cos((K * 0.5)) * (-2.0 * J); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 2.8e+38], (-U$95$m), N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 2.8 \cdot 10^{+38}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(-2 \cdot J\right)\\
\end{array}
\end{array}
if J < 2.8e38Initial program 62.3%
Simplified62.3%
Taylor expanded in J around 0 36.6%
mul-1-neg36.6%
Simplified36.6%
if 2.8e38 < J Initial program 96.9%
Simplified96.9%
Taylor expanded in J around inf 82.9%
associate-*r*82.9%
Simplified82.9%
Final simplification48.3%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (or (<= K 3.2)
(and (not (<= K 2.7e+98))
(or (<= K 7.8e+193) (not (<= K 1.05e+225)))))
(- U_m)
U_m))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if ((K <= 3.2) || (!(K <= 2.7e+98) && ((K <= 7.8e+193) || !(K <= 1.05e+225)))) {
tmp = -U_m;
} else {
tmp = U_m;
}
return tmp;
}
U_m = abs(U)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: tmp
if ((k <= 3.2d0) .or. (.not. (k <= 2.7d+98)) .and. (k <= 7.8d+193) .or. (.not. (k <= 1.05d+225))) then
tmp = -u_m
else
tmp = u_m
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if ((K <= 3.2) || (!(K <= 2.7e+98) && ((K <= 7.8e+193) || !(K <= 1.05e+225)))) {
tmp = -U_m;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if (K <= 3.2) or (not (K <= 2.7e+98) and ((K <= 7.8e+193) or not (K <= 1.05e+225))): tmp = -U_m else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if ((K <= 3.2) || (!(K <= 2.7e+98) && ((K <= 7.8e+193) || !(K <= 1.05e+225)))) tmp = Float64(-U_m); else tmp = U_m; end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if ((K <= 3.2) || (~((K <= 2.7e+98)) && ((K <= 7.8e+193) || ~((K <= 1.05e+225))))) tmp = -U_m; else tmp = U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[Or[LessEqual[K, 3.2], And[N[Not[LessEqual[K, 2.7e+98]], $MachinePrecision], Or[LessEqual[K, 7.8e+193], N[Not[LessEqual[K, 1.05e+225]], $MachinePrecision]]]], (-U$95$m), U$95$m]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 3.2 \lor \neg \left(K \leq 2.7 \cdot 10^{+98}\right) \land \left(K \leq 7.8 \cdot 10^{+193} \lor \neg \left(K \leq 1.05 \cdot 10^{+225}\right)\right):\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;U_m\\
\end{array}
\end{array}
if K < 3.2000000000000002 or 2.7e98 < K < 7.79999999999999999e193 or 1.05e225 < K Initial program 72.1%
Simplified72.1%
Taylor expanded in J around 0 29.4%
mul-1-neg29.4%
Simplified29.4%
if 3.2000000000000002 < K < 2.7e98 or 7.79999999999999999e193 < K < 1.05e225Initial program 64.0%
Simplified63.9%
Taylor expanded in U around -inf 22.0%
Final simplification28.4%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 5.9e+84) (- U_m) (* -2.0 J)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 5.9e+84) {
tmp = -U_m;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = abs(U)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: tmp
if (j <= 5.9d+84) then
tmp = -u_m
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 5.9e+84) {
tmp = -U_m;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 5.9e+84: tmp = -U_m else: tmp = -2.0 * J return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 5.9e+84) tmp = Float64(-U_m); else tmp = Float64(-2.0 * J); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 5.9e+84) tmp = -U_m; else tmp = -2.0 * J; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 5.9e+84], (-U$95$m), N[(-2.0 * J), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 5.9 \cdot 10^{+84}:\\
\;\;\;\;-U_m\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 5.89999999999999984e84Initial program 63.0%
Simplified63.0%
Taylor expanded in J around 0 36.5%
mul-1-neg36.5%
Simplified36.5%
if 5.89999999999999984e84 < J Initial program 99.8%
Simplified99.7%
Taylor expanded in K around 0 42.1%
associate-*r*42.1%
metadata-eval42.1%
unpow242.1%
associate-/r*42.9%
unpow242.9%
associate-*r/50.3%
associate-*l/51.9%
swap-sqr51.9%
unpow251.9%
Simplified51.9%
Taylor expanded in J around inf 47.9%
*-commutative47.9%
Simplified47.9%
Final simplification39.0%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 U_m)
U_m = fabs(U);
double code(double J, double K, double U_m) {
return U_m;
}
U_m = abs(U)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
code = u_m
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
return U_m;
}
U_m = math.fabs(U) def code(J, K, U_m): return U_m
U_m = abs(U) function code(J, K, U_m) return U_m end
U_m = abs(U); function tmp = code(J, K, U_m) tmp = U_m; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := U$95$m
\begin{array}{l}
U_m = \left|U\right|
\\
U_m
\end{array}
Initial program 71.1%
Simplified71.1%
Taylor expanded in U around -inf 23.5%
Final simplification23.5%
herbie shell --seed 2024024
(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)))))