
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(pow (/ (* 2.0 l) Om) 2.0)
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(pow (/ (* 2.0 l) Om) 2.0)
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))
(/ (* l (* (/ l Om) 4.0)) Om)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)) * ((l * ((l / Om) * 4.0)) / Om))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + (((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)) * ((l * ((l / om) * 4.0d0)) / om))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + ((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)) * ((l * ((l / Om) * 4.0)) / Om))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + ((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)) * ((l * ((l / Om) * 4.0)) / Om))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)) * Float64(Float64(l * Float64(Float64(l / Om) * 4.0)) / Om)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)) * ((l * ((l / Om) * 4.0)) / Om)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(N[(l * N[(N[(l / Om), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + \left({\sin kx}^{2} + {\sin ky}^{2}\right) \cdot \frac{\ell \cdot \left(\frac{\ell}{Om} \cdot 4\right)}{Om}}}\right)}
\end{array}
Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (l Om kx ky)
:precision binary64
(if (<=
(/
1.0
(sqrt
(+
1.0
(*
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))
(pow (/ (* 2.0 l) Om) 2.0)))))
2e-6)
(sqrt
(+
0.5
(/
0.5
(sqrt
(fma (/ (* l (* (/ l Om) 4.0)) Om) (+ (+ 0.5 -0.5) (* ky ky)) 1.0)))))
1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if ((1.0 / sqrt((1.0 + ((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)) * pow(((2.0 * l) / Om), 2.0))))) <= 2e-6) {
tmp = sqrt((0.5 + (0.5 / sqrt(fma(((l * ((l / Om) * 4.0)) / Om), ((0.5 + -0.5) + (ky * ky)), 1.0)))));
} else {
tmp = 1.0;
}
return tmp;
}
function code(l, Om, kx, ky) tmp = 0.0 if (Float64(1.0 / sqrt(Float64(1.0 + Float64(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)) * (Float64(Float64(2.0 * l) / Om) ^ 2.0))))) <= 2e-6) tmp = sqrt(Float64(0.5 + Float64(0.5 / sqrt(fma(Float64(Float64(l * Float64(Float64(l / Om) * 4.0)) / Om), Float64(Float64(0.5 + -0.5) + Float64(ky * ky)), 1.0))))); else tmp = 1.0; end return tmp end
code[l_, Om_, kx_, ky_] := If[LessEqual[N[(1.0 / N[Sqrt[N[(1.0 + N[(N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2e-6], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[N[(N[(N[(l * N[(N[(l / Om), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] * N[(N[(0.5 + -0.5), $MachinePrecision] + N[(ky * ky), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{1 + \left({\sin kx}^{2} + {\sin ky}^{2}\right) \cdot {\left(\frac{2 \cdot \ell}{Om}\right)}^{2}}} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{\mathsf{fma}\left(\frac{\ell \cdot \left(\frac{\ell}{Om} \cdot 4\right)}{Om}, \left(0.5 + -0.5\right) + ky \cdot ky, 1\right)}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 #s(literal 2 binary64) l) Om) #s(literal 2 binary64)) (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))))) < 1.99999999999999991e-6Initial program 100.0%
Applied egg-rr73.3%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6486.0
Simplified86.0%
Taylor expanded in kx around 0
Simplified77.3%
associate-*r*N/A
times-fracN/A
associate-*r/N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6483.2
Applied egg-rr83.2%
if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 #s(literal 2 binary64) l) Om) #s(literal 2 binary64)) (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))))) Initial program 99.2%
Taylor expanded in l around 0
Simplified98.7%
metadata-eval98.7
Applied egg-rr98.7%
Final simplification91.0%
(FPCore (l Om kx ky)
:precision binary64
(if (<=
(* (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)) (pow (/ (* 2.0 l) Om) 2.0))
2e-9)
1.0
(sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)) * pow(((2.0 * l) / Om), 2.0)) <= 2e-9) {
tmp = 1.0;
} else {
tmp = sqrt(0.5);
}
return tmp;
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8) :: tmp
if ((((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)) * (((2.0d0 * l) / om) ** 2.0d0)) <= 2d-9) then
tmp = 1.0d0
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)) * Math.pow(((2.0 * l) / Om), 2.0)) <= 2e-9) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if ((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)) * math.pow(((2.0 * l) / Om), 2.0)) <= 2e-9: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Float64(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)) * (Float64(Float64(2.0 * l) / Om) ^ 2.0)) <= 2e-9) tmp = 1.0; else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if ((((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)) * (((2.0 * l) / Om) ^ 2.0)) <= 2e-9) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[N[(N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 2e-9], 1.0, N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left({\sin kx}^{2} + {\sin ky}^{2}\right) \cdot {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 #s(literal 2 binary64) l) Om) #s(literal 2 binary64)) (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))) < 2.00000000000000012e-9Initial program 100.0%
Taylor expanded in l around 0
Simplified99.4%
metadata-eval99.4
Applied egg-rr99.4%
if 2.00000000000000012e-9 < (*.f64 (pow.f64 (/.f64 (*.f64 #s(literal 2 binary64) l) Om) #s(literal 2 binary64)) (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))) Initial program 99.2%
Taylor expanded in l around inf
Simplified99.0%
Final simplification99.2%
(FPCore (l Om kx ky)
:precision binary64
(let* ((t_0 (* (/ l Om) 4.0)))
(if (<= (/ (* 2.0 l) Om) 5e+15)
(sqrt
(*
0.5
(+
1.0
(/
1.0
(sqrt
(fma
t_0
(* (/ l Om) (fma -0.5 (+ (cos (* ky -2.0)) (cos (* kx -2.0))) 1.0))
1.0))))))
(sqrt
(+
0.5
(/
0.5
(sqrt (fma (/ (* l t_0) Om) (+ (+ 0.5 -0.5) (* ky ky)) 1.0))))))))
double code(double l, double Om, double kx, double ky) {
double t_0 = (l / Om) * 4.0;
double tmp;
if (((2.0 * l) / Om) <= 5e+15) {
tmp = sqrt((0.5 * (1.0 + (1.0 / sqrt(fma(t_0, ((l / Om) * fma(-0.5, (cos((ky * -2.0)) + cos((kx * -2.0))), 1.0)), 1.0))))));
} else {
tmp = sqrt((0.5 + (0.5 / sqrt(fma(((l * t_0) / Om), ((0.5 + -0.5) + (ky * ky)), 1.0)))));
}
return tmp;
}
function code(l, Om, kx, ky) t_0 = Float64(Float64(l / Om) * 4.0) tmp = 0.0 if (Float64(Float64(2.0 * l) / Om) <= 5e+15) tmp = sqrt(Float64(0.5 * Float64(1.0 + Float64(1.0 / sqrt(fma(t_0, Float64(Float64(l / Om) * fma(-0.5, Float64(cos(Float64(ky * -2.0)) + cos(Float64(kx * -2.0))), 1.0)), 1.0)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / sqrt(fma(Float64(Float64(l * t_0) / Om), Float64(Float64(0.5 + -0.5) + Float64(ky * ky)), 1.0))))); end return tmp end
code[l_, Om_, kx_, ky_] := Block[{t$95$0 = N[(N[(l / Om), $MachinePrecision] * 4.0), $MachinePrecision]}, If[LessEqual[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 5e+15], N[Sqrt[N[(0.5 * N[(1.0 + N[(1.0 / N[Sqrt[N[(t$95$0 * N[(N[(l / Om), $MachinePrecision] * N[(-0.5 * N[(N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[N[(N[(N[(l * t$95$0), $MachinePrecision] / Om), $MachinePrecision] * N[(N[(0.5 + -0.5), $MachinePrecision] + N[(ky * ky), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\ell}{Om} \cdot 4\\
\mathbf{if}\;\frac{2 \cdot \ell}{Om} \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(1 + \frac{1}{\sqrt{\mathsf{fma}\left(t\_0, \frac{\ell}{Om} \cdot \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right) + \cos \left(kx \cdot -2\right), 1\right), 1\right)}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{\mathsf{fma}\left(\frac{\ell \cdot t\_0}{Om}, \left(0.5 + -0.5\right) + ky \cdot ky, 1\right)}}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 #s(literal 2 binary64) l) Om) < 5e15Initial program 99.5%
Applied egg-rr94.5%
metadata-eval94.5
Applied egg-rr94.5%
Taylor expanded in kx around inf
+-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
+-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
lower-+.f64N/A
cos-negN/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
cos-negN/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6494.5
Simplified94.5%
if 5e15 < (/.f64 (*.f64 #s(literal 2 binary64) l) Om) Initial program 100.0%
Applied egg-rr73.5%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6485.8
Simplified85.8%
Taylor expanded in kx around 0
Simplified76.1%
associate-*r*N/A
times-fracN/A
associate-*r/N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6483.5
Applied egg-rr83.5%
Final simplification91.8%
(FPCore (l Om kx ky)
:precision binary64
(if (<= (/ (* 2.0 l) Om) 5e+15)
(sqrt
(+
0.5
(/
0.5
(sqrt
(fma
(/ (* l (/ (* l 4.0) Om)) Om)
(fma -0.5 (cos (* ky -2.0)) 0.5)
1.0)))))
(sqrt
(+
0.5
(/
0.5
(sqrt
(fma (/ (* l (* (/ l Om) 4.0)) Om) (+ (+ 0.5 -0.5) (* ky ky)) 1.0)))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (((2.0 * l) / Om) <= 5e+15) {
tmp = sqrt((0.5 + (0.5 / sqrt(fma(((l * ((l * 4.0) / Om)) / Om), fma(-0.5, cos((ky * -2.0)), 0.5), 1.0)))));
} else {
tmp = sqrt((0.5 + (0.5 / sqrt(fma(((l * ((l / Om) * 4.0)) / Om), ((0.5 + -0.5) + (ky * ky)), 1.0)))));
}
return tmp;
}
function code(l, Om, kx, ky) tmp = 0.0 if (Float64(Float64(2.0 * l) / Om) <= 5e+15) tmp = sqrt(Float64(0.5 + Float64(0.5 / sqrt(fma(Float64(Float64(l * Float64(Float64(l * 4.0) / Om)) / Om), fma(-0.5, cos(Float64(ky * -2.0)), 0.5), 1.0))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / sqrt(fma(Float64(Float64(l * Float64(Float64(l / Om) * 4.0)) / Om), Float64(Float64(0.5 + -0.5) + Float64(ky * ky)), 1.0))))); end return tmp end
code[l_, Om_, kx_, ky_] := If[LessEqual[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 5e+15], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[N[(N[(N[(l * N[(N[(l * 4.0), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] * N[(-0.5 * N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[N[(N[(N[(l * N[(N[(l / Om), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] * N[(N[(0.5 + -0.5), $MachinePrecision] + N[(ky * ky), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{2 \cdot \ell}{Om} \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{\mathsf{fma}\left(\frac{\ell \cdot \frac{\ell \cdot 4}{Om}}{Om}, \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right), 1\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{\mathsf{fma}\left(\frac{\ell \cdot \left(\frac{\ell}{Om} \cdot 4\right)}{Om}, \left(0.5 + -0.5\right) + ky \cdot ky, 1\right)}}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 #s(literal 2 binary64) l) Om) < 5e15Initial program 99.5%
Applied egg-rr80.5%
Taylor expanded in kx around 0
+-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
cos-negN/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6475.5
Simplified75.5%
associate-*r*N/A
times-fracN/A
associate-*r/N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6486.6
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f6486.6
Applied egg-rr86.6%
if 5e15 < (/.f64 (*.f64 #s(literal 2 binary64) l) Om) Initial program 100.0%
Applied egg-rr73.5%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6485.8
Simplified85.8%
Taylor expanded in kx around 0
Simplified76.1%
associate-*r*N/A
times-fracN/A
associate-*r/N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6483.5
Applied egg-rr83.5%
Final simplification85.9%
(FPCore (l Om kx ky)
:precision binary64
(let* ((t_0 (/ (* l (* (/ l Om) 4.0)) Om)))
(if (<= (/ (* 2.0 l) Om) 50000000000000.0)
(sqrt (+ 0.5 (/ 0.5 (sqrt (fma t_0 (fma -0.5 (cos (- ky)) 0.5) 1.0)))))
(sqrt (+ 0.5 (/ 0.5 (sqrt (fma t_0 (+ (+ 0.5 -0.5) (* ky ky)) 1.0))))))))
double code(double l, double Om, double kx, double ky) {
double t_0 = (l * ((l / Om) * 4.0)) / Om;
double tmp;
if (((2.0 * l) / Om) <= 50000000000000.0) {
tmp = sqrt((0.5 + (0.5 / sqrt(fma(t_0, fma(-0.5, cos(-ky), 0.5), 1.0)))));
} else {
tmp = sqrt((0.5 + (0.5 / sqrt(fma(t_0, ((0.5 + -0.5) + (ky * ky)), 1.0)))));
}
return tmp;
}
function code(l, Om, kx, ky) t_0 = Float64(Float64(l * Float64(Float64(l / Om) * 4.0)) / Om) tmp = 0.0 if (Float64(Float64(2.0 * l) / Om) <= 50000000000000.0) tmp = sqrt(Float64(0.5 + Float64(0.5 / sqrt(fma(t_0, fma(-0.5, cos(Float64(-ky)), 0.5), 1.0))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / sqrt(fma(t_0, Float64(Float64(0.5 + -0.5) + Float64(ky * ky)), 1.0))))); end return tmp end
code[l_, Om_, kx_, ky_] := Block[{t$95$0 = N[(N[(l * N[(N[(l / Om), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision]}, If[LessEqual[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 50000000000000.0], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[N[(t$95$0 * N[(-0.5 * N[Cos[(-ky)], $MachinePrecision] + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[N[(t$95$0 * N[(N[(0.5 + -0.5), $MachinePrecision] + N[(ky * ky), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\ell \cdot \left(\frac{\ell}{Om} \cdot 4\right)}{Om}\\
\mathbf{if}\;\frac{2 \cdot \ell}{Om} \leq 50000000000000:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{\mathsf{fma}\left(t\_0, \mathsf{fma}\left(-0.5, \cos \left(-ky\right), 0.5\right), 1\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\sqrt{\mathsf{fma}\left(t\_0, \left(0.5 + -0.5\right) + ky \cdot ky, 1\right)}}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 #s(literal 2 binary64) l) Om) < 5e13Initial program 99.5%
Applied egg-rr80.5%
Taylor expanded in kx around 0
+-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
cos-negN/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6475.5
Simplified75.5%
Taylor expanded in ky around -inf
mul-1-negN/A
lower-neg.f6475.3
Simplified75.3%
associate-*r*N/A
times-fracN/A
associate-*r/N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6486.4
Applied egg-rr86.4%
if 5e13 < (/.f64 (*.f64 #s(literal 2 binary64) l) Om) Initial program 100.0%
Applied egg-rr73.5%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6485.8
Simplified85.8%
Taylor expanded in kx around 0
Simplified76.1%
associate-*r*N/A
times-fracN/A
associate-*r/N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6483.5
Applied egg-rr83.5%
Final simplification85.7%
(FPCore (l Om kx ky) :precision binary64 1.0)
double code(double l, double Om, double kx, double ky) {
return 1.0;
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = 1.0d0
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0;
}
def code(l, Om, kx, ky): return 1.0
function code(l, Om, kx, ky) return 1.0 end
function tmp = code(l, Om, kx, ky) tmp = 1.0; end
code[l_, Om_, kx_, ky_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.6%
Taylor expanded in l around 0
Simplified59.3%
metadata-eval59.3
Applied egg-rr59.3%
herbie shell --seed 2024214
(FPCore (l Om kx ky)
:name "Toniolo and Linder, Equation (3a)"
:precision binary64
(sqrt (* (/ 1.0 2.0) (+ 1.0 (/ 1.0 (sqrt (+ 1.0 (* (pow (/ (* 2.0 l) Om) 2.0) (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))