
(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
(pow
(+ 1.0 (pow (* (hypot (sin kx) (sin ky)) (* 2.0 (/ l Om))) 2.0))
-0.5)))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * pow((1.0 + pow((hypot(sin(kx), sin(ky)) * (2.0 * (l / Om))), 2.0)), -0.5))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * Math.pow((1.0 + Math.pow((Math.hypot(Math.sin(kx), Math.sin(ky)) * (2.0 * (l / Om))), 2.0)), -0.5))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * math.pow((1.0 + math.pow((math.hypot(math.sin(kx), math.sin(ky)) * (2.0 * (l / Om))), 2.0)), -0.5))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * (Float64(1.0 + (Float64(hypot(sin(kx), sin(ky)) * Float64(2.0 * Float64(l / Om))) ^ 2.0)) ^ -0.5)))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * ((1.0 + ((hypot(sin(kx), sin(ky)) * (2.0 * (l / Om))) ^ 2.0)) ^ -0.5)))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[Power[N[(1.0 + N[Power[N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot {\left(1 + {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}^{2}\right)}^{-0.5}}
\end{array}
Initial program 98.8%
Simplified98.8%
add-sqr-sqrt98.8%
pow298.8%
sqrt-prod98.8%
unpow298.8%
sqrt-prod51.3%
add-sqr-sqrt99.1%
associate-/r/99.1%
*-commutative99.1%
unpow299.1%
unpow299.1%
hypot-def100.0%
Applied egg-rr100.0%
pow1/2100.0%
pow-flip100.0%
associate-*l*100.0%
metadata-eval100.0%
Applied egg-rr100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r/100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.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.8%
Simplified98.8%
add-sqr-sqrt98.8%
hypot-1-def98.8%
sqrt-prod98.8%
unpow298.8%
sqrt-prod51.3%
add-sqr-sqrt99.0%
associate-/r/99.0%
*-commutative99.0%
unpow299.0%
unpow299.0%
hypot-def100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= kx 1.55e-76) (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* 2.0 (/ (* ky l) 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 <= 1.55e-76) {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (2.0 * ((ky * l) / 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 <= 1.55e-76) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, (2.0 * ((ky * l) / 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 <= 1.55e-76: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (2.0 * ((ky * l) / 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 <= 1.55e-76) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(2.0 * Float64(Float64(ky * l) / Om))))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(l * Float64(2.0 * Float64(sin(kx) / Om))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (kx <= 1.55e-76) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (2.0 * ((ky * l) / 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, 1.55e-76], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(ky * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(l * N[(2.0 * N[(N[Sin[kx], $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.55 \cdot 10^{-76}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, 2 \cdot \frac{ky \cdot \ell}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \left(2 \cdot \frac{\sin kx}{Om}\right)\right)}}\\
\end{array}
\end{array}
if kx < 1.54999999999999985e-76Initial program 98.2%
Simplified98.2%
add-sqr-sqrt98.2%
hypot-1-def98.2%
sqrt-prod98.2%
unpow298.2%
sqrt-prod55.3%
add-sqr-sqrt98.6%
associate-/r/98.6%
*-commutative98.6%
unpow298.6%
unpow298.6%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 94.6%
Taylor expanded in ky around 0 88.7%
*-commutative88.7%
Simplified88.7%
if 1.54999999999999985e-76 < kx Initial program 100.0%
Simplified100.0%
Taylor expanded in ky around 0 82.2%
associate-/l*82.2%
associate-/r/82.2%
associate-*l*82.2%
*-commutative82.2%
unpow282.2%
unpow282.2%
times-frac98.4%
metadata-eval98.4%
swap-sqr98.4%
associate-*l/98.4%
associate-*r/98.4%
associate-*l/98.4%
associate-*r/98.4%
unpow298.4%
swap-sqr98.4%
*-commutative98.4%
*-commutative98.4%
Simplified98.4%
expm1-log1p-u97.6%
expm1-udef97.6%
*-commutative97.6%
div-inv97.6%
associate-*r*97.6%
Applied egg-rr97.6%
expm1-def97.7%
expm1-log1p98.4%
associate-*l*98.4%
associate-*l/98.4%
associate-*r/98.4%
Simplified98.4%
Final simplification92.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (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 * (1.0 / 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 * (1.0 / Math.hypot(1.0, (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.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(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, (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[Sin[ky], $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, \sin ky \cdot \left(\ell \cdot \frac{2}{Om}\right)\right)}}
\end{array}
Initial program 98.8%
Simplified98.8%
add-sqr-sqrt98.8%
hypot-1-def98.8%
sqrt-prod98.8%
unpow298.8%
sqrt-prod51.3%
add-sqr-sqrt99.0%
associate-/r/99.0%
*-commutative99.0%
unpow299.0%
unpow299.0%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 93.0%
Final simplification93.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 2.35e+157) (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* 2.0 (/ (* ky l) Om))))))) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 2.35e+157) {
tmp = sqrt((0.5 + (0.5 * (1.0 / 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 <= 2.35e+157) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / 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 <= 2.35e+157: tmp = math.sqrt((0.5 + (0.5 * (1.0 / 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 <= 2.35e+157) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / 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 <= 2.35e+157) tmp = sqrt((0.5 + (0.5 * (1.0 / 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, 2.35e+157], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(ky * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 2.35 \cdot 10^{+157}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, 2 \cdot \frac{ky \cdot \ell}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 2.35000000000000015e157Initial program 98.6%
Simplified98.6%
add-sqr-sqrt98.6%
hypot-1-def98.6%
sqrt-prod98.6%
unpow298.6%
sqrt-prod50.4%
add-sqr-sqrt98.9%
associate-/r/98.9%
*-commutative98.9%
unpow298.9%
unpow298.9%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 92.5%
Taylor expanded in ky around 0 86.9%
*-commutative86.9%
Simplified86.9%
if 2.35000000000000015e157 < Om Initial program 100.0%
Simplified100.0%
Taylor expanded in ky around 0 61.5%
associate-/l*61.5%
associate-/r/61.5%
associate-*l*61.5%
*-commutative61.5%
unpow261.5%
unpow261.5%
times-frac97.7%
metadata-eval97.7%
swap-sqr97.7%
associate-*l/97.7%
associate-*r/97.7%
associate-*l/97.7%
associate-*r/97.7%
unpow297.7%
swap-sqr97.7%
*-commutative97.7%
*-commutative97.7%
Simplified97.7%
expm1-log1p-u97.5%
expm1-udef97.5%
*-commutative97.5%
div-inv97.5%
associate-*r*97.5%
Applied egg-rr97.5%
expm1-def97.5%
expm1-log1p97.7%
associate-*l*97.7%
associate-*l/97.7%
associate-*r/97.7%
Simplified97.7%
Taylor expanded in l around 0 91.5%
Final simplification87.6%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 30.5) (sqrt 0.5) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 30.5) {
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 <= 30.5d0) 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 <= 30.5) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 30.5: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 30.5) 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 <= 30.5) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 30.5], N[Sqrt[0.5], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 30.5:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 30.5Initial program 98.5%
Simplified98.5%
Taylor expanded in ky around 0 74.4%
associate-/l*74.5%
associate-/r/74.8%
associate-*l*74.8%
*-commutative74.8%
unpow274.8%
unpow274.8%
times-frac87.4%
metadata-eval87.4%
swap-sqr87.4%
associate-*l/87.4%
associate-*r/87.4%
associate-*l/87.4%
associate-*r/87.4%
unpow287.4%
swap-sqr93.5%
*-commutative93.5%
*-commutative93.5%
Simplified93.5%
Taylor expanded in l around inf 62.3%
if 30.5 < Om Initial program 100.0%
Simplified100.0%
Taylor expanded in ky around 0 71.7%
associate-/l*71.7%
associate-/r/71.7%
associate-*l*71.7%
*-commutative71.7%
unpow271.7%
unpow271.7%
times-frac96.8%
metadata-eval96.8%
swap-sqr96.8%
associate-*l/96.8%
associate-*r/96.8%
associate-*l/96.8%
associate-*r/96.8%
unpow296.8%
swap-sqr97.1%
*-commutative97.1%
*-commutative97.1%
Simplified97.1%
expm1-log1p-u96.9%
expm1-udef96.9%
*-commutative96.9%
div-inv96.9%
associate-*r*96.9%
Applied egg-rr96.9%
expm1-def96.9%
expm1-log1p97.1%
associate-*l*97.1%
associate-*l/97.1%
associate-*r/97.1%
Simplified97.1%
Taylor expanded in l around 0 83.8%
Final simplification67.3%
(FPCore (l Om kx ky) :precision binary64 (sqrt 0.5))
double code(double l, double Om, double kx, double ky) {
return sqrt(0.5);
}
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)
end function
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(0.5);
}
def code(l, Om, kx, ky): return math.sqrt(0.5)
function code(l, Om, kx, ky) return sqrt(0.5) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(0.5); end
code[l_, Om_, kx_, ky_] := N[Sqrt[0.5], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5}
\end{array}
Initial program 98.8%
Simplified98.8%
Taylor expanded in ky around 0 73.8%
associate-/l*73.9%
associate-/r/74.1%
associate-*l*74.1%
*-commutative74.1%
unpow274.1%
unpow274.1%
times-frac89.6%
metadata-eval89.6%
swap-sqr89.6%
associate-*l/89.6%
associate-*r/89.6%
associate-*l/89.6%
associate-*r/89.6%
unpow289.6%
swap-sqr94.4%
*-commutative94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in l around inf 56.0%
Final simplification56.0%
herbie shell --seed 2023322
(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))))))))))