
(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 8 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 (hypot 1.0 (* (/ 2.0 (/ Om l)) (hypot (sin ky) (sin kx))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / (Om / l)) * hypot(sin(ky), sin(kx)))))));
}
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 / (Om / l)) * Math.hypot(Math.sin(ky), Math.sin(kx)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 / (Om / l)) * math.hypot(math.sin(ky), math.sin(kx)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 / Float64(Om / l)) * hypot(sin(ky), sin(kx))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / (Om / l)) * hypot(sin(ky), sin(kx))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / N[(Om / l), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{\frac{Om}{\ell}} \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right)\right)}}
\end{array}
Initial program 98.4%
Simplified98.4%
add-sqr-sqrt98.4%
hypot-1-def98.4%
sqrt-prod98.4%
sqrt-pow199.0%
metadata-eval99.0%
div-inv99.0%
pow199.0%
clear-num99.0%
unpow299.0%
unpow299.0%
hypot-def100.0%
Applied egg-rr100.0%
expm1-log1p-u99.3%
expm1-udef99.3%
associate-*l/99.3%
metadata-eval99.3%
*-commutative99.3%
associate-*r/99.3%
Applied egg-rr99.3%
expm1-def99.3%
expm1-log1p100.0%
*-commutative100.0%
associate-/l*100.0%
hypot-def99.0%
unpow299.0%
unpow299.0%
+-commutative99.0%
unpow299.0%
unpow299.0%
hypot-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (sqrt (+ 1.0 (* 4.0 (pow (* (sin ky) (/ l Om)) 2.0)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * pow((sin(ky) * (l / Om)), 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((0.5d0 + (0.5d0 * (1.0d0 / sqrt((1.0d0 + (4.0d0 * ((sin(ky) * (l / om)) ** 2.0d0))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + (4.0 * Math.pow((Math.sin(ky) * (l / Om)), 2.0))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + (4.0 * math.pow((math.sin(ky) * (l / Om)), 2.0))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(4.0 * (Float64(sin(ky) * Float64(l / Om)) ^ 2.0)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * ((sin(ky) * (l / Om)) ^ 2.0)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(4.0 * N[Power[N[(N[Sin[ky], $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + 4 \cdot {\left(\sin ky \cdot \frac{\ell}{Om}\right)}^{2}}}}
\end{array}
Initial program 98.4%
Simplified98.4%
Taylor expanded in kx around 0 80.5%
associate-/l*80.7%
associate-/r/81.4%
unpow281.4%
unpow281.4%
times-frac89.9%
unpow289.9%
Simplified89.9%
pow-prod-down93.8%
Applied egg-rr93.8%
Final simplification93.8%
(FPCore (l Om kx ky) :precision binary64 (cbrt (pow (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin ky) (* 2.0 (/ l Om)))))) 1.5)))
double code(double l, double Om, double kx, double ky) {
return cbrt(pow((0.5 + (0.5 / hypot(1.0, (sin(ky) * (2.0 * (l / Om)))))), 1.5));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.cbrt(Math.pow((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(ky) * (2.0 * (l / Om)))))), 1.5));
}
function code(l, Om, kx, ky) return cbrt((Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(ky) * Float64(2.0 * Float64(l / Om)))))) ^ 1.5)) end
code[l_, Om_, kx_, ky_] := N[Power[N[Power[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[ky], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{{\left(0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin ky \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}\right)}^{1.5}}
\end{array}
Initial program 98.4%
Simplified98.4%
Taylor expanded in kx around 0 80.5%
associate-/l*80.7%
associate-/r/81.4%
unpow281.4%
unpow281.4%
times-frac89.9%
unpow289.9%
Simplified89.9%
add-sqr-sqrt89.9%
hypot-1-def89.9%
associate-*r*89.9%
sqrt-prod89.9%
metadata-eval89.9%
unpow289.9%
swap-sqr89.9%
sqrt-unprod49.7%
add-sqr-sqrt90.9%
associate-*r/90.9%
unpow290.9%
sqrt-prod42.5%
add-sqr-sqrt93.8%
Applied egg-rr93.8%
add-cbrt-cube93.8%
pow1/393.8%
Applied egg-rr93.8%
unpow1/393.8%
Simplified93.8%
Final simplification93.8%
(FPCore (l Om kx ky) :precision binary64 (if (<= kx 5e-70) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (/ (* 2.0 l) (/ Om ky)))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (/ (* 2.0 (* l (sin kx))) Om)))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 5e-70) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * l) / (Om / ky))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * (l * sin(kx))) / Om)))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 5e-70) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 * l) / (Om / ky))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 * (l * Math.sin(kx))) / Om)))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if kx <= 5e-70: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 * l) / (Om / ky)))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 * (l * math.sin(kx))) / Om))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (kx <= 5e-70) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 * l) / Float64(Om / ky)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 * Float64(l * sin(kx))) / Om))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (kx <= 5e-70) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * l) / (Om / ky)))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * (l * sin(kx))) / Om))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[kx, 5e-70], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * l), $MachinePrecision] / N[(Om / ky), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l * N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 5 \cdot 10^{-70}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2 \cdot \ell}{\frac{Om}{ky}}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2 \cdot \left(\ell \cdot \sin kx\right)}{Om}\right)}}\\
\end{array}
\end{array}
if kx < 4.9999999999999998e-70Initial program 97.6%
Simplified97.6%
Taylor expanded in kx around 0 85.1%
associate-/l*84.2%
associate-/r/85.3%
unpow285.3%
unpow285.3%
times-frac91.3%
unpow291.3%
Simplified91.3%
add-sqr-sqrt91.3%
hypot-1-def91.3%
associate-*r*91.3%
sqrt-prod91.3%
metadata-eval91.3%
unpow291.3%
swap-sqr91.3%
sqrt-unprod51.3%
add-sqr-sqrt92.3%
associate-*r/92.3%
unpow292.3%
sqrt-prod44.3%
add-sqr-sqrt94.4%
Applied egg-rr94.4%
Taylor expanded in ky around 0 86.6%
*-commutative86.6%
Simplified86.6%
expm1-log1p-u86.0%
expm1-udef86.0%
associate-*l/86.0%
metadata-eval86.0%
associate-/l*86.0%
Applied egg-rr86.0%
expm1-def86.0%
expm1-log1p86.6%
associate-*r/86.6%
Simplified86.6%
if 4.9999999999999998e-70 < kx Initial program 100.0%
Simplified100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
sqrt-pow1100.0%
metadata-eval100.0%
div-inv100.0%
pow1100.0%
clear-num100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Applied egg-rr100.0%
expm1-log1p-u99.3%
expm1-udef99.3%
associate-*l/99.3%
metadata-eval99.3%
*-commutative99.3%
associate-*r/99.3%
Applied egg-rr99.3%
expm1-def99.3%
expm1-log1p100.0%
*-commutative100.0%
associate-/l*100.0%
hypot-def100.0%
unpow2100.0%
unpow2100.0%
+-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Simplified100.0%
Taylor expanded in ky around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Final simplification91.1%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* (sin ky) (/ (* 2.0 l) Om))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (sin(ky) * ((2.0 * l) / Om)))))));
}
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, (Math.sin(ky) * ((2.0 * l) / Om)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (math.sin(ky) * ((2.0 * l) / Om)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(sin(ky) * Float64(Float64(2.0 * l) / Om))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (sin(ky) * ((2.0 * l) / Om))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[ky], $MachinePrecision] * N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \sin ky \cdot \frac{2 \cdot \ell}{Om}\right)}}
\end{array}
Initial program 98.4%
Simplified98.4%
Taylor expanded in kx around 0 80.5%
associate-/l*80.7%
associate-/r/81.4%
unpow281.4%
unpow281.4%
times-frac89.9%
unpow289.9%
Simplified89.9%
add-sqr-sqrt89.9%
hypot-1-def89.9%
associate-*r*89.9%
sqrt-prod89.9%
metadata-eval89.9%
unpow289.9%
swap-sqr89.9%
sqrt-unprod49.7%
add-sqr-sqrt90.9%
associate-*r/90.9%
unpow290.9%
sqrt-prod42.5%
add-sqr-sqrt93.8%
Applied egg-rr93.8%
Final simplification93.8%
(FPCore (l Om kx ky) :precision binary64 (if (<= (* 2.0 l) 5e-14) 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (/ (* 2.0 l) (/ Om ky))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if ((2.0 * l) <= 5e-14) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * l) / (Om / ky))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if ((2.0 * l) <= 5e-14) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 * l) / (Om / ky))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if (2.0 * l) <= 5e-14: tmp = 1.0 else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 * l) / (Om / ky)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Float64(2.0 * l) <= 5e-14) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 * l) / Float64(Om / ky)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if ((2.0 * l) <= 5e-14) tmp = 1.0; else tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * l) / (Om / ky)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[N[(2.0 * l), $MachinePrecision], 5e-14], 1.0, N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * l), $MachinePrecision] / N[(Om / ky), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot \ell \leq 5 \cdot 10^{-14}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2 \cdot \ell}{\frac{Om}{ky}}\right)}}\\
\end{array}
\end{array}
if (*.f64 2 l) < 5.0000000000000002e-14Initial program 98.9%
Simplified98.9%
Taylor expanded in kx around 0 83.9%
associate-/l*84.1%
associate-/r/85.2%
unpow285.2%
unpow285.2%
times-frac91.3%
unpow291.3%
Simplified91.3%
add-sqr-sqrt91.3%
hypot-1-def91.3%
associate-*r*91.3%
sqrt-prod91.3%
metadata-eval91.3%
unpow291.3%
swap-sqr91.3%
sqrt-unprod52.2%
add-sqr-sqrt92.2%
associate-*r/92.2%
unpow292.2%
sqrt-prod39.8%
add-sqr-sqrt94.7%
Applied egg-rr94.7%
add-cbrt-cube94.7%
pow1/394.7%
Applied egg-rr94.7%
unpow1/394.7%
Simplified94.7%
Taylor expanded in ky around 0 69.1%
if 5.0000000000000002e-14 < (*.f64 2 l) Initial program 97.0%
Simplified97.0%
Taylor expanded in kx around 0 71.0%
associate-/l*71.0%
associate-/r/70.9%
unpow270.9%
unpow270.9%
times-frac86.3%
unpow286.3%
Simplified86.3%
add-sqr-sqrt86.3%
hypot-1-def86.3%
associate-*r*86.3%
sqrt-prod86.3%
metadata-eval86.3%
unpow286.3%
swap-sqr86.3%
sqrt-unprod42.8%
add-sqr-sqrt87.3%
associate-*r/87.3%
unpow287.3%
sqrt-prod49.8%
add-sqr-sqrt91.4%
Applied egg-rr91.4%
Taylor expanded in ky around 0 84.9%
*-commutative84.9%
Simplified84.9%
expm1-log1p-u84.1%
expm1-udef84.1%
associate-*l/84.1%
metadata-eval84.1%
associate-/l*84.1%
Applied egg-rr84.1%
expm1-def84.1%
expm1-log1p84.9%
associate-*r/84.9%
Simplified84.9%
Final simplification73.3%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 1.16e+106) 1.0 (sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.16e+106) {
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.16d+106) 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.16e+106) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1.16e+106: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1.16e+106) 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.16e+106) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.16e+106], 1.0, N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.16 \cdot 10^{+106}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 1.16000000000000004e106Initial program 99.0%
Simplified99.0%
Taylor expanded in kx around 0 85.4%
associate-/l*85.6%
associate-/r/86.5%
unpow286.5%
unpow286.5%
times-frac91.9%
unpow291.9%
Simplified91.9%
add-sqr-sqrt91.9%
hypot-1-def91.9%
associate-*r*91.9%
sqrt-prod91.9%
metadata-eval91.9%
unpow291.9%
swap-sqr91.9%
sqrt-unprod52.9%
add-sqr-sqrt92.7%
associate-*r/92.7%
unpow292.7%
sqrt-prod41.9%
add-sqr-sqrt94.9%
Applied egg-rr94.9%
add-cbrt-cube94.9%
pow1/394.9%
Applied egg-rr94.9%
unpow1/394.9%
Simplified94.9%
Taylor expanded in ky around 0 70.0%
if 1.16000000000000004e106 < l Initial program 95.4%
Simplified95.4%
Taylor expanded in Om around 0 77.3%
unpow277.3%
unpow277.3%
hypot-def81.8%
Simplified81.8%
Taylor expanded in l around inf 85.0%
Final simplification72.5%
(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 98.4%
Simplified98.4%
Taylor expanded in kx around 0 80.5%
associate-/l*80.7%
associate-/r/81.4%
unpow281.4%
unpow281.4%
times-frac89.9%
unpow289.9%
Simplified89.9%
add-sqr-sqrt89.9%
hypot-1-def89.9%
associate-*r*89.9%
sqrt-prod89.9%
metadata-eval89.9%
unpow289.9%
swap-sqr89.9%
sqrt-unprod49.7%
add-sqr-sqrt90.9%
associate-*r/90.9%
unpow290.9%
sqrt-prod42.5%
add-sqr-sqrt93.8%
Applied egg-rr93.8%
add-cbrt-cube93.8%
pow1/393.8%
Applied egg-rr93.8%
unpow1/393.8%
Simplified93.8%
Taylor expanded in ky around 0 63.9%
Final simplification63.9%
herbie shell --seed 2023325
(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))))))))))