
(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 6 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
(/ 1.0 (hypot 1.0 (* (hypot (sin ky) (sin kx)) (* 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(ky), sin(kx)) * (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(ky), Math.sin(kx)) * (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(ky), math.sin(kx)) * (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(ky), sin(kx)) * 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(ky), sin(kx)) * (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[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $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 ky, \sin kx\right) \cdot \left(\ell \cdot \frac{2}{Om}\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.7%
unpow299.7%
unpow299.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def100.0%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 6e+71) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* ky l) Om)))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) (* l (/ 2.0 Om)))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 6e+71) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((ky * l) / Om))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (l * (2.0 / Om)))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 6e+71) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((ky * l) / Om))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) * (l * (2.0 / Om)))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if ky <= 6e+71: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((ky * l) / Om)))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) * (l * (2.0 / Om))))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (ky <= 6e+71) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(ky * l) / Om)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * Float64(l * Float64(2.0 / Om))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (ky <= 6e+71) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((ky * l) / Om)))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * (l * (2.0 / Om))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 6e+71], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(ky * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 6 \cdot 10^{+71}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{ky \cdot \ell}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}\\
\end{array}
\end{array}
if ky < 6.00000000000000025e71Initial 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 kx around 0 77.1%
associate-*r/77.1%
*-commutative77.1%
associate-*r*77.1%
unpow277.1%
unpow277.1%
Simplified77.1%
add-sqr-sqrt77.1%
hypot-1-def77.1%
sqrt-div77.1%
*-commutative77.1%
sqrt-prod78.4%
sqrt-prod39.3%
add-sqr-sqrt84.9%
*-commutative84.9%
sqrt-prod84.9%
unpow284.9%
sqrt-prod43.2%
add-sqr-sqrt91.4%
metadata-eval91.4%
sqrt-prod49.4%
add-sqr-sqrt93.2%
Applied egg-rr93.2%
*-un-lft-identity93.2%
associate-*l/93.2%
metadata-eval93.2%
associate-/l*93.2%
Applied egg-rr93.2%
*-lft-identity93.2%
associate-/r/93.2%
*-commutative93.2%
Simplified93.2%
Taylor expanded in ky around 0 87.9%
if 6.00000000000000025e71 < ky Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def100.0%
unpow2100.0%
unpow2100.0%
+-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in ky around 0 90.0%
*-un-lft-identity90.0%
associate-*l/90.0%
metadata-eval90.0%
Applied egg-rr90.0%
*-lft-identity90.0%
Simplified90.0%
Final simplification88.3%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ l Om) (* (sin ky) 2.0)))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (sin(ky) * 2.0))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((l / Om) * (Math.sin(ky) * 2.0))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((l / Om) * (math.sin(ky) * 2.0))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(l / Om) * Float64(sin(ky) * 2.0)))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((l / Om) * (sin(ky) * 2.0)))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(l / Om), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\ell}{Om} \cdot \left(\sin ky \cdot 2\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%
Taylor expanded in kx around 0 79.0%
associate-*r/79.0%
*-commutative79.0%
associate-*r*79.0%
unpow279.0%
unpow279.0%
Simplified79.0%
add-sqr-sqrt79.0%
hypot-1-def79.0%
sqrt-div79.0%
*-commutative79.0%
sqrt-prod80.1%
sqrt-prod41.0%
add-sqr-sqrt87.1%
*-commutative87.1%
sqrt-prod87.1%
unpow287.1%
sqrt-prod46.6%
add-sqr-sqrt92.4%
metadata-eval92.4%
sqrt-prod49.1%
add-sqr-sqrt94.5%
Applied egg-rr94.5%
*-un-lft-identity94.5%
associate-*l/94.5%
metadata-eval94.5%
associate-/l*94.5%
Applied egg-rr94.5%
*-lft-identity94.5%
associate-/r/94.5%
*-commutative94.5%
Simplified94.5%
Final simplification94.5%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 4000000000000.0) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* ky l) Om)))))) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 4000000000000.0) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((ky * l) / Om))))));
} else {
tmp = 1.0;
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 4000000000000.0) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((ky * l) / Om))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 4000000000000.0: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((ky * l) / Om)))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 4000000000000.0) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(ky * l) / Om)))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 4000000000000.0) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((ky * l) / Om)))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 4000000000000.0], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(ky * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 4000000000000:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{ky \cdot \ell}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 4e12Initial program 98.9%
distribute-rgt-in98.9%
metadata-eval98.9%
metadata-eval98.9%
associate-/l*98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in kx around 0 79.2%
associate-*r/79.2%
*-commutative79.2%
associate-*r*79.2%
unpow279.2%
unpow279.2%
Simplified79.2%
add-sqr-sqrt79.2%
hypot-1-def79.2%
sqrt-div79.2%
*-commutative79.2%
sqrt-prod80.7%
sqrt-prod41.4%
add-sqr-sqrt84.4%
*-commutative84.4%
sqrt-prod84.4%
unpow284.4%
sqrt-prod47.1%
add-sqr-sqrt91.5%
metadata-eval91.5%
sqrt-prod32.2%
add-sqr-sqrt94.0%
Applied egg-rr94.0%
*-un-lft-identity94.0%
associate-*l/94.0%
metadata-eval94.0%
associate-/l*94.0%
Applied egg-rr94.0%
*-lft-identity94.0%
associate-/r/94.0%
*-commutative94.0%
Simplified94.0%
Taylor expanded in ky around 0 87.9%
if 4e12 < Om Initial 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 kx around 0 78.6%
associate-*r/78.6%
*-commutative78.6%
associate-*r*78.6%
unpow278.6%
unpow278.6%
Simplified78.6%
add-sqr-sqrt78.6%
hypot-1-def78.6%
sqrt-div78.6%
*-commutative78.6%
sqrt-prod78.6%
sqrt-prod40.0%
add-sqr-sqrt94.8%
*-commutative94.8%
sqrt-prod94.8%
unpow294.8%
sqrt-prod45.1%
add-sqr-sqrt94.8%
metadata-eval94.8%
sqrt-prod95.9%
add-sqr-sqrt95.9%
Applied egg-rr95.9%
*-un-lft-identity95.9%
associate-*l/95.9%
metadata-eval95.9%
associate-/l*95.9%
Applied egg-rr95.9%
*-lft-identity95.9%
associate-/r/95.9%
*-commutative95.9%
Simplified95.9%
Taylor expanded in l around 0 85.9%
Final simplification87.4%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 1.2e-155) (sqrt 0.5) (if (<= Om 1.15e-69) 1.0 (if (<= Om 7e-40) (sqrt 0.5) 1.0))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 1.2e-155) {
tmp = sqrt(0.5);
} else if (Om <= 1.15e-69) {
tmp = 1.0;
} else if (Om <= 7e-40) {
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 <= 1.2d-155) then
tmp = sqrt(0.5d0)
else if (om <= 1.15d-69) then
tmp = 1.0d0
else if (om <= 7d-40) 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 <= 1.2e-155) {
tmp = Math.sqrt(0.5);
} else if (Om <= 1.15e-69) {
tmp = 1.0;
} else if (Om <= 7e-40) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 1.2e-155: tmp = math.sqrt(0.5) elif Om <= 1.15e-69: tmp = 1.0 elif Om <= 7e-40: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 1.2e-155) tmp = sqrt(0.5); elseif (Om <= 1.15e-69) tmp = 1.0; elseif (Om <= 7e-40) 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 <= 1.2e-155) tmp = sqrt(0.5); elseif (Om <= 1.15e-69) tmp = 1.0; elseif (Om <= 7e-40) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 1.2e-155], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[Om, 1.15e-69], 1.0, If[LessEqual[Om, 7e-40], N[Sqrt[0.5], $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 1.2 \cdot 10^{-155}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;Om \leq 1.15 \cdot 10^{-69}:\\
\;\;\;\;1\\
\mathbf{elif}\;Om \leq 7 \cdot 10^{-40}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 1.2e-155 or 1.15e-69 < Om < 7.0000000000000003e-40Initial program 98.7%
distribute-rgt-in98.7%
metadata-eval98.7%
metadata-eval98.7%
associate-/l*98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in Om around 0 56.9%
*-commutative56.9%
associate-*r*56.9%
unpow256.9%
unpow256.9%
hypot-def57.6%
associate-*l/57.6%
associate-*r/57.6%
Simplified57.6%
Taylor expanded in l around inf 64.8%
if 1.2e-155 < Om < 1.15e-69 or 7.0000000000000003e-40 < Om Initial program 98.9%
distribute-rgt-in98.9%
metadata-eval98.9%
metadata-eval98.9%
associate-/l*98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in kx around 0 82.4%
associate-*r/82.4%
*-commutative82.4%
associate-*r*82.4%
unpow282.4%
unpow282.4%
Simplified82.4%
add-sqr-sqrt82.4%
hypot-1-def82.4%
sqrt-div82.4%
*-commutative82.4%
sqrt-prod82.4%
sqrt-prod39.6%
add-sqr-sqrt94.5%
*-commutative94.5%
sqrt-prod94.5%
unpow294.5%
sqrt-prod46.9%
add-sqr-sqrt95.6%
metadata-eval95.6%
sqrt-prod96.5%
add-sqr-sqrt96.5%
Applied egg-rr96.5%
*-un-lft-identity96.5%
associate-*l/96.5%
metadata-eval96.5%
associate-/l*96.5%
Applied egg-rr96.5%
*-lft-identity96.5%
associate-/r/96.5%
*-commutative96.5%
Simplified96.5%
Taylor expanded in l around 0 83.8%
Final simplification71.8%
(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.8%
distribute-rgt-in98.8%
metadata-eval98.8%
metadata-eval98.8%
associate-/l*98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in kx around 0 79.0%
associate-*r/79.0%
*-commutative79.0%
associate-*r*79.0%
unpow279.0%
unpow279.0%
Simplified79.0%
add-sqr-sqrt79.0%
hypot-1-def79.0%
sqrt-div79.0%
*-commutative79.0%
sqrt-prod80.1%
sqrt-prod41.0%
add-sqr-sqrt87.1%
*-commutative87.1%
sqrt-prod87.1%
unpow287.1%
sqrt-prod46.6%
add-sqr-sqrt92.4%
metadata-eval92.4%
sqrt-prod49.1%
add-sqr-sqrt94.5%
Applied egg-rr94.5%
*-un-lft-identity94.5%
associate-*l/94.5%
metadata-eval94.5%
associate-/l*94.5%
Applied egg-rr94.5%
*-lft-identity94.5%
associate-/r/94.5%
*-commutative94.5%
Simplified94.5%
Taylor expanded in l around 0 64.8%
Final simplification64.8%
herbie shell --seed 2023229
(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))))))))))