
(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 ky) (sin kx)) (* 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(ky), sin(kx)) * (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(ky), Math.sin(kx)) * (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(ky), math.sin(kx)) * (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(ky), sin(kx)) * 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(ky), sin(kx)) * (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[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $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 ky, \sin kx\right) \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}
\end{array}
Initial program 98.7%
distribute-rgt-in98.7%
metadata-eval98.7%
metadata-eval98.7%
associate-/l*98.7%
metadata-eval98.7%
Simplified98.7%
expm1-log1p-u98.7%
expm1-udef98.7%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
hypot-def98.8%
unpow298.8%
unpow298.8%
+-commutative98.8%
unpow298.8%
unpow298.8%
hypot-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= kx 9.2e-98) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ l (/ Om ky))))))) (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* (sin kx) (* 2.0 (/ l Om))))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 9.2e-98) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * (l / (Om / ky)))))));
} else {
tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (sin(kx) * (2.0 * (l / Om))))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 9.2e-98) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * (l / (Om / ky)))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 * (1.0 / Math.hypot(1.0, (Math.sin(kx) * (2.0 * (l / Om))))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if kx <= 9.2e-98: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * (l / (Om / ky))))))) else: tmp = math.sqrt((0.5 + (0.5 * (1.0 / math.hypot(1.0, (math.sin(kx) * (2.0 * (l / Om)))))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (kx <= 9.2e-98) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(l / Float64(Om / ky))))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 * Float64(1.0 / hypot(1.0, Float64(sin(kx) * Float64(2.0 * Float64(l / Om)))))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (kx <= 9.2e-98) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * (l / (Om / ky))))))); else tmp = sqrt((0.5 + (0.5 * (1.0 / hypot(1.0, (sin(kx) * (2.0 * (l / Om)))))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[kx, 9.2e-98], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(l / N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Sin[kx], $MachinePrecision] * N[(2.0 * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 9.2 \cdot 10^{-98}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{\ell}{\frac{Om}{ky}}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, \sin kx \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}\\
\end{array}
\end{array}
if kx < 9.20000000000000002e-98Initial program 98.2%
distribute-rgt-in98.2%
metadata-eval98.2%
metadata-eval98.2%
associate-/l*98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in kx around 0 76.9%
associate-/l*77.5%
unpow277.5%
unpow277.5%
Simplified77.5%
expm1-log1p-u77.5%
expm1-udef77.5%
Applied egg-rr91.3%
expm1-def91.3%
expm1-log1p91.3%
associate-*r*91.3%
Simplified91.3%
Taylor expanded in ky around 0 83.8%
associate-*l/83.8%
metadata-eval83.8%
associate-/l*83.8%
Applied egg-rr83.8%
if 9.20000000000000002e-98 < kx 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%
Simplified100.0%
Taylor expanded in ky around 0 97.6%
Final simplification88.2%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (* 0.5 (/ 1.0 (hypot 1.0 (* (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, (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.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.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(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, (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[Sin[ky], $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, \sin ky \cdot \left(2 \cdot \frac{\ell}{Om}\right)\right)}}
\end{array}
Initial 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 kx around 0 77.9%
associate-/l*78.3%
unpow278.3%
unpow278.3%
Simplified78.3%
expm1-log1p-u78.3%
expm1-udef78.3%
Applied egg-rr91.3%
expm1-def91.3%
expm1-log1p91.3%
associate-*r*91.3%
Simplified91.3%
Final simplification91.3%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 6.5e+149) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ l (/ Om ky))))))) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 6.5e+149) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * (l / (Om / ky)))))));
} else {
tmp = 1.0;
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 6.5e+149) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * (l / (Om / ky)))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 6.5e+149: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * (l / (Om / ky))))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 6.5e+149) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(l / Float64(Om / ky))))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 6.5e+149) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * (l / (Om / ky))))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 6.5e+149], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(l / N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 6.5 \cdot 10^{+149}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{\ell}{\frac{Om}{ky}}\right)}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 6.50000000000000015e149Initial program 98.6%
distribute-rgt-in98.6%
metadata-eval98.6%
metadata-eval98.6%
associate-/l*98.6%
metadata-eval98.6%
Simplified98.6%
Taylor expanded in kx around 0 77.3%
associate-/l*77.8%
unpow277.8%
unpow277.8%
Simplified77.8%
expm1-log1p-u77.8%
expm1-udef77.8%
Applied egg-rr90.4%
expm1-def90.4%
expm1-log1p90.4%
associate-*r*90.4%
Simplified90.4%
Taylor expanded in ky around 0 83.5%
associate-*l/83.5%
metadata-eval83.5%
associate-/l*83.5%
Applied egg-rr83.5%
if 6.50000000000000015e149 < Om Initial program 100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in kx around 0 81.8%
associate-/l*81.8%
unpow281.8%
unpow281.8%
Simplified81.8%
expm1-log1p-u81.8%
expm1-udef81.8%
Applied egg-rr97.6%
expm1-def97.6%
expm1-log1p97.6%
associate-*r*97.6%
Simplified97.6%
Taylor expanded in l around 0 95.1%
Final simplification85.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 7.8e-78) (+ 1.0 (/ (* -0.5 (* (* l l) (* ky ky))) (* Om Om))) (sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 7.8e-78) {
tmp = 1.0 + ((-0.5 * ((l * l) * (ky * ky))) / (Om * Om));
} 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 <= 7.8d-78) then
tmp = 1.0d0 + (((-0.5d0) * ((l * l) * (ky * ky))) / (om * om))
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 <= 7.8e-78) {
tmp = 1.0 + ((-0.5 * ((l * l) * (ky * ky))) / (Om * Om));
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 7.8e-78: tmp = 1.0 + ((-0.5 * ((l * l) * (ky * ky))) / (Om * Om)) else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 7.8e-78) tmp = Float64(1.0 + Float64(Float64(-0.5 * Float64(Float64(l * l) * Float64(ky * ky))) / Float64(Om * Om))); else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 7.8e-78) tmp = 1.0 + ((-0.5 * ((l * l) * (ky * ky))) / (Om * Om)); else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 7.8e-78], N[(1.0 + N[(N[(-0.5 * N[(N[(l * l), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 7.8 \cdot 10^{-78}:\\
\;\;\;\;1 + \frac{-0.5 \cdot \left(\left(\ell \cdot \ell\right) \cdot \left(ky \cdot ky\right)\right)}{Om \cdot Om}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 7.8000000000000004e-78Initial program 99.4%
distribute-rgt-in99.4%
metadata-eval99.4%
metadata-eval99.4%
associate-/l*99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in kx around 0 81.1%
associate-/l*81.7%
unpow281.7%
unpow281.7%
Simplified81.7%
Taylor expanded in ky around 0 39.8%
+-commutative39.8%
*-commutative39.8%
fma-def39.8%
unpow239.8%
unpow239.8%
unswap-sqr46.6%
unpow246.6%
Simplified46.6%
Taylor expanded in l around 0 40.0%
associate-*r/40.0%
unpow240.0%
unpow240.0%
unpow240.0%
Simplified40.0%
if 7.8000000000000004e-78 < l Initial program 97.2%
distribute-rgt-in97.2%
metadata-eval97.2%
metadata-eval97.2%
associate-/l*97.2%
metadata-eval97.2%
Simplified97.2%
Taylor expanded in Om around 0 68.6%
*-commutative68.6%
associate-*r*68.6%
associate-*l/68.6%
unpow268.6%
unpow268.6%
hypot-def71.1%
associate-*l/71.1%
*-commutative71.1%
Simplified71.1%
Taylor expanded in l around inf 75.3%
Final simplification50.7%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 4.3e-19) 1.0 (sqrt 0.5)))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 4.3e-19) {
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 <= 4.3d-19) 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 <= 4.3e-19) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 4.3e-19: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 4.3e-19) 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 <= 4.3e-19) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 4.3e-19], 1.0, N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 4.3 \cdot 10^{-19}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 4.3e-19Initial program 99.5%
distribute-rgt-in99.5%
metadata-eval99.5%
metadata-eval99.5%
associate-/l*99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in kx around 0 80.3%
associate-/l*80.9%
unpow280.9%
unpow280.9%
Simplified80.9%
expm1-log1p-u80.9%
expm1-udef80.9%
Applied egg-rr91.6%
expm1-def91.6%
expm1-log1p91.6%
associate-*r*91.6%
Simplified91.6%
Taylor expanded in l around 0 65.2%
if 4.3e-19 < l Initial program 96.9%
distribute-rgt-in96.9%
metadata-eval96.9%
metadata-eval96.9%
associate-/l*96.9%
metadata-eval96.9%
Simplified96.9%
Taylor expanded in Om around 0 69.6%
*-commutative69.6%
associate-*r*69.6%
associate-*l/69.6%
unpow269.6%
unpow269.6%
hypot-def72.4%
associate-*l/72.4%
*-commutative72.4%
Simplified72.4%
Taylor expanded in l around inf 76.2%
Final simplification68.3%
(FPCore (l Om kx ky) :precision binary64 (+ 1.0 (/ (* -0.5 (* (* l l) (* ky ky))) (* Om Om))))
double code(double l, double Om, double kx, double ky) {
return 1.0 + ((-0.5 * ((l * l) * (ky * ky))) / (Om * Om));
}
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 + (((-0.5d0) * ((l * l) * (ky * ky))) / (om * om))
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0 + ((-0.5 * ((l * l) * (ky * ky))) / (Om * Om));
}
def code(l, Om, kx, ky): return 1.0 + ((-0.5 * ((l * l) * (ky * ky))) / (Om * Om))
function code(l, Om, kx, ky) return Float64(1.0 + Float64(Float64(-0.5 * Float64(Float64(l * l) * Float64(ky * ky))) / Float64(Om * Om))) end
function tmp = code(l, Om, kx, ky) tmp = 1.0 + ((-0.5 * ((l * l) * (ky * ky))) / (Om * Om)); end
code[l_, Om_, kx_, ky_] := N[(1.0 + N[(N[(-0.5 * N[(N[(l * l), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{-0.5 \cdot \left(\left(\ell \cdot \ell\right) \cdot \left(ky \cdot ky\right)\right)}{Om \cdot Om}
\end{array}
Initial 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 kx around 0 77.9%
associate-/l*78.3%
unpow278.3%
unpow278.3%
Simplified78.3%
Taylor expanded in ky around 0 33.1%
+-commutative33.1%
*-commutative33.1%
fma-def33.1%
unpow233.1%
unpow233.1%
unswap-sqr38.9%
unpow238.9%
Simplified38.9%
Taylor expanded in l around 0 33.4%
associate-*r/33.4%
unpow233.4%
unpow233.4%
unpow233.4%
Simplified33.4%
Final simplification33.4%
herbie shell --seed 2023252
(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))))))))))