
(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 10 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 100.0%
Simplified100.0%
add-sqr-sqrt100.0%
pow2100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (l Om kx ky) :precision binary64 (sqrt (+ 0.5 (log (exp (/ 0.5 (hypot 1.0 (* l (* (/ 2.0 Om) (sin ky))))))))))
double code(double l, double Om, double kx, double ky) {
return sqrt((0.5 + log(exp((0.5 / 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 + Math.log(Math.exp((0.5 / Math.hypot(1.0, (l * ((2.0 / Om) * Math.sin(ky)))))))));
}
def code(l, Om, kx, ky): return math.sqrt((0.5 + math.log(math.exp((0.5 / math.hypot(1.0, (l * ((2.0 / Om) * math.sin(ky)))))))))
function code(l, Om, kx, ky) return sqrt(Float64(0.5 + log(exp(Float64(0.5 / hypot(1.0, Float64(l * Float64(Float64(2.0 / Om) * sin(ky))))))))) end
function tmp = code(l, Om, kx, ky) tmp = sqrt((0.5 + log(exp((0.5 / hypot(1.0, (l * ((2.0 / Om) * sin(ky))))))))); end
code[l_, Om_, kx_, ky_] := N[Sqrt[N[(0.5 + N[Log[N[Exp[N[(0.5 / N[Sqrt[1.0 ^ 2 + N[(l * N[(N[(2.0 / Om), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $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, \ell \cdot \left(\frac{2}{Om} \cdot \sin ky\right)\right)}}\right)}
\end{array}
Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 78.0%
associate-*r/78.0%
associate-*l/77.5%
unpow277.5%
*-commutative77.5%
*-commutative77.5%
unpow277.5%
unpow277.5%
unswap-sqr83.0%
associate-/r*83.0%
metadata-eval83.0%
associate-*l/83.0%
associate-*r/83.0%
swap-sqr92.4%
associate-*r*92.4%
associate-*r*92.4%
Simplified92.4%
expm1-log1p-u91.9%
expm1-udef91.9%
un-div-inv91.9%
div-inv91.9%
clear-num91.9%
Applied egg-rr91.9%
expm1-def91.9%
expm1-log1p92.4%
associate-*r*92.4%
*-commutative92.4%
Simplified92.4%
add-log-exp92.4%
associate-*l*92.4%
Applied egg-rr92.4%
Final simplification92.4%
(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(Float64(2.0 / Om) * Float64(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[(N[(2.0 / Om), $MachinePrecision] * N[(l * 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}{Om} \cdot \left(\ell \cdot \sin ky\right)\right)}}
\end{array}
Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 78.0%
associate-*r/78.0%
associate-*l/77.5%
unpow277.5%
*-commutative77.5%
*-commutative77.5%
unpow277.5%
unpow277.5%
unswap-sqr83.0%
associate-/r*83.0%
metadata-eval83.0%
associate-*l/83.0%
associate-*r/83.0%
swap-sqr92.4%
associate-*r*92.4%
associate-*r*92.4%
Simplified92.4%
expm1-log1p-u91.9%
expm1-udef91.9%
un-div-inv91.9%
div-inv91.9%
clear-num91.9%
Applied egg-rr91.9%
expm1-def91.9%
expm1-log1p92.4%
associate-*r*92.4%
*-commutative92.4%
Simplified92.4%
Final simplification92.4%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 8500000000000.0) (sqrt 0.5) (+ 1.0 (* -0.5 (/ (* l ky) (/ (* Om (/ Om l)) ky))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 8500000000000.0) {
tmp = sqrt(0.5);
} else {
tmp = 1.0 + (-0.5 * ((l * ky) / ((Om * (Om / l)) / ky)));
}
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 <= 8500000000000.0d0) then
tmp = sqrt(0.5d0)
else
tmp = 1.0d0 + ((-0.5d0) * ((l * ky) / ((om * (om / l)) / ky)))
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 8500000000000.0) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0 + (-0.5 * ((l * ky) / ((Om * (Om / l)) / ky)));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 8500000000000.0: tmp = math.sqrt(0.5) else: tmp = 1.0 + (-0.5 * ((l * ky) / ((Om * (Om / l)) / ky))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 8500000000000.0) tmp = sqrt(0.5); else tmp = Float64(1.0 + Float64(-0.5 * Float64(Float64(l * ky) / Float64(Float64(Om * Float64(Om / l)) / ky)))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (Om <= 8500000000000.0) tmp = sqrt(0.5); else tmp = 1.0 + (-0.5 * ((l * ky) / ((Om * (Om / l)) / ky))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 8500000000000.0], N[Sqrt[0.5], $MachinePrecision], N[(1.0 + N[(-0.5 * N[(N[(l * ky), $MachinePrecision] / N[(N[(Om * N[(Om / l), $MachinePrecision]), $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 8500000000000:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \frac{\ell \cdot ky}{\frac{Om \cdot \frac{Om}{\ell}}{ky}}\\
\end{array}
\end{array}
if Om < 8.5e12Initial program 100.0%
Simplified100.0%
Taylor expanded in ky around 0 74.8%
associate-*r/74.8%
associate-*l/74.2%
unpow274.2%
*-commutative74.2%
*-commutative74.2%
unpow274.2%
unpow274.2%
unswap-sqr79.0%
associate-/r*79.0%
metadata-eval79.0%
associate-*l/79.0%
associate-*r/79.0%
swap-sqr92.9%
associate-*r*92.9%
associate-*r*92.9%
Simplified92.9%
Taylor expanded in l around inf 60.3%
if 8.5e12 < Om Initial program 99.9%
Simplified99.9%
Taylor expanded in kx around 0 83.4%
associate-*r/83.4%
associate-*l/83.4%
unpow283.4%
*-commutative83.4%
*-commutative83.4%
unpow283.4%
unpow283.4%
unswap-sqr89.8%
associate-/r*89.8%
metadata-eval89.8%
associate-*l/89.8%
associate-*r/89.8%
swap-sqr93.1%
associate-*r*93.1%
associate-*r*93.1%
Simplified93.1%
Taylor expanded in ky around 0 55.3%
unpow255.3%
times-frac55.3%
unpow255.3%
unpow255.3%
Simplified55.3%
*-commutative55.3%
associate-/l*59.6%
associate-/l*66.3%
frac-times71.7%
Applied egg-rr71.7%
associate-*r/75.0%
Applied egg-rr75.0%
Final simplification63.7%
(FPCore (l Om kx ky) :precision binary64 (if (<= Om 2e-19) (sqrt 0.5) 1.0))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (Om <= 2e-19) {
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 <= 2d-19) 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 <= 2e-19) {
tmp = Math.sqrt(0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if Om <= 2e-19: tmp = math.sqrt(0.5) else: tmp = 1.0 return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (Om <= 2e-19) 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 <= 2e-19) tmp = sqrt(0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[Om, 2e-19], N[Sqrt[0.5], $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Om \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if Om < 2e-19Initial program 100.0%
Simplified100.0%
Taylor expanded in ky around 0 74.3%
associate-*r/74.3%
associate-*l/73.7%
unpow273.7%
*-commutative73.7%
*-commutative73.7%
unpow273.7%
unpow273.7%
unswap-sqr78.6%
associate-/r*78.6%
metadata-eval78.6%
associate-*l/78.6%
associate-*r/78.6%
swap-sqr92.8%
associate-*r*92.8%
associate-*r*92.8%
Simplified92.8%
Taylor expanded in l around inf 60.3%
if 2e-19 < Om Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 84.5%
associate-*r/84.5%
associate-*l/84.5%
unpow284.5%
*-commutative84.5%
*-commutative84.5%
unpow284.5%
unpow284.5%
unswap-sqr90.4%
associate-/r*90.4%
metadata-eval90.4%
associate-*l/90.4%
associate-*r/90.4%
swap-sqr93.5%
associate-*r*93.5%
associate-*r*93.5%
Simplified93.5%
expm1-log1p-u93.4%
expm1-udef93.4%
un-div-inv93.4%
div-inv93.4%
clear-num93.4%
Applied egg-rr93.4%
expm1-def93.4%
expm1-log1p93.5%
associate-*r*93.5%
*-commutative93.5%
Simplified93.5%
Taylor expanded in l around 0 84.4%
Final simplification66.3%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 1e+61) (+ 1.0 (* -0.5 (/ ky (* (/ Om (* l l)) (/ Om ky))))) (+ 1.0 (* -0.5 (* (/ l (/ Om l)) (* ky (/ ky Om)))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1e+61) {
tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky))));
} else {
tmp = 1.0 + (-0.5 * ((l / (Om / l)) * (ky * (ky / Om))));
}
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+61) then
tmp = 1.0d0 + ((-0.5d0) * (ky / ((om / (l * l)) * (om / ky))))
else
tmp = 1.0d0 + ((-0.5d0) * ((l / (om / l)) * (ky * (ky / om))))
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1e+61) {
tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky))));
} else {
tmp = 1.0 + (-0.5 * ((l / (Om / l)) * (ky * (ky / Om))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1e+61: tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky)))) else: tmp = 1.0 + (-0.5 * ((l / (Om / l)) * (ky * (ky / Om)))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1e+61) tmp = Float64(1.0 + Float64(-0.5 * Float64(ky / Float64(Float64(Om / Float64(l * l)) * Float64(Om / ky))))); else tmp = Float64(1.0 + Float64(-0.5 * Float64(Float64(l / Float64(Om / l)) * Float64(ky * Float64(ky / Om))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 1e+61) tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky)))); else tmp = 1.0 + (-0.5 * ((l / (Om / l)) * (ky * (ky / Om)))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1e+61], N[(1.0 + N[(-0.5 * N[(ky / N[(N[(Om / N[(l * l), $MachinePrecision]), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(N[(l / N[(Om / l), $MachinePrecision]), $MachinePrecision] * N[(ky * N[(ky / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 10^{+61}:\\
\;\;\;\;1 + -0.5 \cdot \frac{ky}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(\frac{\ell}{\frac{Om}{\ell}} \cdot \left(ky \cdot \frac{ky}{Om}\right)\right)\\
\end{array}
\end{array}
if l < 9.99999999999999949e60Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 79.9%
associate-*r/79.9%
associate-*l/79.3%
unpow279.3%
*-commutative79.3%
*-commutative79.3%
unpow279.3%
unpow279.3%
unswap-sqr82.4%
associate-/r*82.4%
metadata-eval82.4%
associate-*l/82.4%
associate-*r/82.4%
swap-sqr92.5%
associate-*r*92.5%
associate-*r*92.5%
Simplified92.5%
Taylor expanded in ky around 0 44.5%
unpow244.5%
times-frac46.2%
unpow246.2%
unpow246.2%
Simplified46.2%
*-commutative46.2%
clear-num46.2%
associate-/l*49.1%
frac-times55.9%
*-un-lft-identity55.9%
Applied egg-rr55.9%
if 9.99999999999999949e60 < l Initial program 99.9%
Simplified99.9%
Taylor expanded in kx around 0 70.2%
associate-*r/70.2%
associate-*l/70.2%
unpow270.2%
*-commutative70.2%
*-commutative70.2%
unpow270.2%
unpow270.2%
unswap-sqr85.7%
associate-/r*85.7%
metadata-eval85.7%
associate-*l/85.7%
associate-*r/85.7%
swap-sqr91.8%
associate-*r*91.8%
associate-*r*91.8%
Simplified91.8%
Taylor expanded in ky around 0 9.1%
unpow29.1%
times-frac10.4%
unpow210.4%
unpow210.4%
Simplified10.4%
*-commutative10.4%
associate-/l*21.4%
associate-/l*21.5%
frac-times22.3%
Applied egg-rr22.3%
times-frac21.5%
associate-/r/21.5%
Applied egg-rr21.5%
Final simplification49.3%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 1.12e+156) (+ 1.0 (* -0.5 (/ ky (* (/ Om (* l l)) (/ Om ky))))) (+ 1.0 (* -0.5 (/ l (* (/ Om l) (/ Om (* ky ky))))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.12e+156) {
tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky))));
} else {
tmp = 1.0 + (-0.5 * (l / ((Om / l) * (Om / (ky * ky)))));
}
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 <= 1.12d+156) then
tmp = 1.0d0 + ((-0.5d0) * (ky / ((om / (l * l)) * (om / ky))))
else
tmp = 1.0d0 + ((-0.5d0) * (l / ((om / l) * (om / (ky * ky)))))
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 1.12e+156) {
tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky))));
} else {
tmp = 1.0 + (-0.5 * (l / ((Om / l) * (Om / (ky * ky)))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 1.12e+156: tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky)))) else: tmp = 1.0 + (-0.5 * (l / ((Om / l) * (Om / (ky * ky))))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 1.12e+156) tmp = Float64(1.0 + Float64(-0.5 * Float64(ky / Float64(Float64(Om / Float64(l * l)) * Float64(Om / ky))))); else tmp = Float64(1.0 + Float64(-0.5 * Float64(l / Float64(Float64(Om / l) * Float64(Om / Float64(ky * ky)))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 1.12e+156) tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky)))); else tmp = 1.0 + (-0.5 * (l / ((Om / l) * (Om / (ky * ky))))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 1.12e+156], N[(1.0 + N[(-0.5 * N[(ky / N[(N[(Om / N[(l * l), $MachinePrecision]), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(l / N[(N[(Om / l), $MachinePrecision] * N[(Om / N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.12 \cdot 10^{+156}:\\
\;\;\;\;1 + -0.5 \cdot \frac{ky}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \frac{\ell}{\frac{Om}{\ell} \cdot \frac{Om}{ky \cdot ky}}\\
\end{array}
\end{array}
if l < 1.12000000000000007e156Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 80.7%
associate-*r/80.7%
associate-*l/80.2%
unpow280.2%
*-commutative80.2%
*-commutative80.2%
unpow280.2%
unpow280.2%
unswap-sqr83.8%
associate-/r*83.8%
metadata-eval83.8%
associate-*l/83.8%
associate-*r/83.8%
swap-sqr92.9%
associate-*r*92.9%
associate-*r*92.9%
Simplified92.9%
Taylor expanded in ky around 0 41.9%
unpow241.9%
times-frac43.8%
unpow243.8%
unpow243.8%
Simplified43.8%
*-commutative43.8%
clear-num43.8%
associate-/l*46.4%
frac-times52.5%
*-un-lft-identity52.5%
Applied egg-rr52.5%
if 1.12000000000000007e156 < l Initial program 99.9%
Simplified99.9%
Taylor expanded in kx around 0 53.8%
associate-*r/53.8%
associate-*l/53.8%
unpow253.8%
*-commutative53.8%
*-commutative53.8%
unpow253.8%
unpow253.8%
unswap-sqr76.1%
associate-/r*76.1%
metadata-eval76.1%
associate-*l/76.1%
associate-*r/76.1%
swap-sqr87.6%
associate-*r*87.6%
associate-*r*87.6%
Simplified87.6%
Taylor expanded in ky around 0 0.4%
unpow20.4%
times-frac0.4%
unpow20.4%
unpow20.4%
Simplified0.4%
clear-num0.4%
associate-/l*17.3%
frac-times19.7%
*-un-lft-identity19.7%
Applied egg-rr19.7%
Final simplification49.1%
(FPCore (l Om kx ky) :precision binary64 (if (<= l 5e-66) (+ 1.0 (* -0.5 (/ ky (* (/ Om (* l l)) (/ Om ky))))) (+ 1.0 (* -0.5 (/ (* l ky) (/ (* Om Om) (* l ky)))))))
double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 5e-66) {
tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky))));
} else {
tmp = 1.0 + (-0.5 * ((l * ky) / ((Om * Om) / (l * ky))));
}
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 <= 5d-66) then
tmp = 1.0d0 + ((-0.5d0) * (ky / ((om / (l * l)) * (om / ky))))
else
tmp = 1.0d0 + ((-0.5d0) * ((l * ky) / ((om * om) / (l * ky))))
end if
code = tmp
end function
public static double code(double l, double Om, double kx, double ky) {
double tmp;
if (l <= 5e-66) {
tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky))));
} else {
tmp = 1.0 + (-0.5 * ((l * ky) / ((Om * Om) / (l * ky))));
}
return tmp;
}
def code(l, Om, kx, ky): tmp = 0 if l <= 5e-66: tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky)))) else: tmp = 1.0 + (-0.5 * ((l * ky) / ((Om * Om) / (l * ky)))) return tmp
function code(l, Om, kx, ky) tmp = 0.0 if (l <= 5e-66) tmp = Float64(1.0 + Float64(-0.5 * Float64(ky / Float64(Float64(Om / Float64(l * l)) * Float64(Om / ky))))); else tmp = Float64(1.0 + Float64(-0.5 * Float64(Float64(l * ky) / Float64(Float64(Om * Om) / Float64(l * ky))))); end return tmp end
function tmp_2 = code(l, Om, kx, ky) tmp = 0.0; if (l <= 5e-66) tmp = 1.0 + (-0.5 * (ky / ((Om / (l * l)) * (Om / ky)))); else tmp = 1.0 + (-0.5 * ((l * ky) / ((Om * Om) / (l * ky)))); end tmp_2 = tmp; end
code[l_, Om_, kx_, ky_] := If[LessEqual[l, 5e-66], N[(1.0 + N[(-0.5 * N[(ky / N[(N[(Om / N[(l * l), $MachinePrecision]), $MachinePrecision] * N[(Om / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(N[(l * ky), $MachinePrecision] / N[(N[(Om * Om), $MachinePrecision] / N[(l * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 5 \cdot 10^{-66}:\\
\;\;\;\;1 + -0.5 \cdot \frac{ky}{\frac{Om}{\ell \cdot \ell} \cdot \frac{Om}{ky}}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \frac{\ell \cdot ky}{\frac{Om \cdot Om}{\ell \cdot ky}}\\
\end{array}
\end{array}
if l < 4.99999999999999962e-66Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 76.9%
associate-*r/76.9%
associate-*l/76.2%
unpow276.2%
*-commutative76.2%
*-commutative76.2%
unpow276.2%
unpow276.2%
unswap-sqr79.8%
associate-/r*79.8%
metadata-eval79.8%
associate-*l/79.8%
associate-*r/79.8%
swap-sqr91.7%
associate-*r*91.7%
associate-*r*91.7%
Simplified91.7%
Taylor expanded in ky around 0 42.8%
unpow242.8%
times-frac44.8%
unpow244.8%
unpow244.8%
Simplified44.8%
*-commutative44.8%
clear-num44.8%
associate-/l*48.2%
frac-times56.2%
*-un-lft-identity56.2%
Applied egg-rr56.2%
if 4.99999999999999962e-66 < l Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 80.5%
associate-*r/80.5%
associate-*l/80.5%
unpow280.5%
*-commutative80.5%
*-commutative80.5%
unpow280.5%
unpow280.5%
unswap-sqr90.1%
associate-/r*90.1%
metadata-eval90.1%
associate-*l/90.1%
associate-*r/90.1%
swap-sqr93.9%
associate-*r*93.9%
associate-*r*93.9%
Simplified93.9%
Taylor expanded in ky around 0 26.3%
unpow226.3%
times-frac27.1%
unpow227.1%
unpow227.1%
Simplified27.1%
*-commutative27.1%
associate-/l*33.9%
associate-/l*33.9%
frac-times34.5%
Applied egg-rr34.5%
Taylor expanded in Om around 0 35.9%
*-commutative35.9%
unpow235.9%
Simplified35.9%
Final simplification49.9%
(FPCore (l Om kx ky) :precision binary64 (+ 1.0 (* -0.5 (* (/ ky (/ Om ky)) (/ (* l l) Om)))))
double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((ky / (Om / ky)) * ((l * l) / 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) * ((ky / (om / ky)) * ((l * l) / om)))
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((ky / (Om / ky)) * ((l * l) / Om)));
}
def code(l, Om, kx, ky): return 1.0 + (-0.5 * ((ky / (Om / ky)) * ((l * l) / Om)))
function code(l, Om, kx, ky) return Float64(1.0 + Float64(-0.5 * Float64(Float64(ky / Float64(Om / ky)) * Float64(Float64(l * l) / Om)))) end
function tmp = code(l, Om, kx, ky) tmp = 1.0 + (-0.5 * ((ky / (Om / ky)) * ((l * l) / Om))); end
code[l_, Om_, kx_, ky_] := N[(1.0 + N[(-0.5 * N[(N[(ky / N[(Om / ky), $MachinePrecision]), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + -0.5 \cdot \left(\frac{ky}{\frac{Om}{ky}} \cdot \frac{\ell \cdot \ell}{Om}\right)
\end{array}
Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 78.0%
associate-*r/78.0%
associate-*l/77.5%
unpow277.5%
*-commutative77.5%
*-commutative77.5%
unpow277.5%
unpow277.5%
unswap-sqr83.0%
associate-/r*83.0%
metadata-eval83.0%
associate-*l/83.0%
associate-*r/83.0%
swap-sqr92.4%
associate-*r*92.4%
associate-*r*92.4%
Simplified92.4%
Taylor expanded in ky around 0 37.7%
unpow237.7%
times-frac39.4%
unpow239.4%
unpow239.4%
Simplified39.4%
Taylor expanded in ky around 0 39.4%
unpow239.4%
associate-/l*41.7%
Simplified41.7%
Final simplification41.7%
(FPCore (l Om kx ky) :precision binary64 (+ 1.0 (* -0.5 (* (/ l (/ Om l)) (* ky (/ ky Om))))))
double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((l / (Om / l)) * (ky * (ky / 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 / (om / l)) * (ky * (ky / om))))
end function
public static double code(double l, double Om, double kx, double ky) {
return 1.0 + (-0.5 * ((l / (Om / l)) * (ky * (ky / Om))));
}
def code(l, Om, kx, ky): return 1.0 + (-0.5 * ((l / (Om / l)) * (ky * (ky / Om))))
function code(l, Om, kx, ky) return Float64(1.0 + Float64(-0.5 * Float64(Float64(l / Float64(Om / l)) * Float64(ky * Float64(ky / Om))))) end
function tmp = code(l, Om, kx, ky) tmp = 1.0 + (-0.5 * ((l / (Om / l)) * (ky * (ky / Om)))); end
code[l_, Om_, kx_, ky_] := N[(1.0 + N[(-0.5 * N[(N[(l / N[(Om / l), $MachinePrecision]), $MachinePrecision] * N[(ky * N[(ky / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + -0.5 \cdot \left(\frac{\ell}{\frac{Om}{\ell}} \cdot \left(ky \cdot \frac{ky}{Om}\right)\right)
\end{array}
Initial program 100.0%
Simplified100.0%
Taylor expanded in kx around 0 78.0%
associate-*r/78.0%
associate-*l/77.5%
unpow277.5%
*-commutative77.5%
*-commutative77.5%
unpow277.5%
unpow277.5%
unswap-sqr83.0%
associate-/r*83.0%
metadata-eval83.0%
associate-*l/83.0%
associate-*r/83.0%
swap-sqr92.4%
associate-*r*92.4%
associate-*r*92.4%
Simplified92.4%
Taylor expanded in ky around 0 37.7%
unpow237.7%
times-frac39.4%
unpow239.4%
unpow239.4%
Simplified39.4%
*-commutative39.4%
associate-/l*41.4%
associate-/l*43.8%
frac-times48.0%
Applied egg-rr48.0%
times-frac43.8%
associate-/r/43.8%
Applied egg-rr43.8%
Final simplification43.8%
herbie shell --seed 2023285
(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))))))))))