
(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 9 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
(pow
(sqrt (hypot 1.0 (* (* l (/ 2.0 Om)) (hypot (sin kx) (sin ky)))))
2.0))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / pow(sqrt(hypot(1.0, ((l * (2.0 / Om)) * hypot(sin(kx), sin(ky))))), 2.0)))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 * (1.0 / Math.pow(Math.sqrt(Math.hypot(1.0, ((l * (2.0 / Om)) * Math.hypot(Math.sin(kx), Math.sin(ky))))), 2.0)))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.pow(math.sqrt(math.hypot(1.0, ((l * (2.0 / Om)) * math.hypot(math.sin(kx), math.sin(ky))))), 2.0)))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / (sqrt(hypot(1.0, Float64(Float64(l * Float64(2.0 / Om)) * hypot(sin(kx), sin(ky))))) ^ 2.0))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / (sqrt(hypot(1.0, ((l * (2.0 / Om)) * hypot(sin(kx), sin(ky))))) ^ 2.0))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Power[N[Sqrt[N[Sqrt[1.0 ^ 2 + N[(N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{{\left(\sqrt{\mathsf{hypot}\left(1, \left(\ell \cdot \frac{2}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}\right)}^{2}}}
\end{array}
Initial program 98.4%
Simplified98.4%
add-sqr-sqrt98.4%
pow298.4%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (l Om kx ky)
:precision binary64
(sqrt
(+
0.5
(*
0.5
(/ 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 * (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 * (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 * (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 * Float64(1.0 / hypot(1.0, Float64(Float64(l * Float64(2.0 / Om)) * hypot(sin(kx), sin(ky)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (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[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(l * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \left(\ell \cdot \frac{2}{Om}\right) \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}}
\end{array}
Initial program 98.4%
Simplified98.4%
add-sqr-sqrt98.4%
hypot-1-def98.4%
sqrt-prod98.4%
unpow298.4%
sqrt-prod63.0%
add-sqr-sqrt99.4%
associate-/r/99.4%
*-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (pow (sqrt (hypot 1.0 (/ (* l 2.0) (/ Om (sin ky))))) -2.0)))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * pow(sqrt(hypot(1.0, ((l * 2.0) / (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.pow(Math.sqrt(Math.hypot(1.0, ((l * 2.0) / (Om / Math.sin(ky))))), -2.0))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * math.pow(math.sqrt(math.hypot(1.0, ((l * 2.0) / (Om / math.sin(ky))))), -2.0))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * (sqrt(hypot(1.0, Float64(Float64(l * 2.0) / Float64(Om / sin(ky))))) ^ -2.0)))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (sqrt(hypot(1.0, ((l * 2.0) / (Om / sin(ky))))) ^ -2.0)))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[Power[N[Sqrt[N[Sqrt[1.0 ^ 2 + N[(N[(l * 2.0), $MachinePrecision] / N[(Om / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot {\left(\sqrt{\mathsf{hypot}\left(1, \frac{\ell \cdot 2}{\frac{Om}{\sin ky}}\right)}\right)}^{-2}}
\end{array}
Initial program 98.4%
Simplified98.4%
Taylor expanded in kx around 0 73.9%
*-commutative73.9%
associate-/l*73.6%
associate-*l/73.2%
unpow273.2%
unpow273.2%
Simplified73.2%
add-sqr-sqrt73.2%
pow273.2%
Applied egg-rr93.4%
pow-flip93.4%
metadata-eval93.4%
Applied egg-rr93.4%
Final simplification93.4%
(FPCore (l Om kx ky)
:precision binary64
(let* ((t_0 (/ (* l ky) Om)))
(if (<= kx 8e-160)
(sqrt (+ 0.5 (* 0.5 (/ 1.0 (sqrt (+ 1.0 (* 4.0 (* t_0 t_0))))))))
(sqrt
(+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (/ (* 2.0 (* l (sin kx))) Om)))))))))
double code(double l, double Om, double kx, double ky) {
double t_0 = (l * ky) / Om;
double tmp;
if (kx <= 8e-160) {
tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * (t_0 * t_0))))))));
} else {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * sin(kx))) / Om))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double t_0 = (l * ky) / Om;
double tmp;
if (kx <= 8e-160) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + (4.0 * (t_0 * t_0))))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, ((2.0 * (l * Math.sin(kx))) / Om))))));
}
return tmp;
}
def code(l, Om, kx, ky): t_0 = (l * ky) / Om tmp = 0 if kx <= 8e-160: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + (4.0 * (t_0 * t_0)))))))) else: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((2.0 * (l * math.sin(kx))) / Om)))))) return tmp
function code(l, Om, kx, ky) t_0 = Float64(Float64(l * ky) / Om) tmp = 0.0 if (kx <= 8e-160) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(4.0 * Float64(t_0 * t_0)))))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(2.0 * Float64(l * sin(kx))) / Om)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) t_0 = (l * ky) / Om; tmp = 0.0; if (kx <= 8e-160) tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * (t_0 * t_0)))))))); else tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((2.0 * (l * sin(kx))) / Om)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := Block[{t$95$0 = N[(N[(l * ky), $MachinePrecision] / Om), $MachinePrecision]}, If[LessEqual[kx, 8e-160], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[(l * N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\ell \cdot ky}{Om}\\
\mathbf{if}\;kx \leq 8 \cdot 10^{-160}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + 4 \cdot \left(t_0 \cdot t_0\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{2 \cdot \left(\ell \cdot \sin kx\right)}{Om}\right)}}\\
\end{array}
\end{array}
if kx < 7.9999999999999999e-160Initial program 97.4%
Simplified97.4%
Taylor expanded in kx around 0 76.4%
*-commutative76.4%
associate-/l*76.4%
associate-*l/75.7%
unpow275.7%
unpow275.7%
Simplified75.7%
Taylor expanded in ky around 0 62.9%
*-commutative62.9%
unpow262.9%
unpow262.9%
unswap-sqr76.9%
unpow276.9%
Simplified76.9%
times-frac85.1%
Applied egg-rr85.1%
if 7.9999999999999999e-160 < kx Initial program 100.0%
Simplified100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
unpow2100.0%
sqrt-prod59.4%
add-sqr-sqrt100.0%
associate-/r/100.0%
*-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in ky around 0 99.9%
associate-*r/99.9%
Simplified99.9%
Final simplification90.9%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (/ (* l 2.0) (/ Om (sin ky)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((l * 2.0) / (Om / sin(ky))))))));
}
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, ((l * 2.0) / (Om / Math.sin(ky))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, ((l * 2.0) / (Om / math.sin(ky))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(Float64(l * 2.0) / Float64(Om / sin(ky)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, ((l * 2.0) / (Om / sin(ky)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(l * 2.0), $MachinePrecision] / N[(Om / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\ell \cdot 2}{\frac{Om}{\sin ky}}\right)}}
\end{array}
Initial program 98.4%
Simplified98.4%
Taylor expanded in kx around 0 73.9%
*-commutative73.9%
associate-/l*73.6%
associate-*l/73.2%
unpow273.2%
unpow273.2%
Simplified73.2%
add-sqr-sqrt73.2%
hypot-1-def73.2%
sqrt-div73.2%
sqrt-prod73.6%
sqrt-prod44.8%
add-sqr-sqrt85.1%
metadata-eval85.1%
sqrt-div85.4%
sqrt-prod46.6%
add-sqr-sqrt91.2%
unpow291.2%
sqrt-prod47.7%
add-sqr-sqrt93.4%
Applied egg-rr93.4%
Final simplification93.4%
(FPCore (l Om kx ky)
:precision binary64
(let* ((t_0 (/ (* l ky) Om)))
(if (<= Om 2e+102)
(sqrt (+ 0.5 (* 0.5 (/ 1.0 (sqrt (+ 1.0 (* 4.0 (* t_0 t_0))))))))
1.0)))
double code(double l, double Om, double kx, double ky) {
double t_0 = (l * ky) / Om;
double tmp;
if (Om <= 2e+102) {
tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * (t_0 * t_0))))))));
} 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) :: t_0
real(8) :: tmp
t_0 = (l * ky) / om
if (om <= 2d+102) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / sqrt((1.0d0 + (4.0d0 * (t_0 * t_0))))))))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double t_0 = (l * ky) / Om;
double tmp;
if (Om <= 2e+102) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.sqrt((1.0 + (4.0 * (t_0 * t_0))))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): t_0 = (l * ky) / Om tmp = 0 if Om <= 2e+102: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.sqrt((1.0 + (4.0 * (t_0 * t_0)))))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) t_0 = Float64(Float64(l * ky) / Om) tmp = 0.0 if (Om <= 2e+102) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / sqrt(Float64(1.0 + Float64(4.0 * Float64(t_0 * t_0)))))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) t_0 = (l * ky) / Om; tmp = 0.0; if (Om <= 2e+102) tmp = sqrt((0.5 + (0.5 * (1.0 / sqrt((1.0 + (4.0 * (t_0 * t_0)))))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := Block[{t$95$0 = N[(N[(l * ky), $MachinePrecision] / Om), $MachinePrecision]}, If[LessEqual[Om, 2e+102], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[N[(1.0 + N[(4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\ell \cdot ky}{Om}\\
\mathbf{if}\;Om \leq 2 \cdot 10^{+102}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\sqrt{1 + 4 \cdot \left(t_0 \cdot t_0\right)}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 1.99999999999999995e102Initial program 98.1%
Simplified98.1%
Taylor expanded in kx around 0 74.3%
*-commutative74.3%
associate-/l*74.0%
associate-*l/73.5%
unpow273.5%
unpow273.5%
Simplified73.5%
Taylor expanded in ky around 0 62.0%
*-commutative62.0%
unpow262.0%
unpow262.0%
unswap-sqr75.4%
unpow275.4%
Simplified75.4%
times-frac85.0%
Applied egg-rr85.0%
if 1.99999999999999995e102 < Om Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 71.9%
*-commutative71.9%
associate-/l*71.4%
associate-*l/71.4%
unpow271.4%
unpow271.4%
Simplified71.4%
add-sqr-sqrt71.4%
pow271.4%
Applied egg-rr92.3%
pow-flip92.3%
metadata-eval92.3%
Applied egg-rr92.3%
Taylor expanded in l around 0 90.4%
Final simplification85.9%
(FPCore (l Om kx ky)
:precision binary64
(if (<= Om 7.5e-12)
(sqrt
(+
0.5
(* 0.5 (/ 1.0 (+ (* 0.25 (/ Om (* l ky))) (* 2.0 (/ (* l ky) Om)))))))
1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 7.5e-12) {
tmp = sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om)))))));
} 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 <= 7.5d-12) then
tmp = sqrt((0.5d0 + (0.5d0 * (1.0d0 / ((0.25d0 * (om / (l * ky))) + (2.0d0 * ((l * ky) / om)))))))
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 <= 7.5e-12) {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om)))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 7.5e-12: tmp = math.sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om))))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 7.5e-12) tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(Float64(0.25 * Float64(Om / Float64(l * ky))) + Float64(2.0 * Float64(Float64(l * ky) / Om))))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 7.5e-12) tmp = sqrt((0.5 + (0.5 * (1.0 / ((0.25 * (Om / (l * ky))) + (2.0 * ((l * ky) / Om))))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 7.5e-12], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[(N[(0.25 * N[(Om / N[(l * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(N[(l * ky), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 7.5 \cdot 10^{-12}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{0.25 \cdot \frac{Om}{\ell \cdot ky} + 2 \cdot \frac{\ell \cdot ky}{Om}}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 7.5e-12Initial program 98.5%
Simplified98.5%
Taylor expanded in kx around 0 73.5%
*-commutative73.5%
associate-/l*73.2%
associate-*l/72.7%
unpow272.7%
unpow272.7%
Simplified72.7%
Taylor expanded in ky around 0 61.8%
*-commutative61.8%
unpow261.8%
unpow261.8%
unswap-sqr75.4%
unpow275.4%
Simplified75.4%
Taylor expanded in l around inf 57.9%
if 7.5e-12 < Om Initial program 98.3%
Simplified98.3%
Taylor expanded in kx around 0 75.3%
*-commutative75.3%
associate-/l*74.9%
associate-*l/74.9%
unpow274.9%
unpow274.9%
Simplified74.9%
add-sqr-sqrt74.9%
pow274.9%
Applied egg-rr91.8%
pow-flip91.8%
metadata-eval91.8%
Applied egg-rr91.8%
Taylor expanded in l around 0 82.3%
Final simplification63.6%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 6.9e-12) (sqrt 0.5) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 6.9e-12) {
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 <= 6.9d-12) 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 <= 6.9e-12) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 6.9e-12: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 6.9e-12) 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 <= 6.9e-12) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 6.9e-12], N[Sqrt[0.5], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 6.9 \cdot 10^{-12}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 6.9000000000000001e-12Initial program 98.5%
Simplified98.5%
Taylor expanded in Om around 0 49.5%
unpow249.5%
unpow249.5%
hypot-def50.1%
Simplified50.1%
Taylor expanded in l around inf 58.1%
if 6.9000000000000001e-12 < Om Initial program 98.3%
Simplified98.3%
Taylor expanded in kx around 0 75.3%
*-commutative75.3%
associate-/l*74.9%
associate-*l/74.9%
unpow274.9%
unpow274.9%
Simplified74.9%
add-sqr-sqrt74.9%
pow274.9%
Applied egg-rr91.8%
pow-flip91.8%
metadata-eval91.8%
Applied egg-rr91.8%
Taylor expanded in l around 0 82.3%
Final simplification63.7%
(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.4%
Simplified98.4%
Taylor expanded in Om around 0 43.3%
unpow243.3%
unpow243.3%
hypot-def44.1%
Simplified44.1%
Taylor expanded in l around inf 53.0%
Final simplification53.0%
herbie shell --seed 2023291
(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))))))))))