
(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 9 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
(+
0.5
(*
0.5
(pow
(pow (hypot 1.0 (* (* 2.0 (/ l Om)) (hypot (sin kx) (sin ky)))) -0.5)
2.0)))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * pow(pow(hypot(1.0, ((2.0 * (l / Om)) * hypot(sin(kx), sin(ky)))), -0.5), 2.0))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * Math.pow(Math.pow(Math.hypot(1.0, ((2.0 * (l / Om)) * Math.hypot(Math.sin(kx), Math.sin(ky)))), -0.5), 2.0))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * math.pow(math.pow(math.hypot(1.0, ((2.0 * (l / Om)) * math.hypot(math.sin(kx), math.sin(ky)))), -0.5), 2.0))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * ((hypot(1.0, Float64(Float64(2.0 * Float64(l / Om)) * hypot(sin(kx), sin(ky)))) ^ -0.5) ^ 2.0)))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * ((hypot(1.0, ((2.0 * (l / Om)) * hypot(sin(kx), sin(ky)))) ^ -0.5) ^ 2.0)))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[Power[N[Power[N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot {\left({\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)}^{-0.5}\right)}^{2}}
\end{array}
Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
add-sqr-sqrt98.8%
pow298.8%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (l Om kx ky)
:precision binary64
(let* ((t_0 (pow (sin ky) 2.0)))
(if (<= t_0 5e-324)
1.0
(if (<= t_0 2e-33)
(sqrt
(+ 0.5 (* 0.5 (/ 1.0 (sqrt (+ 1.0 (/ (* 12.0 (* l l)) (* Om Om))))))))
(sqrt
(+
0.5
(*
0.5
(/
1.0
(+
1.0
(*
2.0
(*
(- 0.5 (/ (cos (+ ky ky)) 2.0))
(* (/ l Om) (/ l Om)))))))))))))
double code(double l, double Om, double kx, double ky) {
double t_0 = pow(sin(ky), 2.0);
double tmp;
if (t_0 <= 5e-324) {
tmp = 1.0;
} else if (t_0 <= 2e-33) {
tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + ((12.0 * (l * l)) / (Om * Om))))))));
} else {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((0.5 - (cos((ky + ky)) / 2.0)) * ((l / Om) * (l / Om)))))))));
}
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) :: t_0
real(8) :: tmp
t_0 = sin(ky) ** 2.0d0
if (t_0 <= 5d-324) then
tmp = 1.0d0
else if (t_0 <= 2d-33) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / sqrt((1.0d0 + ((12.0d0 * (l * l)) / (om * om))))))))
else
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((0.5d0 - (cos((ky + ky)) / 2.0d0)) * ((l / om) * (l / om)))))))))
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double t_0 = Math.pow(Math.sin(ky), 2.0);
double tmp;
if (t_0 <= 5e-324) {
tmp = 1.0;
} else if (t_0 <= 2e-33) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + ((12.0 * (l * l)) / (Om * Om))))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((0.5 - (Math.cos((ky + ky)) / 2.0)) * ((l / Om) * (l / Om)))))))));
}
return tmp;
}
def code(l, Om, kx, ky): t_0 = math.pow(math.sin(ky), 2.0) tmp = 0 if t_0 <= 5e-324: tmp = 1.0 elif t_0 <= 2e-33: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + ((12.0 * (l * l)) / (Om * Om)))))))) else: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((0.5 - (math.cos((ky + ky)) / 2.0)) * ((l / Om) * (l / Om))))))))) return tmp
function code(l, Om, kx, ky) t_0 = sin(ky) ^ 2.0 tmp = 0.0 if (t_0 <= 5e-324) tmp = 1.0; elseif (t_0 <= 2e-33) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(Float64(12.0 * Float64(l * l)) / Float64(Om * Om)))))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(0.5 - Float64(cos(Float64(ky + ky)) / 2.0)) * Float64(Float64(l / Om) * Float64(l / Om))))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) t_0 = sin(ky) ^ 2.0; tmp = 0.0; if (t_0 <= 5e-324) tmp = 1.0; elseif (t_0 <= 2e-33) tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + ((12.0 * (l * l)) / (Om * Om)))))))); else tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((0.5 - (cos((ky + ky)) / 2.0)) * ((l / Om) * (l / Om))))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := Block[{t$95$0 = N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$0, 5e-324], 1.0, If[LessEqual[t$95$0, 2e-33], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(N[(12.0 * N[(l * l), $MachinePrecision]), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(0.5 - N[(N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(l / Om), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin ky}^{2}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-324}:\\
\;\;\;\;1\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \frac{12 \cdot \left(\ell \cdot \ell\right)}{Om \cdot Om}}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \left(\left(0.5 - \frac{\cos \left(ky + ky\right)}{2}\right) \cdot \left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)\right)}}\\
\end{array}
\end{array}
if (pow.f64 (sin.f64 ky) 2) < 4.94066e-324Initial program 95.0%
distribute-rgt-in95.0%
metadata-eval95.0%
metadata-eval95.0%
associate-/l*95.0%
metadata-eval95.0%
Simplified95.0%
add-sqr-sqrt95.0%
pow295.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 84.0%
expm1-log1p-u84.0%
expm1-udef84.0%
+-commutative84.0%
fma-def84.0%
pow-pow84.0%
metadata-eval84.0%
unpow-184.0%
Applied egg-rr84.0%
expm1-def84.0%
expm1-log1p84.0%
fma-udef84.0%
associate-*l/84.0%
metadata-eval84.0%
associate-*l*84.0%
*-commutative84.0%
Simplified84.0%
Taylor expanded in ky around 0 68.0%
if 4.94066e-324 < (pow.f64 (sin.f64 ky) 2) < 2.0000000000000001e-33Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 90.3%
associate-/l*93.3%
unpow293.3%
unpow293.3%
Simplified93.3%
Taylor expanded in ky around 0 93.3%
fma-def93.3%
unpow293.3%
unpow293.3%
unpow293.3%
Simplified93.3%
Taylor expanded in ky around inf 96.9%
associate-*r/96.9%
unpow296.9%
unpow296.9%
Simplified96.9%
if 2.0000000000000001e-33 < (pow.f64 (sin.f64 ky) 2) Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 85.7%
associate-/l*85.7%
unpow285.7%
unpow285.7%
Simplified85.7%
Taylor expanded in l around 0 85.4%
associate-*l/85.4%
unpow285.4%
unpow285.4%
*-commutative85.4%
times-frac97.9%
Simplified97.9%
unpow297.9%
sin-mult97.0%
Applied egg-rr97.0%
div-sub97.0%
+-inverses97.0%
cos-097.0%
metadata-eval97.0%
Simplified97.0%
Final simplification90.1%
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (hypot 1.0 (* (* 2.0 (/ l Om)) (hypot (sin ky) (sin kx)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l / Om)) * hypot(sin(ky), sin(kx))))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((2.0 * (l / Om)) * Math.hypot(Math.sin(ky), Math.sin(kx))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((2.0 * (l / Om)) * math.hypot(math.sin(ky), math.sin(kx))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(2.0 * Float64(l / Om)) * hypot(sin(ky), sin(kx)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l / Om)) * hypot(sin(ky), sin(kx)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right)\right)}}
\end{array}
Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
expm1-log1p-u98.8%
expm1-udef98.8%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def99.2%
unpow299.2%
unpow299.2%
+-commutative99.2%
unpow299.2%
unpow299.2%
hypot-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (pow (pow (hypot 1.0 (* (* 2.0 (/ l Om)) (sin ky))) -0.5) 2.0)))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * pow(pow(hypot(1.0, ((2.0 * (l / Om)) * sin(ky))), -0.5), 2.0))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * Math.pow(Math.pow(Math.hypot(1.0, ((2.0 * (l / Om)) * Math.sin(ky))), -0.5), 2.0))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * math.pow(math.pow(math.hypot(1.0, ((2.0 * (l / Om)) * math.sin(ky))), -0.5), 2.0))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * ((hypot(1.0, Float64(Float64(2.0 * Float64(l / Om)) * sin(ky))) ^ -0.5) ^ 2.0)))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * ((hypot(1.0, ((2.0 * (l / Om)) * sin(ky))) ^ -0.5) ^ 2.0)))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[Power[N[Power[N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot {\left({\left(\mathsf{hypot}\left(1, \left(2 \cdot \frac{\ell}{Om}\right) \cdot \sin ky\right)\right)}^{-0.5}\right)}^{2}}
\end{array}
Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
add-sqr-sqrt98.8%
pow298.8%
Applied egg-rr100.0%
Taylor expanded in kx around 0 94.2%
Final simplification94.2%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (* (/ l Om) (sin ky))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l / Om) * sin(ky)))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((l / Om) * Math.sin(ky)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((l / Om) * math.sin(ky)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(l / Om) * sin(ky))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((l / Om) * sin(ky))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(l / Om), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \left(\frac{\ell}{Om} \cdot \sin ky\right)\right)}}
\end{array}
Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
add-sqr-sqrt98.8%
pow298.8%
Applied egg-rr100.0%
Taylor expanded in kx around 0 94.2%
expm1-log1p-u94.2%
expm1-udef94.2%
+-commutative94.2%
fma-def94.2%
pow-pow94.2%
metadata-eval94.2%
unpow-194.2%
Applied egg-rr94.2%
expm1-def94.2%
expm1-log1p94.2%
fma-udef94.2%
associate-*l/94.2%
metadata-eval94.2%
associate-*l*94.2%
*-commutative94.2%
Simplified94.2%
Final simplification94.2%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l 5.6e-124)
1.0
(if (<= l 6.2e+152)
(sqrt
(+ 0.5 (* 0.5 (/ 1.0 (sqrt (+ 1.0 (/ (* 12.0 (* l l)) (* Om Om))))))))
(sqrt 0.5))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 5.6e-124) {
tmp = 1.0;
} else if (l <= 6.2e+152) {
tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + ((12.0 * (l * l)) / (Om * Om))))))));
} 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 (l <= 5.6d-124) then
tmp = 1.0d0
else if (l <= 6.2d+152) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / sqrt((1.0d0 + ((12.0d0 * (l * l)) / (om * om))))))))
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 (l <= 5.6e-124) {
tmp = 1.0;
} else if (l <= 6.2e+152) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + ((12.0 * (l * l)) / (Om * Om))))))));
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 5.6e-124: tmp = 1.0 elif l <= 6.2e+152: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + ((12.0 * (l * l)) / (Om * Om)))))))) else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 5.6e-124) tmp = 1.0; elseif (l <= 6.2e+152) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(Float64(12.0 * Float64(l * l)) / Float64(Om * Om)))))))); else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 5.6e-124) tmp = 1.0; elseif (l <= 6.2e+152) tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + ((12.0 * (l * l)) / (Om * Om)))))))); else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 5.6e-124], 1.0, If[LessEqual[l, 6.2e+152], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(N[(12.0 * N[(l * l), $MachinePrecision]), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 5.6 \cdot 10^{-124}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 6.2 \cdot 10^{+152}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + \frac{12 \cdot \left(\ell \cdot \ell\right)}{Om \cdot Om}}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 5.59999999999999996e-124Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
add-sqr-sqrt98.8%
pow298.8%
Applied egg-rr100.0%
Taylor expanded in kx around 0 95.7%
expm1-log1p-u95.7%
expm1-udef95.7%
+-commutative95.7%
fma-def95.7%
pow-pow95.7%
metadata-eval95.7%
unpow-195.7%
Applied egg-rr95.7%
expm1-def95.7%
expm1-log1p95.7%
fma-udef95.7%
associate-*l/95.7%
metadata-eval95.7%
associate-*l*95.7%
*-commutative95.7%
Simplified95.7%
Taylor expanded in ky around 0 72.7%
if 5.59999999999999996e-124 < l < 6.2e152Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 88.3%
associate-/l*88.3%
unpow288.3%
unpow288.3%
Simplified88.3%
Taylor expanded in ky around 0 80.3%
fma-def80.3%
unpow280.3%
unpow280.3%
unpow280.3%
Simplified80.3%
Taylor expanded in ky around inf 95.8%
associate-*r/95.8%
unpow295.8%
unpow295.8%
Simplified95.8%
if 6.2e152 < l Initial program 96.4%
distribute-rgt-in96.4%
metadata-eval96.4%
metadata-eval96.4%
associate-/l*96.4%
metadata-eval96.4%
Simplified96.4%
Taylor expanded in Om around 0 87.6%
*-commutative87.6%
associate-*r*87.6%
associate-*l/87.6%
unpow287.6%
unpow287.6%
hypot-def91.2%
associate-*l/91.2%
*-commutative91.2%
Simplified91.2%
Taylor expanded in l around inf 91.7%
Final simplification80.1%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 3.1e+56) (sqrt 0.5) (+ 1.0 (* -0.5 (/ (* l l) (* (/ Om ky) (/ Om ky)))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 3.1e+56) {
tmp = sqrt(0.5);
} else {
tmp = 1.0 + (-0.5 * ((l * l) / ((Om / ky) * (Om / ky))));
}
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 (om <= 3.1d+56) then
tmp = sqrt(0.5d0)
else
tmp = 1.0d0 + ((-0.5d0) * ((l * l) / ((om / ky) * (om / ky))))
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 3.1e+56) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0 + (-0.5 * ((l * l) / ((Om / ky) * (Om / ky))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 3.1e+56: tmp = math.sqrt(0.5) else: tmp = 1.0 + (-0.5 * ((l * l) / ((Om / ky) * (Om / ky)))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 3.1e+56) tmp = sqrt(0.5); else tmp = Float64(1.0 + Float64(-0.5 * Float64(Float64(l * l) / Float64(Float64(Om / ky) * Float64(Om / ky))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 3.1e+56) tmp = sqrt(0.5); else tmp = 1.0 + (-0.5 * ((l * l) / ((Om / ky) * (Om / ky)))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 3.1e+56], N[Sqrt[0.5], $MachinePrecision], N[(1.0 + N[(-0.5 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om / ky), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 3.1 \cdot 10^{+56}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om}{ky} \cdot \frac{Om}{ky}}\\
\end{array}
\end{array}
if Om < 3.10000000000000005e56Initial program 98.5%
distribute-rgt-in98.5%
metadata-eval98.5%
metadata-eval98.5%
associate-/l*98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in Om around 0 51.3%
*-commutative51.3%
associate-*r*51.3%
associate-*l/51.3%
unpow251.3%
unpow251.3%
hypot-def52.3%
associate-*l/52.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in l around inf 60.3%
if 3.10000000000000005e56 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
add-sqr-sqrt100.0%
pow2100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 97.0%
expm1-log1p-u97.0%
expm1-udef97.0%
+-commutative97.0%
fma-def97.0%
pow-pow97.0%
metadata-eval97.0%
unpow-197.0%
Applied egg-rr97.0%
expm1-def97.0%
expm1-log1p97.0%
fma-udef97.0%
associate-*l/97.0%
metadata-eval97.0%
associate-*l*97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in ky around 0 63.2%
*-commutative63.2%
associate-/l*67.1%
unpow267.1%
unpow267.1%
unpow267.1%
times-frac73.1%
Simplified73.1%
Final simplification62.8%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 1.4e+94) 1.0 (sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.4e+94) {
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 (l <= 1.4d+94) 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 (l <= 1.4e+94) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1.4e+94: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1.4e+94) tmp = 1.0; else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 1.4e+94) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.4e+94], 1.0, N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.4 \cdot 10^{+94}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 1.39999999999999999e94Initial program 99.1%
distribute-rgt-in99.1%
metadata-eval99.1%
metadata-eval99.1%
associate-/l*99.1%
metadata-eval99.1%
Simplified99.1%
add-sqr-sqrt99.1%
pow299.1%
Applied egg-rr100.0%
Taylor expanded in kx around 0 94.2%
expm1-log1p-u94.2%
expm1-udef94.2%
+-commutative94.2%
fma-def94.2%
pow-pow94.2%
metadata-eval94.2%
unpow-194.2%
Applied egg-rr94.2%
expm1-def94.2%
expm1-log1p94.2%
fma-udef94.2%
associate-*l/94.2%
metadata-eval94.2%
associate-*l*94.2%
*-commutative94.2%
Simplified94.2%
Taylor expanded in ky around 0 70.3%
if 1.39999999999999999e94 < l Initial program 97.6%
distribute-rgt-in97.6%
metadata-eval97.6%
metadata-eval97.6%
associate-/l*97.6%
metadata-eval97.6%
Simplified97.6%
Taylor expanded in Om around 0 75.1%
*-commutative75.1%
associate-*r*75.1%
associate-*l/75.1%
unpow275.1%
unpow275.1%
hypot-def77.5%
associate-*l/77.5%
*-commutative77.5%
Simplified77.5%
Taylor expanded in l around inf 80.7%
Final simplification72.0%
(FPCore (l Om kx ky) :precision binary64 (+ 1.0 (* -0.5 (/ (* l l) (* (/ Om ky) (/ Om ky))))))
double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((l * l) / ((Om / ky) * (Om / ky))));
}
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 + ((-0.5d0) * ((l * l) / ((om / ky) * (om / ky))))
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((l * l) / ((Om / ky) * (Om / ky))));
}
def code(l, Om, kx, ky): return 1.0 + (-0.5 * ((l * l) / ((Om / ky) * (Om / ky))))
function code(l, Om, kx, ky) return Float64(1.0 + Float64(-0.5 * Float64(Float64(l * l) / Float64(Float64(Om / ky) * Float64(Om / ky))))) end
function tmp = code(l, Om, kx, ky) tmp = 1.0 + (-0.5 * ((l * l) / ((Om / ky) * (Om / ky)))); end
code[l_, Om_, kx_, ky_] := N[(1.0 + N[(-0.5 * N[(N[(l * l), $MachinePrecision] / N[(N[(Om / ky), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + -0.5 \cdot \frac{\ell \cdot \ell}{\frac{Om}{ky} \cdot \frac{Om}{ky}}
\end{array}
Initial program 98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
add-sqr-sqrt98.8%
pow298.8%
Applied egg-rr100.0%
Taylor expanded in kx around 0 94.2%
expm1-log1p-u94.2%
expm1-udef94.2%
+-commutative94.2%
fma-def94.2%
pow-pow94.2%
metadata-eval94.2%
unpow-194.2%
Applied egg-rr94.2%
expm1-def94.2%
expm1-log1p94.2%
fma-udef94.2%
associate-*l/94.2%
metadata-eval94.2%
associate-*l*94.2%
*-commutative94.2%
Simplified94.2%
Taylor expanded in ky around 0 37.9%
*-commutative37.9%
associate-/l*38.3%
unpow238.3%
unpow238.3%
unpow238.3%
times-frac43.3%
Simplified43.3%
Final simplification43.3%
herbie shell --seed 2023216
(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))))))))))