
(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
(log
(exp
(/ 1.0 (hypot 1.0 (* l (* (/ 2.0 Om) (hypot (sin kx) (sin ky))))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * log(exp((1.0 / hypot(1.0, (l * ((2.0 / Om) * hypot(sin(kx), sin(ky)))))))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * Math.log(Math.exp((1.0 / Math.hypot(1.0, (l * ((2.0 / Om) * Math.hypot(Math.sin(kx), Math.sin(ky)))))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * math.log(math.exp((1.0 / math.hypot(1.0, (l * ((2.0 / Om) * math.hypot(math.sin(kx), math.sin(ky)))))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * log(exp(Float64(1.0 / hypot(1.0, Float64(l * Float64(Float64(2.0 / Om) * hypot(sin(kx), sin(ky))))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * log(exp((1.0 / hypot(1.0, (l * ((2.0 / Om) * hypot(sin(kx), sin(ky))))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[Log[N[Exp[N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(l * N[(N[(2.0 / Om), $MachinePrecision] * N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \log \left(e^{\frac{1}{\mathsf{hypot}\left(1, \ell \cdot \left(\frac{2}{Om} \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right)}}\right)}
\end{array}
Initial program 98.4%
Simplified98.4%
add-sqr-sqrt98.4%
hypot-1-def98.4%
sqrt-prod98.4%
unpow298.4%
sqrt-prod50.8%
add-sqr-sqrt98.5%
associate-/r/98.5%
*-commutative98.5%
unpow298.5%
unpow298.5%
hypot-def100.0%
Applied egg-rr100.0%
add-log-exp100.0%
associate-*l*100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (hypot 1.0 (* (hypot (sin kx) (sin ky)) (* l (/ 2.0 Om)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (hypot(sin(kx), sin(ky)) * (l * (2.0 / 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.hypot(Math.sin(kx), Math.sin(ky)) * (l * (2.0 / Om))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (math.hypot(math.sin(kx), math.sin(ky)) * (l * (2.0 / Om))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(hypot(sin(kx), sin(ky)) * Float64(l * Float64(2.0 / Om)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (hypot(sin(kx), sin(ky)) * (l * (2.0 / 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[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}
\end{array}
Initial program 98.4%
Simplified98.4%
add-sqr-sqrt98.4%
hypot-1-def98.4%
sqrt-prod98.4%
unpow298.4%
sqrt-prod50.8%
add-sqr-sqrt98.5%
associate-/r/98.5%
*-commutative98.5%
unpow298.5%
unpow298.5%
hypot-def100.0%
Applied egg-rr100.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 75.4%
associate-/l*76.3%
associate-/r/77.1%
unpow277.1%
unpow277.1%
times-frac88.9%
unpow288.9%
Simplified88.9%
expm1-log1p-u88.9%
expm1-udef88.9%
*-commutative88.9%
pow-prod-down93.7%
Applied egg-rr93.7%
expm1-def93.7%
expm1-log1p93.7%
*-commutative93.7%
Simplified93.7%
Final simplification93.7%
(FPCore (l Om kx ky) :precision binary64 (if (<= kx 9e-108) (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* ky (* l (/ 2.0 Om)))))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (* l 2.0) (/ (sin kx) Om))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 9e-108) {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (ky * (l * (2.0 / Om))))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l * 2.0) * (sin(kx) / Om))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 9e-108) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, (ky * (l * (2.0 / Om))))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((l * 2.0) * (Math.sin(kx) / Om))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if kx <= 9e-108: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (ky * (l * (2.0 / Om)))))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((l * 2.0) * (math.sin(kx) / Om)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (kx <= 9e-108) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(ky * Float64(l * Float64(2.0 / Om)))))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(l * 2.0) * Float64(sin(kx) / Om)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (kx <= 9e-108) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (ky * (l * (2.0 / Om)))))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l * 2.0) * (sin(kx) / Om)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[kx, 9e-108], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(ky * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(l * 2.0), $MachinePrecision] * N[(N[Sin[kx], $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 9 \cdot 10^{-108}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \left(\ell \cdot 2\right) \cdot \frac{\sin kx}{Om}\right)}}\\
\end{array}
\end{array}
if kx < 8.99999999999999941e-108Initial program 97.6%
Simplified97.6%
add-sqr-sqrt97.6%
hypot-1-def97.6%
sqrt-prod97.6%
unpow297.6%
sqrt-prod50.6%
add-sqr-sqrt97.7%
associate-/r/97.7%
*-commutative97.7%
unpow297.7%
unpow297.7%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 96.3%
Taylor expanded in ky around 0 89.2%
if 8.99999999999999941e-108 < kx Initial program 100.0%
Simplified100.0%
Taylor expanded in ky around 0 83.7%
associate-/l*84.9%
associate-/r/84.9%
associate-*l*84.9%
*-commutative84.9%
unpow284.9%
unpow284.9%
times-frac100.0%
metadata-eval100.0%
swap-sqr100.0%
associate-*l/100.0%
associate-*r/100.0%
associate-*l/100.0%
associate-*r/100.0%
unpow2100.0%
swap-sqr100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
expm1-log1p-u99.3%
expm1-udef99.3%
associate-*l/99.3%
metadata-eval99.3%
associate-*l/99.3%
*-un-lft-identity99.3%
times-frac99.3%
metadata-eval99.3%
Applied egg-rr99.3%
expm1-def99.3%
expm1-log1p100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification92.8%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin ky) (* l (/ 2.0 Om))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, (sin(ky) * (l * (2.0 / Om)))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(ky) * (l * (2.0 / Om)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(ky) * (l * (2.0 / Om)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(ky) * Float64(l * Float64(2.0 / Om))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(ky) * (l * (2.0 / Om))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[ky], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}
\end{array}
Initial program 98.4%
Simplified98.4%
add-sqr-sqrt98.4%
hypot-1-def98.4%
sqrt-prod98.4%
unpow298.4%
sqrt-prod50.8%
add-sqr-sqrt98.5%
associate-/r/98.5%
*-commutative98.5%
unpow298.5%
unpow298.5%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 93.7%
expm1-log1p-u93.0%
expm1-udef93.0%
associate-*l/93.0%
metadata-eval93.0%
associate-*l*93.0%
Applied egg-rr93.0%
expm1-def93.0%
expm1-log1p93.7%
associate-*r*93.7%
Simplified93.7%
Final simplification93.7%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 3.5e-171) 1.0 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* ky (* l (/ 2.0 Om))))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 3.5e-171) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (ky * (l * (2.0 / Om))))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 3.5e-171) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, (ky * (l * (2.0 / Om))))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 3.5e-171: tmp = 1.0 else: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (ky * (l * (2.0 / Om)))))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 3.5e-171) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(ky * Float64(l * Float64(2.0 / Om)))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 3.5e-171) tmp = 1.0; else tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (ky * (l * (2.0 / Om)))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 3.5e-171], 1.0, N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(ky * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 3.5 \cdot 10^{-171}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\\
\end{array}
\end{array}
if l < 3.49999999999999994e-171Initial program 99.3%
Simplified99.3%
Taylor expanded in ky around 0 75.7%
associate-/l*75.7%
associate-/r/75.7%
associate-*l*75.7%
*-commutative75.7%
unpow275.7%
unpow275.7%
times-frac89.3%
metadata-eval89.3%
swap-sqr89.3%
associate-*l/89.3%
associate-*r/89.3%
associate-*l/89.3%
associate-*r/89.3%
unpow289.3%
swap-sqr94.5%
*-commutative94.5%
*-commutative94.5%
Simplified94.5%
expm1-log1p-u94.0%
expm1-udef94.0%
associate-*l/94.0%
metadata-eval94.0%
associate-*l/94.0%
*-un-lft-identity94.0%
times-frac94.0%
metadata-eval94.0%
Applied egg-rr94.0%
expm1-def94.0%
expm1-log1p94.5%
associate-*r*94.5%
*-commutative94.5%
Simplified94.5%
Taylor expanded in l around 0 68.1%
if 3.49999999999999994e-171 < l Initial program 97.3%
Simplified97.3%
add-sqr-sqrt97.3%
hypot-1-def97.3%
sqrt-prod97.3%
unpow297.3%
sqrt-prod40.2%
add-sqr-sqrt97.5%
associate-/r/97.5%
*-commutative97.5%
unpow297.5%
unpow297.5%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 94.4%
Taylor expanded in ky around 0 86.8%
Final simplification76.3%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 5e-24) (sqrt 0.5) (if (<= Om 2.05e+36) 1.0 (if (<= Om 5.2e+80) (sqrt 0.5) 1.0))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 5e-24) {
tmp = sqrt(0.5);
} else if (Om <= 2.05e+36) {
tmp = 1.0;
} else if (Om <= 5.2e+80) {
tmp = sqrt(0.5);
} else {
tmp = 1.0;
}
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 <= 5d-24) then
tmp = sqrt(0.5d0)
else if (om <= 2.05d+36) then
tmp = 1.0d0
else if (om <= 5.2d+80) then
tmp = sqrt(0.5d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 5e-24) {
tmp = Math.sqrt(0.5);
} else if (Om <= 2.05e+36) {
tmp = 1.0;
} else if (Om <= 5.2e+80) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 5e-24: tmp = math.sqrt(0.5) elif Om <= 2.05e+36: tmp = 1.0 elif Om <= 5.2e+80: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 5e-24) tmp = sqrt(0.5); elseif (Om <= 2.05e+36) tmp = 1.0; elseif (Om <= 5.2e+80) tmp = sqrt(0.5); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 5e-24) tmp = sqrt(0.5); elseif (Om <= 2.05e+36) tmp = 1.0; elseif (Om <= 5.2e+80) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 5e-24], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 2.05e+36], 1.0, If[LessEqual[Om, 5.2e+80], N[Sqrt[0.5], $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 5 \cdot 10^{-24}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 2.05 \cdot 10^{+36}:\\
\;\;\;\;1\\
\mathbf{elif}\;Om \leq 5.2 \cdot 10^{+80}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 4.9999999999999998e-24 or 2.05000000000000006e36 < Om < 5.19999999999999963e80Initial program 98.1%
Simplified98.1%
Taylor expanded in ky around 0 68.5%
associate-/l*69.7%
associate-/r/69.5%
associate-*l*69.5%
*-commutative69.5%
unpow269.5%
unpow269.5%
times-frac81.2%
metadata-eval81.2%
swap-sqr81.2%
associate-*l/81.2%
associate-*r/81.2%
associate-*l/81.2%
associate-*r/81.2%
unpow281.2%
swap-sqr90.1%
*-commutative90.1%
*-commutative90.1%
Simplified90.1%
Taylor expanded in l around inf 67.0%
if 4.9999999999999998e-24 < Om < 2.05000000000000006e36 or 5.19999999999999963e80 < Om Initial program 100.0%
Simplified100.0%
Taylor expanded in ky around 0 78.7%
associate-/l*78.7%
associate-/r/78.7%
associate-*l*78.7%
*-commutative78.7%
unpow278.7%
unpow278.7%
times-frac96.7%
metadata-eval96.7%
swap-sqr96.7%
associate-*l/96.7%
associate-*r/96.7%
associate-*l/96.7%
associate-*r/96.7%
unpow296.7%
swap-sqr97.2%
*-commutative97.2%
*-commutative97.2%
Simplified97.2%
expm1-log1p-u96.9%
expm1-udef96.9%
associate-*l/96.9%
metadata-eval96.9%
associate-*l/96.9%
*-un-lft-identity96.9%
times-frac96.9%
metadata-eval96.9%
Applied egg-rr96.9%
expm1-def96.9%
expm1-log1p97.2%
associate-*r*97.2%
*-commutative97.2%
Simplified97.2%
Taylor expanded in l around 0 84.7%
Final simplification70.2%
(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 ky around 0 70.4%
associate-/l*71.3%
associate-/r/71.2%
associate-*l*71.2%
*-commutative71.2%
unpow271.2%
unpow271.2%
times-frac84.1%
metadata-eval84.1%
swap-sqr84.1%
associate-*l/84.1%
associate-*r/84.1%
associate-*l/84.1%
associate-*r/84.1%
unpow284.1%
swap-sqr91.4%
*-commutative91.4%
*-commutative91.4%
Simplified91.4%
expm1-log1p-u90.8%
expm1-udef90.8%
associate-*l/90.8%
metadata-eval90.8%
associate-*l/90.8%
*-un-lft-identity90.8%
times-frac90.8%
metadata-eval90.8%
Applied egg-rr90.8%
expm1-def90.8%
expm1-log1p91.4%
associate-*r*91.4%
*-commutative91.4%
Simplified91.4%
Taylor expanded in l around 0 57.3%
Final simplification57.3%
herbie shell --seed 2023331
(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))))))))))