
(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 (+ (+ 1.5 (/ 0.5 (hypot 1.0 (* (* 2.0 (hypot (sin kx) (sin ky))) (/ l Om))))) -1.0)))
double code(double l, double Om, double kx, double ky) {
return sqrt(((1.5 + (0.5 / hypot(1.0, ((2.0 * hypot(sin(kx), sin(ky))) * (l / Om))))) + -1.0));
}
public static double code(double l, double Om, double kx, double ky) {
return Math.sqrt(((1.5 + (0.5 / Math.hypot(1.0, ((2.0 * Math.hypot(Math.sin(kx), Math.sin(ky))) * (l / Om))))) + -1.0));
}
def code(l, Om, kx, ky): return math.sqrt(((1.5 + (0.5 / math.hypot(1.0, ((2.0 * math.hypot(math.sin(kx), math.sin(ky))) * (l / Om))))) + -1.0))
function code(l, Om, kx, ky) return sqrt(Float64(Float64(1.5 + Float64(0.5 / hypot(1.0, Float64(Float64(2.0 * hypot(sin(kx), sin(ky))) * Float64(l / Om))))) + -1.0)) end
function tmp = code(l, Om, kx, ky) tmp = sqrt(((1.5 + (0.5 / hypot(1.0, ((2.0 * hypot(sin(kx), sin(ky))) * (l / Om))))) + -1.0)); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(N[(1.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left(1.5 + \frac{0.5}{\mathsf{hypot}\left(1, \left(2 \cdot \mathsf{hypot}\left(\sin kx, \sin ky\right)\right) \cdot \frac{\ell}{Om}\right)}\right) + -1}
\end{array}
Initial program 98.8%
Simplified98.8%
add-sqr-sqrt98.8%
hypot-1-def98.8%
sqrt-prod98.8%
unpow298.8%
sqrt-prod53.9%
add-sqr-sqrt98.8%
associate-/l*98.8%
unpow298.8%
unpow298.8%
hypot-def100.0%
Applied egg-rr100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
sub-neg100.0%
rem-exp-log100.0%
associate-*r*100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (* (hypot (sin kx) (sin ky)) (/ l Om))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * (hypot(sin(kx), sin(ky)) * (l / Om)))))));
}
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 * (Math.hypot(Math.sin(kx), Math.sin(ky)) * (l / Om)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * (math.hypot(math.sin(kx), math.sin(ky)) * (l / Om)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(hypot(sin(kx), sin(ky)) * Float64(l / Om))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * (hypot(sin(kx), sin(ky)) * (l / Om))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \left(\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \frac{\ell}{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-prod53.9%
add-sqr-sqrt98.8%
associate-/l*98.8%
unpow298.8%
unpow298.8%
hypot-def100.0%
Applied egg-rr100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
rem-exp-log100.0%
+-commutative100.0%
associate--l+100.0%
metadata-eval100.0%
+-commutative100.0%
*-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (if (<= ky 4e+50) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* l (/ (* 2.0 ky) Om)))))) (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* 2.0 (/ (* (sin kx) l) Om))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 4e+50) {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (l * ((2.0 * ky) / Om))))));
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((sin(kx) * l) / Om))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (ky <= 4e+50) {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (l * ((2.0 * ky) / Om))))));
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (2.0 * ((Math.sin(kx) * l) / Om))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if ky <= 4e+50: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (l * ((2.0 * ky) / Om)))))) else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 * ((math.sin(kx) * l) / Om)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (ky <= 4e+50) tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(l * Float64(Float64(2.0 * ky) / Om)))))); else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 * Float64(Float64(sin(kx) * l) / Om)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (ky <= 4e+50) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (l * ((2.0 * ky) / Om)))))); else tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 * ((sin(kx) * l) / Om)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[ky, 4e+50], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(l * N[(N[(2.0 * ky), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 * N[(N[(N[Sin[kx], $MachinePrecision] * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4 \cdot 10^{+50}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \frac{2 \cdot ky}{Om}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, 2 \cdot \frac{\sin kx \cdot \ell}{Om}\right)}}\\
\end{array}
\end{array}
if ky < 4.0000000000000003e50Initial program 98.5%
Simplified98.5%
add-sqr-sqrt98.5%
hypot-1-def98.5%
sqrt-prod98.5%
unpow298.5%
sqrt-prod52.4%
add-sqr-sqrt98.5%
associate-/l*98.5%
unpow298.5%
unpow298.5%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 94.5%
Taylor expanded in ky around 0 88.8%
*-commutative88.8%
associate-/l*88.8%
associate-*l/88.8%
Simplified88.8%
un-div-inv88.8%
associate-/r/88.8%
*-commutative88.8%
*-commutative88.8%
*-un-lft-identity88.8%
times-frac88.8%
metadata-eval88.8%
Applied egg-rr88.8%
associate-*r/88.8%
Simplified88.8%
if 4.0000000000000003e50 < ky Initial program 100.0%
Simplified100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
unpow2100.0%
sqrt-prod60.0%
add-sqr-sqrt100.0%
associate-/l*100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Applied egg-rr100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
rem-exp-log100.0%
+-commutative100.0%
associate--l+100.0%
metadata-eval100.0%
+-commutative100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in ky around 0 91.3%
Final simplification89.3%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (/ 2.0 (/ (/ Om l) (sin ky))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + (0.5 / hypot(1.0, (2.0 / ((Om / l) / sin(ky)))))));
}
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 / l) / Math.sin(ky)))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + (0.5 / math.hypot(1.0, (2.0 / ((Om / l) / math.sin(ky)))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(2.0 / Float64(Float64(Om / l) / sin(ky))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + (0.5 / hypot(1.0, (2.0 / ((Om / l) / sin(ky))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(2.0 / N[(N[(Om / l), $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \frac{2}{\frac{\frac{Om}{\ell}}{\sin ky}}\right)}}
\end{array}
Initial program 98.8%
Simplified98.8%
add-sqr-sqrt98.8%
hypot-1-def98.8%
sqrt-prod98.8%
unpow298.8%
sqrt-prod53.9%
add-sqr-sqrt98.8%
associate-/l*98.8%
unpow298.8%
unpow298.8%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 95.4%
*-un-lft-identity95.4%
un-div-inv95.4%
clear-num95.4%
associate-*l/95.4%
*-un-lft-identity95.4%
Applied egg-rr95.4%
*-lft-identity95.4%
associate-/l*95.4%
associate-*r*95.4%
*-commutative95.4%
associate-*l/95.4%
associate-/r/95.4%
associate-/l*95.4%
Simplified95.4%
Final simplification95.4%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 1.25e-151) 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 (* l (/ (* 2.0 ky) Om))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.25e-151) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + (0.5 / hypot(1.0, (l * ((2.0 * ky) / Om))))));
}
return tmp;
}
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.25e-151) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, (l * ((2.0 * ky) / Om))))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1.25e-151: tmp = 1.0 else: tmp = math.sqrt((0.5 + (0.5 / math.hypot(1.0, (l * ((2.0 * ky) / Om)))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1.25e-151) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, Float64(l * Float64(Float64(2.0 * ky) / Om)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 1.25e-151) tmp = 1.0; else tmp = sqrt((0.5 + (0.5 / hypot(1.0, (l * ((2.0 * ky) / Om)))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.25e-151], 1.0, N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(l * N[(N[(2.0 * ky), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.25 \cdot 10^{-151}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, \ell \cdot \frac{2 \cdot ky}{Om}\right)}}\\
\end{array}
\end{array}
if l < 1.25000000000000001e-151Initial program 99.4%
Simplified99.4%
add-sqr-sqrt99.4%
hypot-1-def99.4%
sqrt-prod99.4%
unpow299.4%
sqrt-prod62.6%
add-sqr-sqrt99.4%
associate-/l*99.4%
unpow299.4%
unpow299.4%
hypot-def100.0%
Applied egg-rr100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
rem-exp-log100.0%
+-commutative100.0%
associate--l+100.0%
metadata-eval100.0%
+-commutative100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in l around 0 66.2%
if 1.25000000000000001e-151 < l Initial program 98.0%
Simplified98.0%
add-sqr-sqrt98.0%
hypot-1-def98.0%
sqrt-prod98.0%
unpow298.0%
sqrt-prod39.8%
add-sqr-sqrt98.0%
associate-/l*98.0%
unpow298.0%
unpow298.0%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in kx around 0 97.5%
Taylor expanded in ky around 0 90.2%
*-commutative90.2%
associate-/l*90.2%
associate-*l/90.2%
Simplified90.2%
un-div-inv90.2%
associate-/r/90.2%
*-commutative90.2%
*-commutative90.2%
*-un-lft-identity90.2%
times-frac90.2%
metadata-eval90.2%
Applied egg-rr90.2%
associate-*r/90.2%
Simplified90.2%
Final simplification75.4%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 1.02e+52) (sqrt 0.5) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 1.02e+52) {
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 <= 1.02d+52) 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 <= 1.02e+52) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 1.02e+52: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 1.02e+52) 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 <= 1.02e+52) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 1.02e+52], N[Sqrt[0.5], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 1.02 \cdot 10^{+52}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 1.02000000000000002e52Initial program 98.5%
Simplified98.5%
Taylor expanded in Om around 0 56.1%
unpow256.1%
unpow256.1%
hypot-def57.7%
Simplified57.7%
Taylor expanded in l around inf 64.7%
if 1.02000000000000002e52 < Om Initial program 100.0%
Simplified100.0%
add-sqr-sqrt100.0%
hypot-1-def100.0%
sqrt-prod100.0%
unpow2100.0%
sqrt-prod69.8%
add-sqr-sqrt100.0%
associate-/l*100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Applied egg-rr100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
rem-exp-log100.0%
+-commutative100.0%
associate--l+100.0%
metadata-eval100.0%
+-commutative100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in l around 0 86.9%
Final simplification69.3%
(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.8%
Simplified98.8%
add-sqr-sqrt98.8%
hypot-1-def98.8%
sqrt-prod98.8%
unpow298.8%
sqrt-prod53.9%
add-sqr-sqrt98.8%
associate-/l*98.8%
unpow298.8%
unpow298.8%
hypot-def100.0%
Applied egg-rr100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
rem-exp-log100.0%
+-commutative100.0%
associate--l+100.0%
metadata-eval100.0%
+-commutative100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in l around 0 61.1%
Final simplification61.1%
herbie shell --seed 2023336
(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))))))))))