
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(pow (/ (* 2.0 l) Om) 2.0)
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(*
(/ 1.0 2.0)
(+
1.0
(/
1.0
(sqrt
(+
1.0
(*
(pow (/ (* 2.0 l) Om) 2.0)
(+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + (pow(((2.0 * l) / Om), 2.0) * (pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))))))));
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = sqrt(((1.0d0 / 2.0d0) * (1.0d0 + (1.0d0 / sqrt((1.0d0 + ((((2.0d0 * l) / om) ** 2.0d0) * ((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))))))))
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / Math.sqrt((1.0 + (Math.pow(((2.0 * l) / Om), 2.0) * (Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))))))));
}
def code(l, Om, kx, ky): return math.sqrt(((1.0 / 2.0) * (1.0 + (1.0 / math.sqrt((1.0 + (math.pow(((2.0 * l) / Om), 2.0) * (math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.0 / 2.0) * Float64(1.0 + Float64(1.0 / sqrt(Float64(1.0 + Float64((Float64(Float64(2.0 * l) / Om) ^ 2.0) * Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.0 / 2.0) * (1.0 + (1.0 / sqrt((1.0 + ((((2.0 * l) / Om) ^ 2.0) * ((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.0 / 2.0), $MachinePrecision] * N[(1.0 + N[(1.0 / N[Sqrt[N[(1.0 + N[(N[Power[N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\sqrt{1 + {\left(\frac{2 \cdot \ell}{Om}\right)}^{2} \cdot \left({\sin kx}^{2} + {\sin ky}^{2}\right)}}\right)}
\end{array}
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(+
0.5
(*
0.5
(/ 1.0 (hypot 1.0 (* (hypot (sin kx) (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, (hypot(sin(kx), 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.hypot(Math.sin(kx), 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.hypot(math.sin(kx), 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(hypot(sin(kx), sin(ky)) * Float64(2.0 * Float64(l / 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)) * (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[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(2.0 * N[(l / 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(2 \cdot \frac{\ell}{Om}\right)\right)}}
\end{array}
Initial program 97.3%
Simplified97.3%
expm1-log1p-u97.3%
expm1-udef97.3%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky)
:precision binary64
(let* ((t_0 (/ (* 2.0 l) Om)))
(if (<= t_0 10.0)
(sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) t_0)))))
(sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (* 2.0 l) (/ ky Om)))))))))
double code(double l, double Om, double kx, double ky) {
double t_0 = (2.0 * l) / Om;
double tmp;
if (t_0 <= 10.0) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * t_0)))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * l) * (ky / Om))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double t_0 = (2.0 * l) / Om;
double tmp;
if (t_0 <= 10.0) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) * t_0)))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 * l) * (ky / Om))))));
}
return tmp;
}
def code(l, Om, kx, ky): t_0 = (2.0 * l) / Om tmp = 0 if t_0 <= 10.0: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) * t_0))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 * l) * (ky / Om)))))) return tmp
function code(l, Om, kx, ky) t_0 = Float64(Float64(2.0 * l) / Om) tmp = 0.0 if (t_0 <= 10.0) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * t_0))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 * l) * Float64(ky / Om)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) t_0 = (2.0 * l) / Om; tmp = 0.0; if (t_0 <= 10.0) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * t_0))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * l) * (ky / Om)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := Block[{t$95$0 = N[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision]}, If[LessEqual[t$95$0, 10.0], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * l), $MachinePrecision] * N[(ky / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 \cdot \ell}{Om}\\
\mathbf{if}\;t_0 \leq 10:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot t_0\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \left(2 \cdot \ell\right) \cdot \frac{ky}{Om}\right)}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 2 l) Om) < 10Initial program 98.9%
Simplified98.9%
expm1-log1p-u98.9%
expm1-udef98.9%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in ky around 0 96.1%
expm1-log1p-u96.1%
expm1-udef96.1%
un-div-inv96.1%
Applied egg-rr96.1%
expm1-def96.1%
expm1-log1p96.1%
associate-*r/96.1%
Simplified96.1%
if 10 < (/.f64 (*.f64 2 l) Om) Initial program 92.8%
Simplified92.8%
Taylor expanded in kx around 0 63.4%
associate-*r/63.4%
associate-*r*63.4%
unpow263.4%
unpow263.4%
Simplified63.4%
add-sqr-sqrt63.4%
hypot-1-def63.4%
sqrt-div63.4%
*-commutative63.4%
sqrt-prod64.9%
unpow264.9%
sqrt-prod34.9%
add-sqr-sqrt78.0%
*-commutative78.0%
sqrt-prod78.0%
sqrt-prod37.7%
add-sqr-sqrt86.5%
metadata-eval86.5%
sqrt-prod40.1%
add-sqr-sqrt94.1%
Applied egg-rr94.1%
expm1-log1p-u92.9%
expm1-udef92.8%
un-div-inv92.8%
associate-/l*92.8%
Applied egg-rr92.8%
expm1-def92.9%
expm1-log1p94.1%
associate-/r/94.1%
*-commutative94.1%
Simplified94.1%
Taylor expanded in ky around 0 92.1%
Final simplification95.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ (sin ky) Om) (* 2.0 l)))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, ((sin(ky) / Om) * (2.0 * l))))));
}
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) / Om) * (2.0 * l))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((math.sin(ky) / Om) * (2.0 * l))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(sin(ky) / Om) * Float64(2.0 * l)))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((sin(ky) / Om) * (2.0 * l)))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(N[Sin[ky], $MachinePrecision] / Om), $MachinePrecision] * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{\sin ky}{Om} \cdot \left(2 \cdot \ell\right)\right)}}
\end{array}
Initial program 97.3%
Simplified97.3%
Taylor expanded in kx around 0 77.3%
associate-*r/77.3%
associate-*r*77.3%
unpow277.3%
unpow277.3%
Simplified77.3%
add-sqr-sqrt77.3%
hypot-1-def77.3%
sqrt-div77.3%
*-commutative77.3%
sqrt-prod77.7%
unpow277.7%
sqrt-prod42.2%
add-sqr-sqrt83.5%
*-commutative83.5%
sqrt-prod83.5%
sqrt-prod37.6%
add-sqr-sqrt89.6%
metadata-eval89.6%
sqrt-prod46.3%
add-sqr-sqrt96.0%
Applied egg-rr96.0%
expm1-log1p-u95.3%
expm1-udef95.3%
un-div-inv95.3%
associate-/l*95.3%
Applied egg-rr95.3%
expm1-def95.3%
expm1-log1p96.0%
associate-/r/96.0%
*-commutative96.0%
Simplified96.0%
Final simplification96.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 5.5e+96) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (* 2.0 l) (/ ky Om)))))) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 5.5e+96) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * l) * (ky / Om))))));
} else {
tmp = 1.0;
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 5.5e+96) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 * l) * (ky / Om))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 5.5e+96: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 * l) * (ky / Om)))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 5.5e+96) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 * l) * Float64(ky / Om)))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 5.5e+96) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 * l) * (ky / Om)))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 5.5e+96], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * l), $MachinePrecision] * N[(ky / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 5.5 \cdot 10^{+96}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \left(2 \cdot \ell\right) \cdot \frac{ky}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 5.5000000000000002e96Initial program 96.9%
Simplified96.9%
Taylor expanded in kx around 0 76.5%
associate-*r/76.5%
associate-*r*76.5%
unpow276.5%
unpow276.5%
Simplified76.5%
add-sqr-sqrt76.5%
hypot-1-def76.5%
sqrt-div76.5%
*-commutative76.5%
sqrt-prod77.0%
unpow277.0%
sqrt-prod42.5%
add-sqr-sqrt83.5%
*-commutative83.5%
sqrt-prod83.5%
sqrt-prod35.8%
add-sqr-sqrt88.9%
metadata-eval88.9%
sqrt-prod39.2%
add-sqr-sqrt95.4%
Applied egg-rr95.4%
expm1-log1p-u94.7%
expm1-udef94.7%
un-div-inv94.7%
associate-/l*94.7%
Applied egg-rr94.7%
expm1-def94.7%
expm1-log1p95.4%
associate-/r/95.4%
*-commutative95.4%
Simplified95.4%
Taylor expanded in ky around 0 87.7%
if 5.5000000000000002e96 < Om Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 83.3%
associate-*r/83.3%
associate-*r*83.3%
unpow283.3%
unpow283.3%
Simplified83.3%
add-sqr-sqrt83.3%
hypot-1-def83.3%
sqrt-div83.3%
*-commutative83.3%
sqrt-prod83.3%
unpow283.3%
sqrt-prod40.0%
add-sqr-sqrt83.3%
*-commutative83.3%
sqrt-prod83.3%
sqrt-prod51.3%
add-sqr-sqrt94.7%
metadata-eval94.7%
sqrt-prod100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
expm1-log1p-u99.9%
expm1-udef99.9%
un-div-inv99.9%
associate-/l*99.9%
Applied egg-rr99.9%
expm1-def99.9%
expm1-log1p100.0%
associate-/r/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in ky around 0 94.7%
Final simplification88.5%
(FPCore (l Om kx ky)
:precision binary64
(if (<= l 1.6e-23)
1.0
(if (<= l 1.06e+127)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ 1.0 (* 2.0 (/ (* ky ky) (/ (* Om Om) (* l l)))))))))
(sqrt 0.5))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.6e-23) {
tmp = 1.0;
} else if (l <= 1.06e+127) {
tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l)))))))));
} 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.6d-23) then
tmp = 1.0d0
else if (l <= 1.06d+127) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / (1.0d0 + (2.0d0 * ((ky * ky) / ((om * om) / (l * l)))))))))
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.6e-23) {
tmp = 1.0;
} else if (l <= 1.06e+127) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l)))))))));
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1.6e-23: tmp = 1.0 elif l <= 1.06e+127: tmp = math.sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l))))))))) else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1.6e-23) tmp = 1.0; elseif (l <= 1.06e+127) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(1.0 + Float64(2.0 * Float64(Float64(ky * ky) / Float64(Float64(Om * Om) / Float64(l * l))))))))); else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 1.6e-23) tmp = 1.0; elseif (l <= 1.06e+127) tmp = sqrt((0.5 + (0.5 * (1.0 / (1.0 + (2.0 * ((ky * ky) / ((Om * Om) / (l * l))))))))); else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.6e-23], 1.0, If[LessEqual[l, 1.06e+127], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(1.0 + N[(2.0 * N[(N[(ky * ky), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.6 \cdot 10^{-23}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 1.06 \cdot 10^{+127}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{1 + 2 \cdot \frac{ky \cdot ky}{\frac{Om \cdot Om}{\ell \cdot \ell}}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 1.59999999999999988e-23Initial program 97.4%
Simplified97.4%
Taylor expanded in kx around 0 77.3%
associate-*r/77.3%
associate-*r*77.3%
unpow277.3%
unpow277.3%
Simplified77.3%
add-sqr-sqrt77.3%
hypot-1-def77.3%
sqrt-div77.3%
*-commutative77.3%
sqrt-prod77.8%
unpow277.8%
sqrt-prod40.8%
add-sqr-sqrt82.5%
*-commutative82.5%
sqrt-prod82.5%
sqrt-prod20.1%
add-sqr-sqrt89.1%
metadata-eval89.1%
sqrt-prod47.4%
add-sqr-sqrt97.3%
Applied egg-rr97.3%
expm1-log1p-u96.7%
expm1-udef96.7%
un-div-inv96.7%
associate-/l*96.7%
Applied egg-rr96.7%
expm1-def96.7%
expm1-log1p97.3%
associate-/r/97.3%
*-commutative97.3%
Simplified97.3%
Taylor expanded in ky around 0 65.6%
if 1.59999999999999988e-23 < l < 1.06000000000000006e127Initial program 92.6%
Simplified92.6%
Taylor expanded in kx around 0 77.0%
associate-*r/77.0%
associate-*r*77.0%
unpow277.0%
unpow277.0%
Simplified77.0%
Taylor expanded in ky around 0 68.2%
associate-/l*67.4%
unpow267.4%
unpow267.4%
unpow267.4%
Simplified67.4%
if 1.06000000000000006e127 < l Initial program 100.0%
Simplified100.0%
Taylor expanded in Om around 0 85.6%
associate-*r*85.6%
unpow285.6%
unpow285.6%
hypot-def85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in l around inf 87.1%
Final simplification68.8%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 24500000.0) 1.0 (sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 24500000.0) {
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 <= 24500000.0d0) 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 <= 24500000.0) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 24500000.0: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 24500000.0) 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 <= 24500000.0) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 24500000.0], 1.0, N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 24500000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 2.45e7Initial program 97.5%
Simplified97.5%
Taylor expanded in kx around 0 77.5%
associate-*r/77.5%
associate-*r*77.5%
unpow277.5%
unpow277.5%
Simplified77.5%
add-sqr-sqrt77.5%
hypot-1-def77.5%
sqrt-div77.5%
*-commutative77.5%
sqrt-prod78.0%
unpow278.0%
sqrt-prod40.8%
add-sqr-sqrt82.5%
*-commutative82.5%
sqrt-prod82.5%
sqrt-prod21.7%
add-sqr-sqrt89.0%
metadata-eval89.0%
sqrt-prod46.7%
add-sqr-sqrt97.0%
Applied egg-rr97.0%
expm1-log1p-u96.4%
expm1-udef96.4%
un-div-inv96.4%
associate-/l*96.4%
Applied egg-rr96.4%
expm1-def96.4%
expm1-log1p97.0%
associate-/r/97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in ky around 0 66.0%
if 2.45e7 < l Initial program 96.6%
Simplified96.6%
Taylor expanded in Om around 0 73.8%
associate-*r*73.8%
unpow273.8%
unpow273.8%
hypot-def75.9%
*-commutative75.9%
Simplified75.9%
Taylor expanded in l around inf 77.6%
Final simplification68.7%
(FPCore (l Om kx ky) :precision binary64 1.0)
double code(double l, double Om, double kx, double ky) {
return 1.0;
}
real(8) function code(l, om, kx, ky)
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: kx
real(8), intent (in) :: ky
code = 1.0d0
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0;
}
def code(l, Om, kx, ky): return 1.0
function code(l, Om, kx, ky) return 1.0 end
function tmp = code(l, Om, kx, ky) tmp = 1.0; end
code[l_, Om_, kx_, ky_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 97.3%
Simplified97.3%
Taylor expanded in kx around 0 77.3%
associate-*r/77.3%
associate-*r*77.3%
unpow277.3%
unpow277.3%
Simplified77.3%
add-sqr-sqrt77.3%
hypot-1-def77.3%
sqrt-div77.3%
*-commutative77.3%
sqrt-prod77.7%
unpow277.7%
sqrt-prod42.2%
add-sqr-sqrt83.5%
*-commutative83.5%
sqrt-prod83.5%
sqrt-prod37.6%
add-sqr-sqrt89.6%
metadata-eval89.6%
sqrt-prod46.3%
add-sqr-sqrt96.0%
Applied egg-rr96.0%
expm1-log1p-u95.3%
expm1-udef95.3%
un-div-inv95.3%
associate-/l*95.3%
Applied egg-rr95.3%
expm1-def95.3%
expm1-log1p96.0%
associate-/r/96.0%
*-commutative96.0%
Simplified96.0%
Taylor expanded in ky around 0 59.7%
Final simplification59.7%
herbie shell --seed 2023287
(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))))))))))