
(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 (/ Om l)))))))))
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 / (Om / l))))))));
}
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 / (Om / l))))))));
}
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 / (Om / l))))))))
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(Om / l)))))))) 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 / (Om / l)))))))); 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[(Om / l), $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 \frac{2}{\frac{Om}{\ell}}\right)}}
\end{array}
Initial program 98.0%
Simplified98.0%
expm1-log1p-u98.0%
expm1-udef98.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (log (exp (/ 0.5 (hypot 1.0 (* (/ 2.0 Om) (* (sin ky) l)))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + log(exp((0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l))))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + Math.log(Math.exp((0.5 / Math.hypot(1.0, ((2.0 / Om) * (Math.sin(ky) * l))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + math.log(math.exp((0.5 / math.hypot(1.0, ((2.0 / Om) * (math.sin(ky) * l))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + log(exp(Float64(0.5 / hypot(1.0, Float64(Float64(2.0 / Om) * Float64(sin(ky) * l)))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + log(exp((0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l)))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[Log[N[Exp[N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / Om), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \log \left(e^{\frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(\sin ky \cdot \ell\right)\right)}}\right)}
\end{array}
Initial program 98.0%
Simplified98.0%
expm1-log1p-u98.0%
expm1-udef98.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in kx around 0 92.4%
add-log-exp92.4%
un-div-inv92.4%
*-commutative92.4%
associate-/r/92.4%
associate-*l*92.4%
Applied egg-rr92.4%
Final simplification92.4%
(FPCore (l Om kx ky) :precision binary64 (if (<= kx 9e-115) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ 2.0 Om) (* ky l)))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (sin kx) (/ (* 2.0 l) Om))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (kx <= 9e-115) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (ky * l))))));
} else {
tmp = sqrt((0.5 + (0.5 / 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 <= 9e-115) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 / Om) * (ky * l))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (Math.sin(kx) * ((2.0 * l) / Om))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if kx <= 9e-115: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 / Om) * (ky * l)))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (math.sin(kx) * ((2.0 * l) / Om)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (kx <= 9e-115) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 / Om) * Float64(ky * l)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(sin(kx) * Float64(Float64(2.0 * l) / Om)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (kx <= 9e-115) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (ky * l)))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, (sin(kx) * ((2.0 * l) / Om)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[kx, 9e-115], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / Om), $MachinePrecision] * N[(ky * l), $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[(N[(2.0 * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 9 \cdot 10^{-115}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(ky \cdot \ell\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \sin kx \cdot \frac{2 \cdot \ell}{Om}\right)}}\\
\end{array}
\end{array}
if kx < 9.00000000000000046e-115Initial program 97.0%
Simplified97.0%
expm1-log1p-u97.0%
expm1-udef97.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in kx around 0 93.4%
un-div-inv93.4%
*-commutative93.4%
associate-/r/93.4%
associate-*l*93.4%
Applied egg-rr93.4%
Taylor expanded in ky around 0 89.4%
*-commutative89.4%
Simplified89.4%
if 9.00000000000000046e-115 < kx Initial program 100.0%
Simplified100.0%
Taylor expanded in ky around 0 93.7%
associate-/l*92.5%
associate-/r/93.7%
associate-*l*93.7%
metadata-eval93.7%
unpow293.7%
unpow293.7%
times-frac98.6%
swap-sqr98.6%
unpow298.6%
swap-sqr98.6%
hypot-1-def98.6%
*-commutative98.6%
associate-*r/98.6%
associate-*r/98.6%
Simplified98.6%
expm1-log1p-u98.6%
expm1-udef98.6%
un-div-inv98.6%
associate-/l*98.6%
div-inv98.6%
associate-/l/98.6%
clear-num98.6%
associate-/r/98.6%
*-commutative98.6%
Applied egg-rr98.6%
expm1-def98.6%
expm1-log1p98.6%
associate-*r/98.6%
Simplified98.6%
Final simplification92.5%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ 2.0 Om) (* (sin ky) l)))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l))))));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 / Om) * (Math.sin(ky) * l))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 / Om) * (math.sin(ky) * l))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 / Om) * Float64(sin(ky) * l)))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (sin(ky) * l)))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / Om), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(\sin ky \cdot \ell\right)\right)}}
\end{array}
Initial program 98.0%
Simplified98.0%
expm1-log1p-u98.0%
expm1-udef98.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in kx around 0 92.4%
un-div-inv92.4%
*-commutative92.4%
associate-/r/92.4%
associate-*l*92.4%
Applied egg-rr92.4%
Final simplification92.4%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 5.6e+73) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* (/ 2.0 Om) (* ky l)))))) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 5.6e+73) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (ky * l))))));
} else {
tmp = 1.0;
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 5.6e+73) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, ((2.0 / Om) * (ky * l))))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 5.6e+73: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, ((2.0 / Om) * (ky * l)))))) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 5.6e+73) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 / Om) * Float64(ky * l)))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 5.6e+73) tmp = sqrt((0.5 + (0.5 / hypot(1.0, ((2.0 / Om) * (ky * l)))))); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 5.6e+73], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 / Om), $MachinePrecision] * N[(ky * l), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 5.6 \cdot 10^{+73}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{Om} \cdot \left(ky \cdot \ell\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 5.60000000000000016e73Initial program 97.7%
Simplified97.7%
expm1-log1p-u97.7%
expm1-udef97.7%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in kx around 0 91.2%
un-div-inv91.2%
*-commutative91.2%
associate-/r/91.2%
associate-*l*91.2%
Applied egg-rr91.2%
Taylor expanded in ky around 0 86.7%
*-commutative86.7%
Simplified86.7%
if 5.60000000000000016e73 < Om Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in kx around 0 98.4%
add-log-exp98.4%
un-div-inv98.4%
*-commutative98.4%
associate-/r/98.4%
associate-*l*98.4%
Applied egg-rr98.4%
Taylor expanded in Om around inf 92.2%
Final simplification87.6%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 1e-17) 1.0 (if (<= l 4.4e+78) (sqrt 0.5) (if (<= l 9.5e+94) 1.0 (sqrt 0.5)))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1e-17) {
tmp = 1.0;
} else if (l <= 4.4e+78) {
tmp = sqrt(0.5);
} else if (l <= 9.5e+94) {
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 <= 1d-17) then
tmp = 1.0d0
else if (l <= 4.4d+78) then
tmp = sqrt(0.5d0)
else if (l <= 9.5d+94) 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 <= 1e-17) {
tmp = 1.0;
} else if (l <= 4.4e+78) {
tmp = Math.sqrt(0.5);
} else if (l <= 9.5e+94) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1e-17: tmp = 1.0 elif l <= 4.4e+78: tmp = math.sqrt(0.5) elif l <= 9.5e+94: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1e-17) tmp = 1.0; elseif (l <= 4.4e+78) tmp = sqrt(0.5); elseif (l <= 9.5e+94) 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 <= 1e-17) tmp = 1.0; elseif (l <= 4.4e+78) tmp = sqrt(0.5); elseif (l <= 9.5e+94) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1e-17], 1.0, If[LessEqual[l, 4.4e+78], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[l, 9.5e+94], 1.0, N[Sqrt[0.5], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 10^{-17}:\\
\;\;\;\;1\\
\mathbf{elif}\;\ell \leq 4.4 \cdot 10^{+78}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;\ell \leq 9.5 \cdot 10^{+94}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if l < 1.00000000000000007e-17 or 4.40000000000000028e78 < l < 9.4999999999999998e94Initial program 98.0%
Simplified98.0%
expm1-log1p-u98.0%
expm1-udef98.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in kx around 0 92.9%
add-log-exp92.9%
un-div-inv92.9%
*-commutative92.9%
associate-/r/92.9%
associate-*l*92.9%
Applied egg-rr92.9%
Taylor expanded in Om around inf 70.6%
if 1.00000000000000007e-17 < l < 4.40000000000000028e78 or 9.4999999999999998e94 < l Initial program 98.3%
Simplified98.3%
Taylor expanded in Om around 0 84.4%
associate-*r*84.4%
*-commutative84.4%
unpow284.4%
unpow284.4%
hypot-def86.1%
associate-*r/86.1%
associate-/l*86.1%
Simplified86.1%
Taylor expanded in Om around 0 87.9%
Final simplification74.6%
(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.0%
Simplified98.0%
expm1-log1p-u98.0%
expm1-udef98.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in kx around 0 92.4%
add-log-exp92.4%
un-div-inv92.4%
*-commutative92.4%
associate-/r/92.4%
associate-*l*92.4%
Applied egg-rr92.4%
Taylor expanded in Om around inf 61.5%
Final simplification61.5%
herbie shell --seed 2023313
(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))))))))))