
(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 15 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}
(FPCore (J K U) :precision binary64 (let* ((t_0 (* J (cos (* K 0.5))))) (* (* t_0 -2.0) (sqrt (+ 1.0 (pow (/ (* 0.5 U) t_0) 2.0))))))
double code(double J, double K, double U) {
double t_0 = J * cos((K * 0.5));
return (t_0 * -2.0) * sqrt((1.0 + pow(((0.5 * U) / 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 = j * cos((k * 0.5d0))
code = (t_0 * (-2.0d0)) * sqrt((1.0d0 + (((0.5d0 * u) / t_0) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = J * Math.cos((K * 0.5));
return (t_0 * -2.0) * Math.sqrt((1.0 + Math.pow(((0.5 * U) / t_0), 2.0)));
}
def code(J, K, U): t_0 = J * math.cos((K * 0.5)) return (t_0 * -2.0) * math.sqrt((1.0 + math.pow(((0.5 * U) / t_0), 2.0)))
function code(J, K, U) t_0 = Float64(J * cos(Float64(K * 0.5))) return Float64(Float64(t_0 * -2.0) * sqrt(Float64(1.0 + (Float64(Float64(0.5 * U) / t_0) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = J * cos((K * 0.5)); tmp = (t_0 * -2.0) * sqrt((1.0 + (((0.5 * U) / t_0) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 * -2.0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(N[(0.5 * U), $MachinePrecision] / t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \cos \left(K \cdot 0.5\right)\\
\left(t\_0 \cdot -2\right) \cdot \sqrt{1 + {\left(\frac{0.5 \cdot U}{t\_0}\right)}^{2}}
\end{array}
\end{array}
Initial program 80.0%
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6480.0
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6480.0
Applied egg-rr80.0%
Taylor expanded in U around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6480.0
Simplified80.0%
Final simplification80.0%
(FPCore (J K U) :precision binary64 (* (* (* J (cos (* K 0.5))) -2.0) (sqrt (+ 1.0 (* (/ U (fma J 0.5 (* J (* 0.5 (cos K))))) (/ U (* J 4.0)))))))
double code(double J, double K, double U) {
return ((J * cos((K * 0.5))) * -2.0) * sqrt((1.0 + ((U / fma(J, 0.5, (J * (0.5 * cos(K))))) * (U / (J * 4.0)))));
}
function code(J, K, U) return Float64(Float64(Float64(J * cos(Float64(K * 0.5))) * -2.0) * sqrt(Float64(1.0 + Float64(Float64(U / fma(J, 0.5, Float64(J * Float64(0.5 * cos(K))))) * Float64(U / Float64(J * 4.0)))))) end
code[J_, K_, U_] := N[(N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[(N[(U / N[(J * 0.5 + N[(J * N[(0.5 * N[Cos[K], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(U / N[(J * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot -2\right) \cdot \sqrt{1 + \frac{U}{\mathsf{fma}\left(J, 0.5, J \cdot \left(0.5 \cdot \cos K\right)\right)} \cdot \frac{U}{J \cdot 4}}
\end{array}
Initial program 80.0%
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6480.0
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6480.0
Applied egg-rr80.0%
Applied egg-rr79.9%
lift-*.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
*-rgt-identityN/A
distribute-lft-inN/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6479.9
Applied egg-rr79.9%
Final simplification79.9%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (* J -2.0) (cos (/ K 2.0))))
(t_1
(/
U
(*
(* J -2.0)
(fma K (* K (fma 0.0026041666666666665 (* K K) -0.125)) 1.0)))))
(if (<= J 4.8e-158)
(* t_0 (sqrt (fma (/ U J) (* U (/ 0.25 J)) 1.0)))
(if (<= J 4.8e+113)
(*
J
(*
(sqrt (fma U (/ U (* (fma 0.5 (cos K) 0.5) (* J (* J 4.0)))) 1.0))
(* (cos (* K 0.5)) -2.0)))
(* t_0 (sqrt (fma t_1 t_1 1.0)))))))
double code(double J, double K, double U) {
double t_0 = (J * -2.0) * cos((K / 2.0));
double t_1 = U / ((J * -2.0) * fma(K, (K * fma(0.0026041666666666665, (K * K), -0.125)), 1.0));
double tmp;
if (J <= 4.8e-158) {
tmp = t_0 * sqrt(fma((U / J), (U * (0.25 / J)), 1.0));
} else if (J <= 4.8e+113) {
tmp = J * (sqrt(fma(U, (U / (fma(0.5, cos(K), 0.5) * (J * (J * 4.0)))), 1.0)) * (cos((K * 0.5)) * -2.0));
} else {
tmp = t_0 * sqrt(fma(t_1, t_1, 1.0));
}
return tmp;
}
function code(J, K, U) t_0 = Float64(Float64(J * -2.0) * cos(Float64(K / 2.0))) t_1 = Float64(U / Float64(Float64(J * -2.0) * fma(K, Float64(K * fma(0.0026041666666666665, Float64(K * K), -0.125)), 1.0))) tmp = 0.0 if (J <= 4.8e-158) tmp = Float64(t_0 * sqrt(fma(Float64(U / J), Float64(U * Float64(0.25 / J)), 1.0))); elseif (J <= 4.8e+113) tmp = Float64(J * Float64(sqrt(fma(U, Float64(U / Float64(fma(0.5, cos(K), 0.5) * Float64(J * Float64(J * 4.0)))), 1.0)) * Float64(cos(Float64(K * 0.5)) * -2.0))); else tmp = Float64(t_0 * sqrt(fma(t_1, t_1, 1.0))); end return tmp end
code[J_, K_, U_] := Block[{t$95$0 = N[(N[(J * -2.0), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U / N[(N[(J * -2.0), $MachinePrecision] * N[(K * N[(K * N[(0.0026041666666666665 * N[(K * K), $MachinePrecision] + -0.125), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, 4.8e-158], N[(t$95$0 * N[Sqrt[N[(N[(U / J), $MachinePrecision] * N[(U * N[(0.25 / J), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 4.8e+113], N[(J * N[(N[Sqrt[N[(U * N[(U / N[(N[(0.5 * N[Cos[K], $MachinePrecision] + 0.5), $MachinePrecision] * N[(J * N[(J * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Sqrt[N[(t$95$1 * t$95$1 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\\
t_1 := \frac{U}{\left(J \cdot -2\right) \cdot \mathsf{fma}\left(K, K \cdot \mathsf{fma}\left(0.0026041666666666665, K \cdot K, -0.125\right), 1\right)}\\
\mathbf{if}\;J \leq 4.8 \cdot 10^{-158}:\\
\;\;\;\;t\_0 \cdot \sqrt{\mathsf{fma}\left(\frac{U}{J}, U \cdot \frac{0.25}{J}, 1\right)}\\
\mathbf{elif}\;J \leq 4.8 \cdot 10^{+113}:\\
\;\;\;\;J \cdot \left(\sqrt{\mathsf{fma}\left(U, \frac{U}{\mathsf{fma}\left(0.5, \cos K, 0.5\right) \cdot \left(J \cdot \left(J \cdot 4\right)\right)}, 1\right)} \cdot \left(\cos \left(K \cdot 0.5\right) \cdot -2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{\mathsf{fma}\left(t\_1, t\_1, 1\right)}\\
\end{array}
\end{array}
if J < 4.80000000000000015e-158Initial program 75.5%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6465.2
Simplified65.2%
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6465.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f6465.2
Applied egg-rr65.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
Applied egg-rr65.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f6465.2
lift-/.f64N/A
div-invN/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6465.2
Applied egg-rr65.2%
if 4.80000000000000015e-158 < J < 4.79999999999999966e113Initial program 76.9%
Applied egg-rr76.8%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6476.8
Applied egg-rr76.8%
if 4.79999999999999966e113 < J Initial program 99.8%
Taylor expanded in K around 0
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6497.8
Simplified97.8%
Applied egg-rr97.8%
Final simplification73.4%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (* J -2.0) (cos (/ K 2.0))))
(t_1
(/
U
(*
(* J -2.0)
(fma K (* K (fma 0.0026041666666666665 (* K K) -0.125)) 1.0)))))
(if (<= J 4.8e-158)
(* t_0 (sqrt (fma (/ U J) (* U (/ 0.25 J)) 1.0)))
(if (<= J 4.8e+113)
(*
(cos (* K 0.5))
(*
(* J -2.0)
(sqrt (fma U (/ U (* (* J (* J 4.0)) (fma (cos K) 0.5 0.5))) 1.0))))
(* t_0 (sqrt (fma t_1 t_1 1.0)))))))
double code(double J, double K, double U) {
double t_0 = (J * -2.0) * cos((K / 2.0));
double t_1 = U / ((J * -2.0) * fma(K, (K * fma(0.0026041666666666665, (K * K), -0.125)), 1.0));
double tmp;
if (J <= 4.8e-158) {
tmp = t_0 * sqrt(fma((U / J), (U * (0.25 / J)), 1.0));
} else if (J <= 4.8e+113) {
tmp = cos((K * 0.5)) * ((J * -2.0) * sqrt(fma(U, (U / ((J * (J * 4.0)) * fma(cos(K), 0.5, 0.5))), 1.0)));
} else {
tmp = t_0 * sqrt(fma(t_1, t_1, 1.0));
}
return tmp;
}
function code(J, K, U) t_0 = Float64(Float64(J * -2.0) * cos(Float64(K / 2.0))) t_1 = Float64(U / Float64(Float64(J * -2.0) * fma(K, Float64(K * fma(0.0026041666666666665, Float64(K * K), -0.125)), 1.0))) tmp = 0.0 if (J <= 4.8e-158) tmp = Float64(t_0 * sqrt(fma(Float64(U / J), Float64(U * Float64(0.25 / J)), 1.0))); elseif (J <= 4.8e+113) tmp = Float64(cos(Float64(K * 0.5)) * Float64(Float64(J * -2.0) * sqrt(fma(U, Float64(U / Float64(Float64(J * Float64(J * 4.0)) * fma(cos(K), 0.5, 0.5))), 1.0)))); else tmp = Float64(t_0 * sqrt(fma(t_1, t_1, 1.0))); end return tmp end
code[J_, K_, U_] := Block[{t$95$0 = N[(N[(J * -2.0), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U / N[(N[(J * -2.0), $MachinePrecision] * N[(K * N[(K * N[(0.0026041666666666665 * N[(K * K), $MachinePrecision] + -0.125), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, 4.8e-158], N[(t$95$0 * N[Sqrt[N[(N[(U / J), $MachinePrecision] * N[(U * N[(0.25 / J), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 4.8e+113], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(N[(J * -2.0), $MachinePrecision] * N[Sqrt[N[(U * N[(U / N[(N[(J * N[(J * 4.0), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[K], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Sqrt[N[(t$95$1 * t$95$1 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\\
t_1 := \frac{U}{\left(J \cdot -2\right) \cdot \mathsf{fma}\left(K, K \cdot \mathsf{fma}\left(0.0026041666666666665, K \cdot K, -0.125\right), 1\right)}\\
\mathbf{if}\;J \leq 4.8 \cdot 10^{-158}:\\
\;\;\;\;t\_0 \cdot \sqrt{\mathsf{fma}\left(\frac{U}{J}, U \cdot \frac{0.25}{J}, 1\right)}\\
\mathbf{elif}\;J \leq 4.8 \cdot 10^{+113}:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(\left(J \cdot -2\right) \cdot \sqrt{\mathsf{fma}\left(U, \frac{U}{\left(J \cdot \left(J \cdot 4\right)\right) \cdot \mathsf{fma}\left(\cos K, 0.5, 0.5\right)}, 1\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{\mathsf{fma}\left(t\_1, t\_1, 1\right)}\\
\end{array}
\end{array}
if J < 4.80000000000000015e-158Initial program 75.5%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6465.2
Simplified65.2%
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6465.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f6465.2
Applied egg-rr65.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
Applied egg-rr65.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f6465.2
lift-/.f64N/A
div-invN/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6465.2
Applied egg-rr65.2%
if 4.80000000000000015e-158 < J < 4.79999999999999966e113Initial program 76.9%
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6476.9
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6476.9
Applied egg-rr76.9%
Applied egg-rr76.8%
lift-*.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f6476.8
lift-*.f64N/A
*-rgt-identity76.8
Applied egg-rr76.8%
if 4.79999999999999966e113 < J Initial program 99.8%
Taylor expanded in K around 0
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6497.8
Simplified97.8%
Applied egg-rr97.8%
Final simplification73.4%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* (* J -2.0) (cos (/ K 2.0))))
(t_1
(/
U
(*
(* J -2.0)
(fma K (* K (fma 0.0026041666666666665 (* K K) -0.125)) 1.0)))))
(if (<= J 4.8e-158)
(* t_0 (sqrt (fma (/ U J) (* U (/ 0.25 J)) 1.0)))
(if (<= J 4.8e+113)
(*
(* J -2.0)
(*
(cos (* K 0.5))
(sqrt (fma U (/ U (* J (* (fma 0.5 (cos K) 0.5) (* J 4.0)))) 1.0))))
(* t_0 (sqrt (fma t_1 t_1 1.0)))))))
double code(double J, double K, double U) {
double t_0 = (J * -2.0) * cos((K / 2.0));
double t_1 = U / ((J * -2.0) * fma(K, (K * fma(0.0026041666666666665, (K * K), -0.125)), 1.0));
double tmp;
if (J <= 4.8e-158) {
tmp = t_0 * sqrt(fma((U / J), (U * (0.25 / J)), 1.0));
} else if (J <= 4.8e+113) {
tmp = (J * -2.0) * (cos((K * 0.5)) * sqrt(fma(U, (U / (J * (fma(0.5, cos(K), 0.5) * (J * 4.0)))), 1.0)));
} else {
tmp = t_0 * sqrt(fma(t_1, t_1, 1.0));
}
return tmp;
}
function code(J, K, U) t_0 = Float64(Float64(J * -2.0) * cos(Float64(K / 2.0))) t_1 = Float64(U / Float64(Float64(J * -2.0) * fma(K, Float64(K * fma(0.0026041666666666665, Float64(K * K), -0.125)), 1.0))) tmp = 0.0 if (J <= 4.8e-158) tmp = Float64(t_0 * sqrt(fma(Float64(U / J), Float64(U * Float64(0.25 / J)), 1.0))); elseif (J <= 4.8e+113) tmp = Float64(Float64(J * -2.0) * Float64(cos(Float64(K * 0.5)) * sqrt(fma(U, Float64(U / Float64(J * Float64(fma(0.5, cos(K), 0.5) * Float64(J * 4.0)))), 1.0)))); else tmp = Float64(t_0 * sqrt(fma(t_1, t_1, 1.0))); end return tmp end
code[J_, K_, U_] := Block[{t$95$0 = N[(N[(J * -2.0), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U / N[(N[(J * -2.0), $MachinePrecision] * N[(K * N[(K * N[(0.0026041666666666665 * N[(K * K), $MachinePrecision] + -0.125), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, 4.8e-158], N[(t$95$0 * N[Sqrt[N[(N[(U / J), $MachinePrecision] * N[(U * N[(0.25 / J), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 4.8e+113], N[(N[(J * -2.0), $MachinePrecision] * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(U * N[(U / N[(J * N[(N[(0.5 * N[Cos[K], $MachinePrecision] + 0.5), $MachinePrecision] * N[(J * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Sqrt[N[(t$95$1 * t$95$1 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\\
t_1 := \frac{U}{\left(J \cdot -2\right) \cdot \mathsf{fma}\left(K, K \cdot \mathsf{fma}\left(0.0026041666666666665, K \cdot K, -0.125\right), 1\right)}\\
\mathbf{if}\;J \leq 4.8 \cdot 10^{-158}:\\
\;\;\;\;t\_0 \cdot \sqrt{\mathsf{fma}\left(\frac{U}{J}, U \cdot \frac{0.25}{J}, 1\right)}\\
\mathbf{elif}\;J \leq 4.8 \cdot 10^{+113}:\\
\;\;\;\;\left(J \cdot -2\right) \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \sqrt{\mathsf{fma}\left(U, \frac{U}{J \cdot \left(\mathsf{fma}\left(0.5, \cos K, 0.5\right) \cdot \left(J \cdot 4\right)\right)}, 1\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{\mathsf{fma}\left(t\_1, t\_1, 1\right)}\\
\end{array}
\end{array}
if J < 4.80000000000000015e-158Initial program 75.5%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6465.2
Simplified65.2%
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6465.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f6465.2
Applied egg-rr65.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
Applied egg-rr65.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f6465.2
lift-/.f64N/A
div-invN/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6465.2
Applied egg-rr65.2%
if 4.80000000000000015e-158 < J < 4.79999999999999966e113Initial program 76.9%
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6476.9
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6476.9
Applied egg-rr76.9%
Applied egg-rr76.8%
Applied egg-rr76.7%
if 4.79999999999999966e113 < J Initial program 99.8%
Taylor expanded in K around 0
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6497.8
Simplified97.8%
Applied egg-rr97.8%
Final simplification73.4%
(FPCore (J K U)
:precision binary64
(if (<= J 1.02e-238)
(* (* J -2.0) (sqrt (fma (/ U (* J 4.0)) (/ U J) 1.0)))
(*
(cos (* K 0.5))
(*
(* J -2.0)
(sqrt (fma U (/ (/ U (* J (fma 0.5 (cos K) 0.5))) (* J 4.0)) 1.0))))))
double code(double J, double K, double U) {
double tmp;
if (J <= 1.02e-238) {
tmp = (J * -2.0) * sqrt(fma((U / (J * 4.0)), (U / J), 1.0));
} else {
tmp = cos((K * 0.5)) * ((J * -2.0) * sqrt(fma(U, ((U / (J * fma(0.5, cos(K), 0.5))) / (J * 4.0)), 1.0)));
}
return tmp;
}
function code(J, K, U) tmp = 0.0 if (J <= 1.02e-238) tmp = Float64(Float64(J * -2.0) * sqrt(fma(Float64(U / Float64(J * 4.0)), Float64(U / J), 1.0))); else tmp = Float64(cos(Float64(K * 0.5)) * Float64(Float64(J * -2.0) * sqrt(fma(U, Float64(Float64(U / Float64(J * fma(0.5, cos(K), 0.5))) / Float64(J * 4.0)), 1.0)))); end return tmp end
code[J_, K_, U_] := If[LessEqual[J, 1.02e-238], N[(N[(J * -2.0), $MachinePrecision] * N[Sqrt[N[(N[(U / N[(J * 4.0), $MachinePrecision]), $MachinePrecision] * N[(U / J), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(N[(J * -2.0), $MachinePrecision] * N[Sqrt[N[(U * N[(N[(U / N[(J * N[(0.5 * N[Cos[K], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(J * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \leq 1.02 \cdot 10^{-238}:\\
\;\;\;\;\left(J \cdot -2\right) \cdot \sqrt{\mathsf{fma}\left(\frac{U}{J \cdot 4}, \frac{U}{J}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(\left(J \cdot -2\right) \cdot \sqrt{\mathsf{fma}\left(U, \frac{\frac{U}{J \cdot \mathsf{fma}\left(0.5, \cos K, 0.5\right)}}{J \cdot 4}, 1\right)}\right)\\
\end{array}
\end{array}
if J < 1.01999999999999992e-238Initial program 78.3%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6468.3
Simplified68.3%
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6468.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f6468.2
Applied egg-rr68.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
Applied egg-rr68.3%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6445.1
Simplified45.1%
if 1.01999999999999992e-238 < J Initial program 81.9%
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6481.9
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6481.9
Applied egg-rr81.9%
Applied egg-rr71.4%
lift-*.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f6471.4
lift-*.f64N/A
*-rgt-identity71.4
Applied egg-rr71.4%
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lower-/.f6481.0
Applied egg-rr81.0%
Final simplification61.9%
(FPCore (J K U) :precision binary64 (* (* (* J (cos (* K 0.5))) -2.0) (sqrt (+ 1.0 (* (/ U (* J 4.0)) (/ U (* J (fma 0.5 (cos K) 0.5))))))))
double code(double J, double K, double U) {
return ((J * cos((K * 0.5))) * -2.0) * sqrt((1.0 + ((U / (J * 4.0)) * (U / (J * fma(0.5, cos(K), 0.5))))));
}
function code(J, K, U) return Float64(Float64(Float64(J * cos(Float64(K * 0.5))) * -2.0) * sqrt(Float64(1.0 + Float64(Float64(U / Float64(J * 4.0)) * Float64(U / Float64(J * fma(0.5, cos(K), 0.5))))))) end
code[J_, K_, U_] := N[(N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[(N[(U / N[(J * 4.0), $MachinePrecision]), $MachinePrecision] * N[(U / N[(J * N[(0.5 * N[Cos[K], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot -2\right) \cdot \sqrt{1 + \frac{U}{J \cdot 4} \cdot \frac{U}{J \cdot \mathsf{fma}\left(0.5, \cos K, 0.5\right)}}
\end{array}
Initial program 80.0%
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6480.0
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6480.0
Applied egg-rr80.0%
Applied egg-rr79.9%
Final simplification79.9%
(FPCore (J K U) :precision binary64 (* (* (* J (cos (* K 0.5))) -2.0) (sqrt (fma (/ U (* J (fma 0.5 (cos K) 0.5))) (* U (/ 0.25 J)) 1.0))))
double code(double J, double K, double U) {
return ((J * cos((K * 0.5))) * -2.0) * sqrt(fma((U / (J * fma(0.5, cos(K), 0.5))), (U * (0.25 / J)), 1.0));
}
function code(J, K, U) return Float64(Float64(Float64(J * cos(Float64(K * 0.5))) * -2.0) * sqrt(fma(Float64(U / Float64(J * fma(0.5, cos(K), 0.5))), Float64(U * Float64(0.25 / J)), 1.0))) end
code[J_, K_, U_] := N[(N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision] * N[Sqrt[N[(N[(U / N[(J * N[(0.5 * N[Cos[K], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(U * N[(0.25 / J), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot -2\right) \cdot \sqrt{\mathsf{fma}\left(\frac{U}{J \cdot \mathsf{fma}\left(0.5, \cos K, 0.5\right)}, U \cdot \frac{0.25}{J}, 1\right)}
\end{array}
Initial program 80.0%
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6480.0
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6480.0
Applied egg-rr80.0%
Applied egg-rr79.9%
lift-*.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6479.9
Applied egg-rr79.8%
(FPCore (J K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.999) (* (cos (* K 0.5)) (* J -2.0)) (* (* J -2.0) (sqrt (fma (/ U (* J 4.0)) (/ U J) 1.0)))))
double code(double J, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.999) {
tmp = cos((K * 0.5)) * (J * -2.0);
} else {
tmp = (J * -2.0) * sqrt(fma((U / (J * 4.0)), (U / J), 1.0));
}
return tmp;
}
function code(J, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.999) tmp = Float64(cos(Float64(K * 0.5)) * Float64(J * -2.0)); else tmp = Float64(Float64(J * -2.0) * sqrt(fma(Float64(U / Float64(J * 4.0)), Float64(U / J), 1.0))); end return tmp end
code[J_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.999], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(J * -2.0), $MachinePrecision] * N[Sqrt[N[(N[(U / N[(J * 4.0), $MachinePrecision]), $MachinePrecision] * N[(U / J), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.999:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot -2\right) \cdot \sqrt{\mathsf{fma}\left(\frac{U}{J \cdot 4}, \frac{U}{J}, 1\right)}\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.998999999999999999Initial program 83.7%
Taylor expanded in J around inf
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6460.5
Simplified60.5%
if 0.998999999999999999 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 76.6%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6475.7
Simplified75.7%
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6475.7
lift-*.f64N/A
*-commutativeN/A
lift-*.f6475.7
Applied egg-rr75.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
Applied egg-rr75.7%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6476.2
Simplified76.2%
Final simplification68.7%
(FPCore (J K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.04) (* (cos (* K 0.5)) (- J)) (* (* J -2.0) (sqrt (fma (/ U (* J 4.0)) (/ U J) 1.0)))))
double code(double J, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.04) {
tmp = cos((K * 0.5)) * -J;
} else {
tmp = (J * -2.0) * sqrt(fma((U / (J * 4.0)), (U / J), 1.0));
}
return tmp;
}
function code(J, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.04) tmp = Float64(cos(Float64(K * 0.5)) * Float64(-J)); else tmp = Float64(Float64(J * -2.0) * sqrt(fma(Float64(U / Float64(J * 4.0)), Float64(U / J), 1.0))); end return tmp end
code[J_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.04], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * (-J)), $MachinePrecision], N[(N[(J * -2.0), $MachinePrecision] * N[Sqrt[N[(N[(U / N[(J * 4.0), $MachinePrecision]), $MachinePrecision] * N[(U / J), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.04:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(-J\right)\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot -2\right) \cdot \sqrt{\mathsf{fma}\left(\frac{U}{J \cdot 4}, \frac{U}{J}, 1\right)}\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0400000000000000008Initial program 85.4%
Taylor expanded in J around inf
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6461.4
Simplified61.4%
Taylor expanded in J around -inf
mul-1-negN/A
lower-neg.f6413.8
Simplified13.8%
if 0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 77.9%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6472.2
Simplified72.2%
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6472.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f6472.2
Applied egg-rr72.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
Applied egg-rr72.2%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6465.1
Simplified65.1%
Final simplification50.6%
(FPCore (J K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.05) (* (* J -2.0) (cos (- K))) (* (* J -2.0) (sqrt (fma (/ U (* J 4.0)) (/ U J) 1.0)))))
double code(double J, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.05) {
tmp = (J * -2.0) * cos(-K);
} else {
tmp = (J * -2.0) * sqrt(fma((U / (J * 4.0)), (U / J), 1.0));
}
return tmp;
}
function code(J, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.05) tmp = Float64(Float64(J * -2.0) * cos(Float64(-K))); else tmp = Float64(Float64(J * -2.0) * sqrt(fma(Float64(U / Float64(J * 4.0)), Float64(U / J), 1.0))); end return tmp end
code[J_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(N[(J * -2.0), $MachinePrecision] * N[Cos[(-K)], $MachinePrecision]), $MachinePrecision], N[(N[(J * -2.0), $MachinePrecision] * N[Sqrt[N[(N[(U / N[(J * 4.0), $MachinePrecision]), $MachinePrecision] * N[(U / J), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\
\;\;\;\;\left(J \cdot -2\right) \cdot \cos \left(-K\right)\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot -2\right) \cdot \sqrt{\mathsf{fma}\left(\frac{U}{J \cdot 4}, \frac{U}{J}, 1\right)}\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.050000000000000003Initial program 85.2%
Taylor expanded in J around inf
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6460.9
Simplified60.9%
Taylor expanded in K around -inf
mul-1-negN/A
lower-neg.f647.3
Simplified7.3%
if -0.050000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 78.0%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6472.3
Simplified72.3%
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6472.3
lift-*.f64N/A
*-commutativeN/A
lift-*.f6472.3
Applied egg-rr72.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
Applied egg-rr72.3%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6464.8
Simplified64.8%
Final simplification48.8%
(FPCore (J K U) :precision binary64 (* (sqrt (fma (/ U (* J 4.0)) (/ U J) 1.0)) (* J (* (cos (* K 0.5)) -2.0))))
double code(double J, double K, double U) {
return sqrt(fma((U / (J * 4.0)), (U / J), 1.0)) * (J * (cos((K * 0.5)) * -2.0));
}
function code(J, K, U) return Float64(sqrt(fma(Float64(U / Float64(J * 4.0)), Float64(U / J), 1.0)) * Float64(J * Float64(cos(Float64(K * 0.5)) * -2.0))) end
code[J_, K_, U_] := N[(N[Sqrt[N[(N[(U / N[(J * 4.0), $MachinePrecision]), $MachinePrecision] * N[(U / J), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(\frac{U}{J \cdot 4}, \frac{U}{J}, 1\right)} \cdot \left(J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot -2\right)\right)
\end{array}
Initial program 80.0%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6470.2
Simplified70.2%
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6470.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f6470.2
Applied egg-rr70.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
Applied egg-rr70.2%
*-commutativeN/A
div-invN/A
metadata-evalN/A
lift-*.f64N/A
lift-cos.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6470.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.2
Applied egg-rr70.2%
Final simplification70.2%
(FPCore (J K U) :precision binary64 (* (* J -2.0) (sqrt (fma (/ U (* J 4.0)) (/ U J) 1.0))))
double code(double J, double K, double U) {
return (J * -2.0) * sqrt(fma((U / (J * 4.0)), (U / J), 1.0));
}
function code(J, K, U) return Float64(Float64(J * -2.0) * sqrt(fma(Float64(U / Float64(J * 4.0)), Float64(U / J), 1.0))) end
code[J_, K_, U_] := N[(N[(J * -2.0), $MachinePrecision] * N[Sqrt[N[(N[(U / N[(J * 4.0), $MachinePrecision]), $MachinePrecision] * N[(U / J), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot -2\right) \cdot \sqrt{\mathsf{fma}\left(\frac{U}{J \cdot 4}, \frac{U}{J}, 1\right)}
\end{array}
Initial program 80.0%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6470.2
Simplified70.2%
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6470.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f6470.2
Applied egg-rr70.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
Applied egg-rr70.2%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6447.1
Simplified47.1%
(FPCore (J K U) :precision binary64 (* J -2.0))
double code(double J, double K, double U) {
return J * -2.0;
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
code = j * (-2.0d0)
end function
public static double code(double J, double K, double U) {
return J * -2.0;
}
def code(J, K, U): return J * -2.0
function code(J, K, U) return Float64(J * -2.0) end
function tmp = code(J, K, U) tmp = J * -2.0; end
code[J_, K_, U_] := N[(J * -2.0), $MachinePrecision]
\begin{array}{l}
\\
J \cdot -2
\end{array}
Initial program 80.0%
Taylor expanded in J around inf
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6455.8
Simplified55.8%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6429.9
Simplified29.9%
(FPCore (J K U) :precision binary64 (- J))
double code(double J, double K, double U) {
return -J;
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
code = -j
end function
public static double code(double J, double K, double U) {
return -J;
}
def code(J, K, U): return -J
function code(J, K, U) return Float64(-J) end
function tmp = code(J, K, U) tmp = -J; end
code[J_, K_, U_] := (-J)
\begin{array}{l}
\\
-J
\end{array}
Initial program 80.0%
Taylor expanded in J around inf
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6455.8
Simplified55.8%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f6429.9
Simplified29.9%
Taylor expanded in J around -inf
mul-1-negN/A
lower-neg.f649.3
Simplified9.3%
herbie shell --seed 2024214
(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)))))