
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (/ (sin th) (/ (hypot (sin ky) (sin kx)) (sin ky))))
double code(double kx, double ky, double th) {
return sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / Math.sin(ky));
}
def code(kx, ky, th): return math.sin(th) / (math.hypot(math.sin(ky), math.sin(kx)) / math.sin(ky))
function code(kx, ky, th) return Float64(sin(th) / Float64(hypot(sin(ky), sin(kx)) / sin(ky))) end
function tmp = code(kx, ky, th) tmp = sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky)); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}
\end{array}
Initial program 93.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6492.9
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (* (/ -1.0 (hypot (sin kx) (sin ky))) (- ky)) (sin th)))
(t_2 (pow (sin ky) 2.0))
(t_3 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) t_2)))))
(if (<= t_3 -0.99)
(* (/ (sin ky) (sqrt (+ (* kx kx) t_2))) (sin th))
(if (<= t_3 -0.01)
(*
(* (sin ky) th)
(sqrt (pow (fma (- 1.0 (cos (* 2.0 kx))) 0.5 t_2) -1.0)))
(if (<= t_3 0.15)
t_1
(if (<= t_3 0.999999999981754)
(* (* (- th) (sin ky)) (/ -1.0 (hypot (sin ky) (sin kx))))
(if (<= t_3 1.0) (sin th) t_1)))))))
double code(double kx, double ky, double th) {
double t_1 = ((-1.0 / hypot(sin(kx), sin(ky))) * -ky) * sin(th);
double t_2 = pow(sin(ky), 2.0);
double t_3 = sin(ky) / sqrt((pow(sin(kx), 2.0) + t_2));
double tmp;
if (t_3 <= -0.99) {
tmp = (sin(ky) / sqrt(((kx * kx) + t_2))) * sin(th);
} else if (t_3 <= -0.01) {
tmp = (sin(ky) * th) * sqrt(pow(fma((1.0 - cos((2.0 * kx))), 0.5, t_2), -1.0));
} else if (t_3 <= 0.15) {
tmp = t_1;
} else if (t_3 <= 0.999999999981754) {
tmp = (-th * sin(ky)) * (-1.0 / hypot(sin(ky), sin(kx)));
} else if (t_3 <= 1.0) {
tmp = sin(th);
} else {
tmp = t_1;
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(Float64(Float64(-1.0 / hypot(sin(kx), sin(ky))) * Float64(-ky)) * sin(th)) t_2 = sin(ky) ^ 2.0 t_3 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + t_2))) tmp = 0.0 if (t_3 <= -0.99) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(kx * kx) + t_2))) * sin(th)); elseif (t_3 <= -0.01) tmp = Float64(Float64(sin(ky) * th) * sqrt((fma(Float64(1.0 - cos(Float64(2.0 * kx))), 0.5, t_2) ^ -1.0))); elseif (t_3 <= 0.15) tmp = t_1; elseif (t_3 <= 0.999999999981754) tmp = Float64(Float64(Float64(-th) * sin(ky)) * Float64(-1.0 / hypot(sin(ky), sin(kx)))); elseif (t_3 <= 1.0) tmp = sin(th); else tmp = t_1; end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[(-1.0 / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * (-ky)), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -0.99], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(kx * kx), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -0.01], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] * N[Sqrt[N[Power[N[(N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + t$95$2), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.15], t$95$1, If[LessEqual[t$95$3, 0.999999999981754], N[(N[((-th) * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 1.0], N[Sin[th], $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\frac{-1}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \left(-ky\right)\right) \cdot \sin th\\
t_2 := {\sin ky}^{2}\\
t_3 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + t\_2}}\\
\mathbf{if}\;t\_3 \leq -0.99:\\
\;\;\;\;\frac{\sin ky}{\sqrt{kx \cdot kx + t\_2}} \cdot \sin th\\
\mathbf{elif}\;t\_3 \leq -0.01:\\
\;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{{\left(\mathsf{fma}\left(1 - \cos \left(2 \cdot kx\right), 0.5, t\_2\right)\right)}^{-1}}\\
\mathbf{elif}\;t\_3 \leq 0.15:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_3 \leq 0.999999999981754:\\
\;\;\;\;\left(\left(-th\right) \cdot \sin ky\right) \cdot \frac{-1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{elif}\;t\_3 \leq 1:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.98999999999999999Initial program 81.9%
Taylor expanded in kx around 0
unpow2N/A
lower-*.f6477.3
Applied rewrites77.3%
if -0.98999999999999999 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.0100000000000000002Initial program 99.3%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
cos-diffN/A
cos-sin-sumN/A
lower--.f64N/A
lower-cos.f64N/A
count-2N/A
lower-*.f6499.3
Applied rewrites99.3%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f6445.2
Applied rewrites45.2%
if -0.0100000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.149999999999999994 or 1 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6489.4
lift-sqrt.f64N/A
Applied rewrites97.1%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6495.1
Applied rewrites95.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites97.7%
Taylor expanded in ky around 0
mul-1-negN/A
lower-neg.f6497.7
Applied rewrites97.7%
if 0.149999999999999994 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99999999998175404Initial program 97.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6497.5
lift-sqrt.f64N/A
Applied rewrites99.2%
Taylor expanded in th around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f6439.3
Applied rewrites39.3%
if 0.99999999998175404 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 1Initial program 100.0%
Taylor expanded in kx around 0
lower-sin.f64100.0
Applied rewrites100.0%
Final simplification81.1%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (* (/ -1.0 (hypot (sin kx) (sin ky))) (- ky)) (sin th)))
(t_2 (* (* (- th) (sin ky)) (/ -1.0 (hypot (sin ky) (sin kx)))))
(t_3 (pow (sin ky) 2.0))
(t_4 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) t_3)))))
(if (<= t_4 -0.99)
(* (/ (sin ky) (sqrt (+ (* kx kx) t_3))) (sin th))
(if (<= t_4 -0.01)
t_2
(if (<= t_4 0.15)
t_1
(if (<= t_4 0.999999999981754)
t_2
(if (<= t_4 1.0) (sin th) t_1)))))))
double code(double kx, double ky, double th) {
double t_1 = ((-1.0 / hypot(sin(kx), sin(ky))) * -ky) * sin(th);
double t_2 = (-th * sin(ky)) * (-1.0 / hypot(sin(ky), sin(kx)));
double t_3 = pow(sin(ky), 2.0);
double t_4 = sin(ky) / sqrt((pow(sin(kx), 2.0) + t_3));
double tmp;
if (t_4 <= -0.99) {
tmp = (sin(ky) / sqrt(((kx * kx) + t_3))) * sin(th);
} else if (t_4 <= -0.01) {
tmp = t_2;
} else if (t_4 <= 0.15) {
tmp = t_1;
} else if (t_4 <= 0.999999999981754) {
tmp = t_2;
} else if (t_4 <= 1.0) {
tmp = sin(th);
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = ((-1.0 / Math.hypot(Math.sin(kx), Math.sin(ky))) * -ky) * Math.sin(th);
double t_2 = (-th * Math.sin(ky)) * (-1.0 / Math.hypot(Math.sin(ky), Math.sin(kx)));
double t_3 = Math.pow(Math.sin(ky), 2.0);
double t_4 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + t_3));
double tmp;
if (t_4 <= -0.99) {
tmp = (Math.sin(ky) / Math.sqrt(((kx * kx) + t_3))) * Math.sin(th);
} else if (t_4 <= -0.01) {
tmp = t_2;
} else if (t_4 <= 0.15) {
tmp = t_1;
} else if (t_4 <= 0.999999999981754) {
tmp = t_2;
} else if (t_4 <= 1.0) {
tmp = Math.sin(th);
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = ((-1.0 / math.hypot(math.sin(kx), math.sin(ky))) * -ky) * math.sin(th) t_2 = (-th * math.sin(ky)) * (-1.0 / math.hypot(math.sin(ky), math.sin(kx))) t_3 = math.pow(math.sin(ky), 2.0) t_4 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + t_3)) tmp = 0 if t_4 <= -0.99: tmp = (math.sin(ky) / math.sqrt(((kx * kx) + t_3))) * math.sin(th) elif t_4 <= -0.01: tmp = t_2 elif t_4 <= 0.15: tmp = t_1 elif t_4 <= 0.999999999981754: tmp = t_2 elif t_4 <= 1.0: tmp = math.sin(th) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(Float64(Float64(-1.0 / hypot(sin(kx), sin(ky))) * Float64(-ky)) * sin(th)) t_2 = Float64(Float64(Float64(-th) * sin(ky)) * Float64(-1.0 / hypot(sin(ky), sin(kx)))) t_3 = sin(ky) ^ 2.0 t_4 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + t_3))) tmp = 0.0 if (t_4 <= -0.99) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(kx * kx) + t_3))) * sin(th)); elseif (t_4 <= -0.01) tmp = t_2; elseif (t_4 <= 0.15) tmp = t_1; elseif (t_4 <= 0.999999999981754) tmp = t_2; elseif (t_4 <= 1.0) tmp = sin(th); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = ((-1.0 / hypot(sin(kx), sin(ky))) * -ky) * sin(th); t_2 = (-th * sin(ky)) * (-1.0 / hypot(sin(ky), sin(kx))); t_3 = sin(ky) ^ 2.0; t_4 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + t_3)); tmp = 0.0; if (t_4 <= -0.99) tmp = (sin(ky) / sqrt(((kx * kx) + t_3))) * sin(th); elseif (t_4 <= -0.01) tmp = t_2; elseif (t_4 <= 0.15) tmp = t_1; elseif (t_4 <= 0.999999999981754) tmp = t_2; elseif (t_4 <= 1.0) tmp = sin(th); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[(-1.0 / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * (-ky)), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[((-th) * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -0.99], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(kx * kx), $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -0.01], t$95$2, If[LessEqual[t$95$4, 0.15], t$95$1, If[LessEqual[t$95$4, 0.999999999981754], t$95$2, If[LessEqual[t$95$4, 1.0], N[Sin[th], $MachinePrecision], t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\frac{-1}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \left(-ky\right)\right) \cdot \sin th\\
t_2 := \left(\left(-th\right) \cdot \sin ky\right) \cdot \frac{-1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
t_3 := {\sin ky}^{2}\\
t_4 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + t\_3}}\\
\mathbf{if}\;t\_4 \leq -0.99:\\
\;\;\;\;\frac{\sin ky}{\sqrt{kx \cdot kx + t\_3}} \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq -0.01:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_4 \leq 0.15:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_4 \leq 0.999999999981754:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_4 \leq 1:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.98999999999999999Initial program 81.9%
Taylor expanded in kx around 0
unpow2N/A
lower-*.f6477.3
Applied rewrites77.3%
if -0.98999999999999999 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.0100000000000000002 or 0.149999999999999994 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99999999998175404Initial program 98.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6498.3
lift-sqrt.f64N/A
Applied rewrites99.1%
Taylor expanded in th around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f6441.9
Applied rewrites41.9%
if -0.0100000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.149999999999999994 or 1 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6489.4
lift-sqrt.f64N/A
Applied rewrites97.1%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6495.1
Applied rewrites95.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites97.7%
Taylor expanded in ky around 0
mul-1-negN/A
lower-neg.f6497.7
Applied rewrites97.7%
if 0.99999999998175404 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 1Initial program 100.0%
Taylor expanded in kx around 0
lower-sin.f64100.0
Applied rewrites100.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (* (- th) (sin ky)) (/ -1.0 (hypot (sin ky) (sin kx)))))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
(t_3 (* (* (/ -1.0 (hypot (sin kx) (sin ky))) (- ky)) (sin th))))
(if (<= t_2 -0.01)
t_1
(if (<= t_2 0.15)
t_3
(if (<= t_2 0.999999999981754) t_1 (if (<= t_2 1.0) (sin th) t_3))))))
double code(double kx, double ky, double th) {
double t_1 = (-th * sin(ky)) * (-1.0 / hypot(sin(ky), sin(kx)));
double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double t_3 = ((-1.0 / hypot(sin(kx), sin(ky))) * -ky) * sin(th);
double tmp;
if (t_2 <= -0.01) {
tmp = t_1;
} else if (t_2 <= 0.15) {
tmp = t_3;
} else if (t_2 <= 0.999999999981754) {
tmp = t_1;
} else if (t_2 <= 1.0) {
tmp = sin(th);
} else {
tmp = t_3;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = (-th * Math.sin(ky)) * (-1.0 / Math.hypot(Math.sin(ky), Math.sin(kx)));
double t_2 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
double t_3 = ((-1.0 / Math.hypot(Math.sin(kx), Math.sin(ky))) * -ky) * Math.sin(th);
double tmp;
if (t_2 <= -0.01) {
tmp = t_1;
} else if (t_2 <= 0.15) {
tmp = t_3;
} else if (t_2 <= 0.999999999981754) {
tmp = t_1;
} else if (t_2 <= 1.0) {
tmp = Math.sin(th);
} else {
tmp = t_3;
}
return tmp;
}
def code(kx, ky, th): t_1 = (-th * math.sin(ky)) * (-1.0 / math.hypot(math.sin(ky), math.sin(kx))) t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))) t_3 = ((-1.0 / math.hypot(math.sin(kx), math.sin(ky))) * -ky) * math.sin(th) tmp = 0 if t_2 <= -0.01: tmp = t_1 elif t_2 <= 0.15: tmp = t_3 elif t_2 <= 0.999999999981754: tmp = t_1 elif t_2 <= 1.0: tmp = math.sin(th) else: tmp = t_3 return tmp
function code(kx, ky, th) t_1 = Float64(Float64(Float64(-th) * sin(ky)) * Float64(-1.0 / hypot(sin(ky), sin(kx)))) t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) t_3 = Float64(Float64(Float64(-1.0 / hypot(sin(kx), sin(ky))) * Float64(-ky)) * sin(th)) tmp = 0.0 if (t_2 <= -0.01) tmp = t_1; elseif (t_2 <= 0.15) tmp = t_3; elseif (t_2 <= 0.999999999981754) tmp = t_1; elseif (t_2 <= 1.0) tmp = sin(th); else tmp = t_3; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (-th * sin(ky)) * (-1.0 / hypot(sin(ky), sin(kx))); t_2 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); t_3 = ((-1.0 / hypot(sin(kx), sin(ky))) * -ky) * sin(th); tmp = 0.0; if (t_2 <= -0.01) tmp = t_1; elseif (t_2 <= 0.15) tmp = t_3; elseif (t_2 <= 0.999999999981754) tmp = t_1; elseif (t_2 <= 1.0) tmp = sin(th); else tmp = t_3; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[((-th) * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(-1.0 / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * (-ky)), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.01], t$95$1, If[LessEqual[t$95$2, 0.15], t$95$3, If[LessEqual[t$95$2, 0.999999999981754], t$95$1, If[LessEqual[t$95$2, 1.0], N[Sin[th], $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(-th\right) \cdot \sin ky\right) \cdot \frac{-1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
t_3 := \left(\frac{-1}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \left(-ky\right)\right) \cdot \sin th\\
\mathbf{if}\;t\_2 \leq -0.01:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 0.15:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 0.999999999981754:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 1:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.0100000000000000002 or 0.149999999999999994 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99999999998175404Initial program 90.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6489.2
lift-sqrt.f64N/A
Applied rewrites95.1%
Taylor expanded in th around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f6440.2
Applied rewrites40.2%
if -0.0100000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.149999999999999994 or 1 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6489.4
lift-sqrt.f64N/A
Applied rewrites97.1%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6495.1
Applied rewrites95.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites97.7%
Taylor expanded in ky around 0
mul-1-negN/A
lower-neg.f6497.7
Applied rewrites97.7%
if 0.99999999998175404 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 1Initial program 100.0%
Taylor expanded in kx around 0
lower-sin.f64100.0
Applied rewrites100.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (* (- th) (sin ky)) (/ -1.0 (hypot (sin ky) (sin kx)))))
(t_2 (pow (sin kx) 2.0))
(t_3 (/ (sin ky) (sqrt (+ t_2 (pow (sin ky) 2.0))))))
(if (<= t_3 -0.01)
t_1
(if (<= t_3 5e-8)
(*
(/
(*
(fma
(fma 0.008333333333333333 (* ky ky) -0.16666666666666666)
(* ky ky)
1.0)
ky)
(sqrt (+ t_2 (* ky ky))))
(sin th))
(if (<= t_3 0.999999999981754) t_1 (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = (-th * sin(ky)) * (-1.0 / hypot(sin(ky), sin(kx)));
double t_2 = pow(sin(kx), 2.0);
double t_3 = sin(ky) / sqrt((t_2 + pow(sin(ky), 2.0)));
double tmp;
if (t_3 <= -0.01) {
tmp = t_1;
} else if (t_3 <= 5e-8) {
tmp = ((fma(fma(0.008333333333333333, (ky * ky), -0.16666666666666666), (ky * ky), 1.0) * ky) / sqrt((t_2 + (ky * ky)))) * sin(th);
} else if (t_3 <= 0.999999999981754) {
tmp = t_1;
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(Float64(Float64(-th) * sin(ky)) * Float64(-1.0 / hypot(sin(ky), sin(kx)))) t_2 = sin(kx) ^ 2.0 t_3 = Float64(sin(ky) / sqrt(Float64(t_2 + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_3 <= -0.01) tmp = t_1; elseif (t_3 <= 5e-8) tmp = Float64(Float64(Float64(fma(fma(0.008333333333333333, Float64(ky * ky), -0.16666666666666666), Float64(ky * ky), 1.0) * ky) / sqrt(Float64(t_2 + Float64(ky * ky)))) * sin(th)); elseif (t_3 <= 0.999999999981754) tmp = t_1; else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[((-th) * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$2 + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -0.01], t$95$1, If[LessEqual[t$95$3, 5e-8], N[(N[(N[(N[(N[(0.008333333333333333 * N[(ky * ky), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[(t$95$2 + N[(ky * ky), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.999999999981754], t$95$1, N[Sin[th], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(-th\right) \cdot \sin ky\right) \cdot \frac{-1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
t_2 := {\sin kx}^{2}\\
t_3 := \frac{\sin ky}{\sqrt{t\_2 + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_3 \leq -0.01:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, ky \cdot ky, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot ky}{\sqrt{t\_2 + ky \cdot ky}} \cdot \sin th\\
\mathbf{elif}\;t\_3 \leq 0.999999999981754:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.0100000000000000002 or 4.9999999999999998e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99999999998175404Initial program 91.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6489.4
lift-sqrt.f64N/A
Applied rewrites95.2%
Taylor expanded in th around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f6440.4
Applied rewrites40.4%
if -0.0100000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 4.9999999999999998e-8Initial program 98.8%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6498.8
Applied rewrites98.8%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.8
Applied rewrites98.8%
if 0.99999999998175404 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 87.6%
Taylor expanded in kx around 0
lower-sin.f6496.6
Applied rewrites96.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin kx) 2.0))
(t_2 (/ (sin ky) (sqrt (+ t_1 (pow (sin ky) 2.0))))))
(if (<= t_2 -0.01)
(* (/ (sin ky) (* (sqrt 0.5) (sqrt (- 1.0 (cos (* 2.0 kx)))))) (sin th))
(if (<= t_2 5e-8)
(*
(/
(*
(fma
(fma 0.008333333333333333 (* ky ky) -0.16666666666666666)
(* ky ky)
1.0)
ky)
(sqrt (+ t_1 (* ky ky))))
(sin th))
(sin th)))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(kx), 2.0);
double t_2 = sin(ky) / sqrt((t_1 + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= -0.01) {
tmp = (sin(ky) / (sqrt(0.5) * sqrt((1.0 - cos((2.0 * kx)))))) * sin(th);
} else if (t_2 <= 5e-8) {
tmp = ((fma(fma(0.008333333333333333, (ky * ky), -0.16666666666666666), (ky * ky), 1.0) * ky) / sqrt((t_1 + (ky * ky)))) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = sin(kx) ^ 2.0 t_2 = Float64(sin(ky) / sqrt(Float64(t_1 + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.01) tmp = Float64(Float64(sin(ky) / Float64(sqrt(0.5) * sqrt(Float64(1.0 - cos(Float64(2.0 * kx)))))) * sin(th)); elseif (t_2 <= 5e-8) tmp = Float64(Float64(Float64(fma(fma(0.008333333333333333, Float64(ky * ky), -0.16666666666666666), Float64(ky * ky), 1.0) * ky) / sqrt(Float64(t_1 + Float64(ky * ky)))) * sin(th)); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.01], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[0.5], $MachinePrecision] * N[Sqrt[N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-8], N[(N[(N[(N[(N[(0.008333333333333333 * N[(ky * ky), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(ky * ky), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin kx}^{2}\\
t_2 := \frac{\sin ky}{\sqrt{t\_1 + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.01:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, ky \cdot ky, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot ky}{\sqrt{t\_1 + ky \cdot ky}} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.0100000000000000002Initial program 88.2%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
cos-diffN/A
cos-sin-sumN/A
lower--.f64N/A
lower-cos.f64N/A
count-2N/A
lower-*.f6488.2
Applied rewrites88.2%
Taylor expanded in ky around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f649.8
Applied rewrites9.8%
if -0.0100000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 4.9999999999999998e-8Initial program 98.8%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6498.8
Applied rewrites98.8%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.8
Applied rewrites98.8%
if 4.9999999999999998e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.5%
Taylor expanded in kx around 0
lower-sin.f6469.6
Applied rewrites69.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin kx) 2.0))
(t_2 (/ (sin ky) (sqrt (+ t_1 (pow (sin ky) 2.0))))))
(if (<= t_2 -0.01)
(* (/ (sin ky) (* (sqrt 0.5) (sqrt (- 1.0 (cos (* 2.0 kx)))))) (sin th))
(if (<= t_2 5e-8)
(*
(/
(* (fma -0.16666666666666666 (* ky ky) 1.0) ky)
(sqrt (+ t_1 (* ky ky))))
(sin th))
(sin th)))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(kx), 2.0);
double t_2 = sin(ky) / sqrt((t_1 + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= -0.01) {
tmp = (sin(ky) / (sqrt(0.5) * sqrt((1.0 - cos((2.0 * kx)))))) * sin(th);
} else if (t_2 <= 5e-8) {
tmp = ((fma(-0.16666666666666666, (ky * ky), 1.0) * ky) / sqrt((t_1 + (ky * ky)))) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = sin(kx) ^ 2.0 t_2 = Float64(sin(ky) / sqrt(Float64(t_1 + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.01) tmp = Float64(Float64(sin(ky) / Float64(sqrt(0.5) * sqrt(Float64(1.0 - cos(Float64(2.0 * kx)))))) * sin(th)); elseif (t_2 <= 5e-8) tmp = Float64(Float64(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky) / sqrt(Float64(t_1 + Float64(ky * ky)))) * sin(th)); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.01], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[0.5], $MachinePrecision] * N[Sqrt[N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-8], N[(N[(N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(ky * ky), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin kx}^{2}\\
t_2 := \frac{\sin ky}{\sqrt{t\_1 + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.01:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky}{\sqrt{t\_1 + ky \cdot ky}} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.0100000000000000002Initial program 88.2%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
cos-diffN/A
cos-sin-sumN/A
lower--.f64N/A
lower-cos.f64N/A
count-2N/A
lower-*.f6488.2
Applied rewrites88.2%
Taylor expanded in ky around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f649.8
Applied rewrites9.8%
if -0.0100000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 4.9999999999999998e-8Initial program 98.8%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6498.8
Applied rewrites98.8%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.8
Applied rewrites98.8%
if 4.9999999999999998e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.5%
Taylor expanded in kx around 0
lower-sin.f6469.6
Applied rewrites69.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_1 2e-184)
(* (/ (sin ky) (* (sqrt 0.5) (sqrt (- 1.0 (cos (* 2.0 kx)))))) (sin th))
(if (<= t_1 5e-8) (* (/ ky (sin kx)) (sin th)) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_1 <= 2e-184) {
tmp = (sin(ky) / (sqrt(0.5) * sqrt((1.0 - cos((2.0 * kx)))))) * sin(th);
} else if (t_1 <= 5e-8) {
tmp = (ky / sin(kx)) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
if (t_1 <= 2d-184) then
tmp = (sin(ky) / (sqrt(0.5d0) * sqrt((1.0d0 - cos((2.0d0 * kx)))))) * sin(th)
else if (t_1 <= 5d-8) then
tmp = (ky / sin(kx)) * sin(th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
double tmp;
if (t_1 <= 2e-184) {
tmp = (Math.sin(ky) / (Math.sqrt(0.5) * Math.sqrt((1.0 - Math.cos((2.0 * kx)))))) * Math.sin(th);
} else if (t_1 <= 5e-8) {
tmp = (ky / Math.sin(kx)) * Math.sin(th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))) tmp = 0 if t_1 <= 2e-184: tmp = (math.sin(ky) / (math.sqrt(0.5) * math.sqrt((1.0 - math.cos((2.0 * kx)))))) * math.sin(th) elif t_1 <= 5e-8: tmp = (ky / math.sin(kx)) * math.sin(th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_1 <= 2e-184) tmp = Float64(Float64(sin(ky) / Float64(sqrt(0.5) * sqrt(Float64(1.0 - cos(Float64(2.0 * kx)))))) * sin(th)); elseif (t_1 <= 5e-8) tmp = Float64(Float64(ky / sin(kx)) * sin(th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); tmp = 0.0; if (t_1 <= 2e-184) tmp = (sin(ky) / (sqrt(0.5) * sqrt((1.0 - cos((2.0 * kx)))))) * sin(th); elseif (t_1 <= 5e-8) tmp = (ky / sin(kx)) * sin(th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e-184], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[0.5], $MachinePrecision] * N[Sqrt[N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-8], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-184}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2.0000000000000001e-184Initial program 92.8%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
cos-diffN/A
cos-sin-sumN/A
lower--.f64N/A
lower-cos.f64N/A
count-2N/A
lower-*.f6480.9
Applied rewrites80.9%
Taylor expanded in ky around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6434.0
Applied rewrites34.0%
if 2.0000000000000001e-184 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 4.9999999999999998e-8Initial program 97.4%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6454.1
Applied rewrites54.1%
if 4.9999999999999998e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.5%
Taylor expanded in kx around 0
lower-sin.f6469.6
Applied rewrites69.6%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 5e-8) (* (/ (sin ky) (sin kx)) (sin th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 5e-8) {
tmp = (sin(ky) / sin(kx)) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 5d-8) then
tmp = (sin(ky) / sin(kx)) * sin(th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 5e-8) {
tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 5e-8: tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 5e-8) tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 5e-8) tmp = (sin(ky) / sin(kx)) * sin(th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 5e-8], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 4.9999999999999998e-8Initial program 93.8%
Taylor expanded in ky around 0
lower-sin.f6438.3
Applied rewrites38.3%
if 4.9999999999999998e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.5%
Taylor expanded in kx around 0
lower-sin.f6469.6
Applied rewrites69.6%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 5e-8) (* (/ ky (sin kx)) (sin th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 5e-8) {
tmp = (ky / sin(kx)) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 5d-8) then
tmp = (ky / sin(kx)) * sin(th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 5e-8) {
tmp = (ky / Math.sin(kx)) * Math.sin(th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 5e-8: tmp = (ky / math.sin(kx)) * math.sin(th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 5e-8) tmp = Float64(Float64(ky / sin(kx)) * sin(th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 5e-8) tmp = (ky / sin(kx)) * sin(th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 5e-8], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 4.9999999999999998e-8Initial program 93.8%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6436.5
Applied rewrites36.5%
if 4.9999999999999998e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.5%
Taylor expanded in kx around 0
lower-sin.f6469.6
Applied rewrites69.6%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 5e-62) (/ (sin th) (fma (/ 0.5 (* ky ky)) (* kx kx) 1.0)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 5e-62) {
tmp = sin(th) / fma((0.5 / (ky * ky)), (kx * kx), 1.0);
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 5e-62) tmp = Float64(sin(th) / fma(Float64(0.5 / Float64(ky * ky)), Float64(kx * kx), 1.0)); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 5e-62], N[(N[Sin[th], $MachinePrecision] / N[(N[(0.5 / N[(ky * ky), $MachinePrecision]), $MachinePrecision] * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 5 \cdot 10^{-62}:\\
\;\;\;\;\frac{\sin th}{\mathsf{fma}\left(\frac{0.5}{ky \cdot ky}, kx \cdot kx, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 5.0000000000000002e-62Initial program 93.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6493.5
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
Taylor expanded in kx around 0
+-commutativeN/A
associate-*r/N/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
unpow2N/A
lower-*.f6418.0
Applied rewrites18.0%
Taylor expanded in ky around 0
Applied rewrites17.8%
if 5.0000000000000002e-62 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 92.1%
Taylor expanded in kx around 0
lower-sin.f6463.4
Applied rewrites63.4%
(FPCore (kx ky th)
:precision binary64
(if (<=
(*
(/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))
(sin th))
1e-302)
(* (* (* -0.16666666666666666 th) th) th)
(*
(fma
(fma (* th th) 0.008333333333333333 -0.16666666666666666)
(* th th)
1.0)
th)))
double code(double kx, double ky, double th) {
double tmp;
if (((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th)) <= 1e-302) {
tmp = ((-0.16666666666666666 * th) * th) * th;
} else {
tmp = fma(fma((th * th), 0.008333333333333333, -0.16666666666666666), (th * th), 1.0) * th;
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) <= 1e-302) tmp = Float64(Float64(Float64(-0.16666666666666666 * th) * th) * th); else tmp = Float64(fma(fma(Float64(th * th), 0.008333333333333333, -0.16666666666666666), Float64(th * th), 1.0) * th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], 1e-302], N[(N[(N[(-0.16666666666666666 * th), $MachinePrecision] * th), $MachinePrecision] * th), $MachinePrecision], N[(N[(N[(N[(th * th), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(th * th), $MachinePrecision] + 1.0), $MachinePrecision] * th), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \leq 10^{-302}:\\
\;\;\;\;\left(\left(-0.16666666666666666 \cdot th\right) \cdot th\right) \cdot th\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, 0.008333333333333333, -0.16666666666666666\right), th \cdot th, 1\right) \cdot th\\
\end{array}
\end{array}
if (*.f64 (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) (sin.f64 th)) < 9.9999999999999996e-303Initial program 94.0%
Taylor expanded in kx around 0
lower-sin.f6425.5
Applied rewrites25.5%
Taylor expanded in th around 0
Applied rewrites13.6%
Taylor expanded in th around inf
Applied rewrites19.1%
Applied rewrites19.1%
if 9.9999999999999996e-303 < (*.f64 (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) (sin.f64 th)) Initial program 91.8%
Taylor expanded in kx around 0
lower-sin.f6428.0
Applied rewrites28.0%
Taylor expanded in th around 0
Applied rewrites14.6%
(FPCore (kx ky th)
:precision binary64
(if (<=
(*
(/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))
(sin th))
1e-302)
(* (* (* -0.16666666666666666 th) th) th)
(* (fma (* -0.16666666666666666 th) th 1.0) th)))
double code(double kx, double ky, double th) {
double tmp;
if (((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th)) <= 1e-302) {
tmp = ((-0.16666666666666666 * th) * th) * th;
} else {
tmp = fma((-0.16666666666666666 * th), th, 1.0) * th;
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) <= 1e-302) tmp = Float64(Float64(Float64(-0.16666666666666666 * th) * th) * th); else tmp = Float64(fma(Float64(-0.16666666666666666 * th), th, 1.0) * th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], 1e-302], N[(N[(N[(-0.16666666666666666 * th), $MachinePrecision] * th), $MachinePrecision] * th), $MachinePrecision], N[(N[(N[(-0.16666666666666666 * th), $MachinePrecision] * th + 1.0), $MachinePrecision] * th), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \leq 10^{-302}:\\
\;\;\;\;\left(\left(-0.16666666666666666 \cdot th\right) \cdot th\right) \cdot th\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666 \cdot th, th, 1\right) \cdot th\\
\end{array}
\end{array}
if (*.f64 (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) (sin.f64 th)) < 9.9999999999999996e-303Initial program 94.0%
Taylor expanded in kx around 0
lower-sin.f6425.5
Applied rewrites25.5%
Taylor expanded in th around 0
Applied rewrites13.6%
Taylor expanded in th around inf
Applied rewrites19.1%
Applied rewrites19.1%
if 9.9999999999999996e-303 < (*.f64 (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) (sin.f64 th)) Initial program 91.8%
Taylor expanded in kx around 0
lower-sin.f6428.0
Applied rewrites28.0%
Taylor expanded in th around 0
Applied rewrites14.9%
Applied rewrites14.9%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 5e-62) (* (* (* -0.16666666666666666 th) th) th) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 5e-62) {
tmp = ((-0.16666666666666666 * th) * th) * th;
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 5d-62) then
tmp = (((-0.16666666666666666d0) * th) * th) * th
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 5e-62) {
tmp = ((-0.16666666666666666 * th) * th) * th;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 5e-62: tmp = ((-0.16666666666666666 * th) * th) * th else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 5e-62) tmp = Float64(Float64(Float64(-0.16666666666666666 * th) * th) * th); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 5e-62) tmp = ((-0.16666666666666666 * th) * th) * th; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 5e-62], N[(N[(N[(-0.16666666666666666 * th), $MachinePrecision] * th), $MachinePrecision] * th), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 5 \cdot 10^{-62}:\\
\;\;\;\;\left(\left(-0.16666666666666666 \cdot th\right) \cdot th\right) \cdot th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 5.0000000000000002e-62Initial program 93.5%
Taylor expanded in kx around 0
lower-sin.f643.5
Applied rewrites3.5%
Taylor expanded in th around 0
Applied rewrites3.4%
Taylor expanded in th around inf
Applied rewrites16.9%
Applied rewrites16.9%
if 5.0000000000000002e-62 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 92.1%
Taylor expanded in kx around 0
lower-sin.f6463.4
Applied rewrites63.4%
(FPCore (kx ky th) :precision binary64 (* (/ (sin th) (hypot (sin ky) (sin kx))) (sin ky)))
double code(double kx, double ky, double th) {
return (sin(th) / hypot(sin(ky), sin(kx))) * sin(ky);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(ky);
}
def code(kx, ky, th): return (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(ky)
function code(kx, ky, th) return Float64(Float64(sin(th) / hypot(sin(ky), sin(kx))) * sin(ky)) end
function tmp = code(kx, ky, th) tmp = (sin(th) / hypot(sin(ky), sin(kx))) * sin(ky); end
code[kx_, ky_, th_] := N[(N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin ky
\end{array}
Initial program 93.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6492.9
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 5.4e-6)
(* (* (/ -1.0 (hypot (sin kx) (sin ky))) (- ky)) (sin th))
(*
(/
(sin ky)
(/
(sqrt
(fma (- 1.0 (cos (* ky 2.0))) 2.0 (* 2.0 (- 1.0 (cos (* 2.0 kx))))))
2.0))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 5.4e-6) {
tmp = ((-1.0 / hypot(sin(kx), sin(ky))) * -ky) * sin(th);
} else {
tmp = (sin(ky) / (sqrt(fma((1.0 - cos((ky * 2.0))), 2.0, (2.0 * (1.0 - cos((2.0 * kx)))))) / 2.0)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (ky <= 5.4e-6) tmp = Float64(Float64(Float64(-1.0 / hypot(sin(kx), sin(ky))) * Float64(-ky)) * sin(th)); else tmp = Float64(Float64(sin(ky) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(ky * 2.0))), 2.0, Float64(2.0 * Float64(1.0 - cos(Float64(2.0 * kx)))))) / 2.0)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[ky, 5.4e-6], N[(N[(N[(-1.0 / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * (-ky)), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2.0 + N[(2.0 * N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 5.4 \cdot 10^{-6}:\\
\;\;\;\;\left(\frac{-1}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \left(-ky\right)\right) \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky \cdot 2\right), 2, 2 \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}{2}} \cdot \sin th\\
\end{array}
\end{array}
if ky < 5.39999999999999997e-6Initial program 90.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6487.6
lift-sqrt.f64N/A
Applied rewrites94.8%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6461.4
Applied rewrites61.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites66.2%
Taylor expanded in ky around 0
mul-1-negN/A
lower-neg.f6466.5
Applied rewrites66.5%
if 5.39999999999999997e-6 < ky Initial program 99.7%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
frac-addN/A
metadata-evalN/A
metadata-evalN/A
sqrt-divN/A
Applied rewrites98.2%
(FPCore (kx ky th) :precision binary64 (* (* (* -0.16666666666666666 th) th) th))
double code(double kx, double ky, double th) {
return ((-0.16666666666666666 * th) * th) * th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (((-0.16666666666666666d0) * th) * th) * th
end function
public static double code(double kx, double ky, double th) {
return ((-0.16666666666666666 * th) * th) * th;
}
def code(kx, ky, th): return ((-0.16666666666666666 * th) * th) * th
function code(kx, ky, th) return Float64(Float64(Float64(-0.16666666666666666 * th) * th) * th) end
function tmp = code(kx, ky, th) tmp = ((-0.16666666666666666 * th) * th) * th; end
code[kx_, ky_, th_] := N[(N[(N[(-0.16666666666666666 * th), $MachinePrecision] * th), $MachinePrecision] * th), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(-0.16666666666666666 \cdot th\right) \cdot th\right) \cdot th
\end{array}
Initial program 93.0%
Taylor expanded in kx around 0
lower-sin.f6426.7
Applied rewrites26.7%
Taylor expanded in th around 0
Applied rewrites14.2%
Taylor expanded in th around inf
Applied rewrites11.8%
Applied rewrites11.8%
herbie shell --seed 2024303
(FPCore (kx ky th)
:name "Toniolo and Linder, Equation (3b), real"
:precision binary64
(* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))