
(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 23 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 ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 94.4%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin kx) 2.0))
(t_2 (* (sin ky) th))
(t_3 (pow (sin ky) 2.0))
(t_4 (/ (sin ky) (sqrt (+ t_1 t_3)))))
(if (<= t_4 -0.9996)
(* (/ (sin ky) (sqrt (+ (* kx kx) t_3))) (sin th))
(if (<= t_4 -0.1)
(*
t_2
(sqrt
(pow (- (fma (sin ky) (sin ky) 0.5) (* (cos (* -2.0 kx)) 0.5)) -1.0)))
(if (<= t_4 0.06)
(*
(/
(sin ky)
(sqrt
(+ t_1 (* (fma (* ky ky) -0.3333333333333333 1.0) (* ky ky)))))
(sin th))
(if (<= t_4 0.998)
(/ t_2 (hypot (sin ky) (sin kx)))
(*
(/ (sin ky) (fma (* (/ 0.5 (sin ky)) kx) kx (sin ky)))
(sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(kx), 2.0);
double t_2 = sin(ky) * th;
double t_3 = pow(sin(ky), 2.0);
double t_4 = sin(ky) / sqrt((t_1 + t_3));
double tmp;
if (t_4 <= -0.9996) {
tmp = (sin(ky) / sqrt(((kx * kx) + t_3))) * sin(th);
} else if (t_4 <= -0.1) {
tmp = t_2 * sqrt(pow((fma(sin(ky), sin(ky), 0.5) - (cos((-2.0 * kx)) * 0.5)), -1.0));
} else if (t_4 <= 0.06) {
tmp = (sin(ky) / sqrt((t_1 + (fma((ky * ky), -0.3333333333333333, 1.0) * (ky * ky))))) * sin(th);
} else if (t_4 <= 0.998) {
tmp = t_2 / hypot(sin(ky), sin(kx));
} else {
tmp = (sin(ky) / fma(((0.5 / sin(ky)) * kx), kx, sin(ky))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = sin(kx) ^ 2.0 t_2 = Float64(sin(ky) * th) t_3 = sin(ky) ^ 2.0 t_4 = Float64(sin(ky) / sqrt(Float64(t_1 + t_3))) tmp = 0.0 if (t_4 <= -0.9996) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(kx * kx) + t_3))) * sin(th)); elseif (t_4 <= -0.1) tmp = Float64(t_2 * sqrt((Float64(fma(sin(ky), sin(ky), 0.5) - Float64(cos(Float64(-2.0 * kx)) * 0.5)) ^ -1.0))); elseif (t_4 <= 0.06) tmp = Float64(Float64(sin(ky) / sqrt(Float64(t_1 + Float64(fma(Float64(ky * ky), -0.3333333333333333, 1.0) * Float64(ky * ky))))) * sin(th)); elseif (t_4 <= 0.998) tmp = Float64(t_2 / hypot(sin(ky), sin(kx))); else tmp = Float64(Float64(sin(ky) / fma(Float64(Float64(0.5 / sin(ky)) * kx), kx, sin(ky))) * 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] * th), $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[(t$95$1 + t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -0.9996], 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.1], N[(t$95$2 * N[Sqrt[N[Power[N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[ky], $MachinePrecision] + 0.5), $MachinePrecision] - N[(N[Cos[N[(-2.0 * kx), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.06], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(N[(N[(ky * ky), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.998], N[(t$95$2 / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(N[(0.5 / N[Sin[ky], $MachinePrecision]), $MachinePrecision] * kx), $MachinePrecision] * kx + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin kx}^{2}\\
t_2 := \sin ky \cdot th\\
t_3 := {\sin ky}^{2}\\
t_4 := \frac{\sin ky}{\sqrt{t\_1 + t\_3}}\\
\mathbf{if}\;t\_4 \leq -0.9996:\\
\;\;\;\;\frac{\sin ky}{\sqrt{kx \cdot kx + t\_3}} \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq -0.1:\\
\;\;\;\;t\_2 \cdot \sqrt{{\left(\mathsf{fma}\left(\sin ky, \sin ky, 0.5\right) - \cos \left(-2 \cdot kx\right) \cdot 0.5\right)}^{-1}}\\
\mathbf{elif}\;t\_4 \leq 0.06:\\
\;\;\;\;\frac{\sin ky}{\sqrt{t\_1 + \mathsf{fma}\left(ky \cdot ky, -0.3333333333333333, 1\right) \cdot \left(ky \cdot ky\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq 0.998:\\
\;\;\;\;\frac{t\_2}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(\frac{0.5}{\sin ky} \cdot kx, kx, \sin ky\right)} \cdot \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.99960000000000004Initial program 88.3%
Taylor expanded in kx around 0
unpow2N/A
lower-*.f6488.3
Applied rewrites88.3%
if -0.99960000000000004 < (/.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.10000000000000001Initial program 99.5%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/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
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval48.0
Applied rewrites48.0%
if -0.10000000000000001 < (/.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.059999999999999998Initial program 99.6%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6497.9
Applied rewrites97.9%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.0
Applied rewrites98.0%
if 0.059999999999999998 < (/.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.998Initial program 99.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.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.5
Applied rewrites99.5%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6450.4
Applied rewrites50.4%
if 0.998 < (/.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 86.3%
Taylor expanded in kx around 0
+-commutativeN/A
associate-*r/N/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f6493.4
Applied rewrites93.4%
Final simplification82.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx)))
(t_2 (* (sin ky) th))
(t_3 (pow (sin ky) 2.0))
(t_4 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) t_3)))))
(if (<= t_4 -0.9996)
(* (/ (sin ky) (sqrt (+ (* kx kx) t_3))) (sin th))
(if (<= t_4 -0.1)
(*
t_2
(sqrt
(pow (- (fma (sin ky) (sin ky) 0.5) (* (cos (* -2.0 kx)) 0.5)) -1.0)))
(if (<= t_4 0.06)
(/ (* (* (fma -0.16666666666666666 (* ky ky) 1.0) (sin th)) ky) t_1)
(if (<= t_4 0.998)
(/ t_2 t_1)
(*
(/ (sin ky) (fma (* (/ 0.5 (sin ky)) kx) kx (sin ky)))
(sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double t_2 = sin(ky) * th;
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.9996) {
tmp = (sin(ky) / sqrt(((kx * kx) + t_3))) * sin(th);
} else if (t_4 <= -0.1) {
tmp = t_2 * sqrt(pow((fma(sin(ky), sin(ky), 0.5) - (cos((-2.0 * kx)) * 0.5)), -1.0));
} else if (t_4 <= 0.06) {
tmp = ((fma(-0.16666666666666666, (ky * ky), 1.0) * sin(th)) * ky) / t_1;
} else if (t_4 <= 0.998) {
tmp = t_2 / t_1;
} else {
tmp = (sin(ky) / fma(((0.5 / sin(ky)) * kx), kx, sin(ky))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) t_2 = Float64(sin(ky) * th) 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.9996) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(kx * kx) + t_3))) * sin(th)); elseif (t_4 <= -0.1) tmp = Float64(t_2 * sqrt((Float64(fma(sin(ky), sin(ky), 0.5) - Float64(cos(Float64(-2.0 * kx)) * 0.5)) ^ -1.0))); elseif (t_4 <= 0.06) tmp = Float64(Float64(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * sin(th)) * ky) / t_1); elseif (t_4 <= 0.998) tmp = Float64(t_2 / t_1); else tmp = Float64(Float64(sin(ky) / fma(Float64(Float64(0.5 / sin(ky)) * kx), kx, sin(ky))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] * th), $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.9996], 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.1], N[(t$95$2 * N[Sqrt[N[Power[N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[ky], $MachinePrecision] + 0.5), $MachinePrecision] - N[(N[Cos[N[(-2.0 * kx), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.06], N[(N[(N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$4, 0.998], N[(t$95$2 / t$95$1), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(N[(0.5 / N[Sin[ky], $MachinePrecision]), $MachinePrecision] * kx), $MachinePrecision] * kx + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
t_2 := \sin ky \cdot th\\
t_3 := {\sin ky}^{2}\\
t_4 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + t\_3}}\\
\mathbf{if}\;t\_4 \leq -0.9996:\\
\;\;\;\;\frac{\sin ky}{\sqrt{kx \cdot kx + t\_3}} \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq -0.1:\\
\;\;\;\;t\_2 \cdot \sqrt{{\left(\mathsf{fma}\left(\sin ky, \sin ky, 0.5\right) - \cos \left(-2 \cdot kx\right) \cdot 0.5\right)}^{-1}}\\
\mathbf{elif}\;t\_4 \leq 0.06:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot \sin th\right) \cdot ky}{t\_1}\\
\mathbf{elif}\;t\_4 \leq 0.998:\\
\;\;\;\;\frac{t\_2}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(\frac{0.5}{\sin ky} \cdot kx, kx, \sin ky\right)} \cdot \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.99960000000000004Initial program 88.3%
Taylor expanded in kx around 0
unpow2N/A
lower-*.f6488.3
Applied rewrites88.3%
if -0.99960000000000004 < (/.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.10000000000000001Initial program 99.5%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/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
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval48.0
Applied rewrites48.0%
if -0.10000000000000001 < (/.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.059999999999999998Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.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.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f6497.8
Applied rewrites97.8%
if 0.059999999999999998 < (/.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.998Initial program 99.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.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.5
Applied rewrites99.5%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6450.4
Applied rewrites50.4%
if 0.998 < (/.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 86.3%
Taylor expanded in kx around 0
+-commutativeN/A
associate-*r/N/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f6493.4
Applied rewrites93.4%
Final simplification82.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx)))
(t_2 (/ (* (sin ky) th) t_1))
(t_3 (pow (sin ky) 2.0))
(t_4 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) t_3)))))
(if (<= t_4 -1.0)
(* (/ (sin ky) (sqrt (+ (* kx kx) t_3))) (sin th))
(if (<= t_4 -0.1)
t_2
(if (<= t_4 0.06)
(/ (* (* (fma -0.16666666666666666 (* ky ky) 1.0) (sin th)) ky) t_1)
(if (<= t_4 0.998)
t_2
(*
(/ (sin ky) (fma (* (/ 0.5 (sin ky)) kx) kx (sin ky)))
(sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double t_2 = (sin(ky) * th) / t_1;
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 <= -1.0) {
tmp = (sin(ky) / sqrt(((kx * kx) + t_3))) * sin(th);
} else if (t_4 <= -0.1) {
tmp = t_2;
} else if (t_4 <= 0.06) {
tmp = ((fma(-0.16666666666666666, (ky * ky), 1.0) * sin(th)) * ky) / t_1;
} else if (t_4 <= 0.998) {
tmp = t_2;
} else {
tmp = (sin(ky) / fma(((0.5 / sin(ky)) * kx), kx, sin(ky))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) t_2 = Float64(Float64(sin(ky) * th) / t_1) 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 <= -1.0) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(kx * kx) + t_3))) * sin(th)); elseif (t_4 <= -0.1) tmp = t_2; elseif (t_4 <= 0.06) tmp = Float64(Float64(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * sin(th)) * ky) / t_1); elseif (t_4 <= 0.998) tmp = t_2; else tmp = Float64(Float64(sin(ky) / fma(Float64(Float64(0.5 / sin(ky)) * kx), kx, sin(ky))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / t$95$1), $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, -1.0], 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.1], t$95$2, If[LessEqual[t$95$4, 0.06], N[(N[(N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$4, 0.998], t$95$2, N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(N[(0.5 / N[Sin[ky], $MachinePrecision]), $MachinePrecision] * kx), $MachinePrecision] * kx + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
t_2 := \frac{\sin ky \cdot th}{t\_1}\\
t_3 := {\sin ky}^{2}\\
t_4 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + t\_3}}\\
\mathbf{if}\;t\_4 \leq -1:\\
\;\;\;\;\frac{\sin ky}{\sqrt{kx \cdot kx + t\_3}} \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq -0.1:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_4 \leq 0.06:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot \sin th\right) \cdot ky}{t\_1}\\
\mathbf{elif}\;t\_4 \leq 0.998:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(\frac{0.5}{\sin ky} \cdot kx, kx, \sin ky\right)} \cdot \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))))) < -1Initial program 87.6%
Taylor expanded in kx around 0
unpow2N/A
lower-*.f6487.6
Applied rewrites87.6%
if -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))))) < -0.10000000000000001 or 0.059999999999999998 < (/.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.998Initial program 99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.4
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6448.7
Applied rewrites48.7%
if -0.10000000000000001 < (/.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.059999999999999998Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.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.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f6497.8
Applied rewrites97.8%
if 0.998 < (/.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 86.3%
Taylor expanded in kx around 0
+-commutativeN/A
associate-*r/N/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f6493.4
Applied rewrites93.4%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx)))
(t_2 (/ (* (sin ky) th) t_1))
(t_3 (pow (sin ky) 2.0))
(t_4 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) t_3)))))
(if (<= t_4 -1.0)
(* (/ (sin ky) (sqrt (+ (* kx kx) t_3))) (sin th))
(if (<= t_4 -0.1)
t_2
(if (<= t_4 0.06)
(/ (* (* (fma -0.16666666666666666 (* ky ky) 1.0) (sin th)) ky) t_1)
(if (<= t_4 0.998) t_2 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double t_2 = (sin(ky) * th) / t_1;
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 <= -1.0) {
tmp = (sin(ky) / sqrt(((kx * kx) + t_3))) * sin(th);
} else if (t_4 <= -0.1) {
tmp = t_2;
} else if (t_4 <= 0.06) {
tmp = ((fma(-0.16666666666666666, (ky * ky), 1.0) * sin(th)) * ky) / t_1;
} else if (t_4 <= 0.998) {
tmp = t_2;
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) t_2 = Float64(Float64(sin(ky) * th) / t_1) 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 <= -1.0) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(kx * kx) + t_3))) * sin(th)); elseif (t_4 <= -0.1) tmp = t_2; elseif (t_4 <= 0.06) tmp = Float64(Float64(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * sin(th)) * ky) / t_1); elseif (t_4 <= 0.998) tmp = t_2; else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / t$95$1), $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, -1.0], 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.1], t$95$2, If[LessEqual[t$95$4, 0.06], N[(N[(N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$4, 0.998], t$95$2, N[Sin[th], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
t_2 := \frac{\sin ky \cdot th}{t\_1}\\
t_3 := {\sin ky}^{2}\\
t_4 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + t\_3}}\\
\mathbf{if}\;t\_4 \leq -1:\\
\;\;\;\;\frac{\sin ky}{\sqrt{kx \cdot kx + t\_3}} \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq -0.1:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_4 \leq 0.06:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot \sin th\right) \cdot ky}{t\_1}\\
\mathbf{elif}\;t\_4 \leq 0.998:\\
\;\;\;\;t\_2\\
\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))))) < -1Initial program 87.6%
Taylor expanded in kx around 0
unpow2N/A
lower-*.f6487.6
Applied rewrites87.6%
if -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))))) < -0.10000000000000001 or 0.059999999999999998 < (/.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.998Initial program 99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.4
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6448.7
Applied rewrites48.7%
if -0.10000000000000001 < (/.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.059999999999999998Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.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.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f6497.8
Applied rewrites97.8%
if 0.998 < (/.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 86.3%
Taylor expanded in kx around 0
lower-sin.f6493.2
Applied rewrites93.2%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx)))
(t_2 (/ (* (sin ky) th) t_1))
(t_3 (pow (sin ky) 2.0))
(t_4 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) t_3)))))
(if (<= t_4 -1.0)
(* (* (sqrt (pow t_3 -1.0)) (sin ky)) (sin th))
(if (<= t_4 -0.1)
t_2
(if (<= t_4 0.06)
(/ (* (* (fma -0.16666666666666666 (* ky ky) 1.0) (sin th)) ky) t_1)
(if (<= t_4 0.998) t_2 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double t_2 = (sin(ky) * th) / t_1;
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 <= -1.0) {
tmp = (sqrt(pow(t_3, -1.0)) * sin(ky)) * sin(th);
} else if (t_4 <= -0.1) {
tmp = t_2;
} else if (t_4 <= 0.06) {
tmp = ((fma(-0.16666666666666666, (ky * ky), 1.0) * sin(th)) * ky) / t_1;
} else if (t_4 <= 0.998) {
tmp = t_2;
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) t_2 = Float64(Float64(sin(ky) * th) / t_1) 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 <= -1.0) tmp = Float64(Float64(sqrt((t_3 ^ -1.0)) * sin(ky)) * sin(th)); elseif (t_4 <= -0.1) tmp = t_2; elseif (t_4 <= 0.06) tmp = Float64(Float64(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * sin(th)) * ky) / t_1); elseif (t_4 <= 0.998) tmp = t_2; else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / t$95$1), $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, -1.0], N[(N[(N[Sqrt[N[Power[t$95$3, -1.0], $MachinePrecision]], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -0.1], t$95$2, If[LessEqual[t$95$4, 0.06], N[(N[(N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$4, 0.998], t$95$2, N[Sin[th], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
t_2 := \frac{\sin ky \cdot th}{t\_1}\\
t_3 := {\sin ky}^{2}\\
t_4 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + t\_3}}\\
\mathbf{if}\;t\_4 \leq -1:\\
\;\;\;\;\left(\sqrt{{t\_3}^{-1}} \cdot \sin ky\right) \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq -0.1:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_4 \leq 0.06:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot \sin th\right) \cdot ky}{t\_1}\\
\mathbf{elif}\;t\_4 \leq 0.998:\\
\;\;\;\;t\_2\\
\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))))) < -1Initial program 87.6%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/A
lower-*.f6487.6
Applied rewrites87.6%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites59.2%
Taylor expanded in kx around 0
Applied rewrites87.4%
if -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))))) < -0.10000000000000001 or 0.059999999999999998 < (/.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.998Initial program 99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.4
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6448.7
Applied rewrites48.7%
if -0.10000000000000001 < (/.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.059999999999999998Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.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.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f6497.8
Applied rewrites97.8%
if 0.998 < (/.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 86.3%
Taylor expanded in kx around 0
lower-sin.f6493.2
Applied rewrites93.2%
Final simplification81.4%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx)))
(t_2 (/ (* (sin ky) th) t_1))
(t_3 (pow (sin ky) 2.0))
(t_4 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) t_3)))))
(if (<= t_4 -1.0)
(* (* (sqrt (pow t_3 -1.0)) (sin ky)) (sin th))
(if (<= t_4 -0.1)
t_2
(if (<= t_4 0.07)
(/ (* (sin th) ky) t_1)
(if (<= t_4 0.998) t_2 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double t_2 = (sin(ky) * th) / t_1;
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 <= -1.0) {
tmp = (sqrt(pow(t_3, -1.0)) * sin(ky)) * sin(th);
} else if (t_4 <= -0.1) {
tmp = t_2;
} else if (t_4 <= 0.07) {
tmp = (sin(th) * ky) / t_1;
} else if (t_4 <= 0.998) {
tmp = t_2;
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(ky), Math.sin(kx));
double t_2 = (Math.sin(ky) * th) / t_1;
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 <= -1.0) {
tmp = (Math.sqrt(Math.pow(t_3, -1.0)) * Math.sin(ky)) * Math.sin(th);
} else if (t_4 <= -0.1) {
tmp = t_2;
} else if (t_4 <= 0.07) {
tmp = (Math.sin(th) * ky) / t_1;
} else if (t_4 <= 0.998) {
tmp = t_2;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) t_2 = (math.sin(ky) * th) / t_1 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 <= -1.0: tmp = (math.sqrt(math.pow(t_3, -1.0)) * math.sin(ky)) * math.sin(th) elif t_4 <= -0.1: tmp = t_2 elif t_4 <= 0.07: tmp = (math.sin(th) * ky) / t_1 elif t_4 <= 0.998: tmp = t_2 else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) t_2 = Float64(Float64(sin(ky) * th) / t_1) 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 <= -1.0) tmp = Float64(Float64(sqrt((t_3 ^ -1.0)) * sin(ky)) * sin(th)); elseif (t_4 <= -0.1) tmp = t_2; elseif (t_4 <= 0.07) tmp = Float64(Float64(sin(th) * ky) / t_1); elseif (t_4 <= 0.998) tmp = t_2; else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); t_2 = (sin(ky) * th) / t_1; t_3 = sin(ky) ^ 2.0; t_4 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + t_3)); tmp = 0.0; if (t_4 <= -1.0) tmp = (sqrt((t_3 ^ -1.0)) * sin(ky)) * sin(th); elseif (t_4 <= -0.1) tmp = t_2; elseif (t_4 <= 0.07) tmp = (sin(th) * ky) / t_1; elseif (t_4 <= 0.998) tmp = t_2; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / t$95$1), $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, -1.0], N[(N[(N[Sqrt[N[Power[t$95$3, -1.0], $MachinePrecision]], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -0.1], t$95$2, If[LessEqual[t$95$4, 0.07], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$4, 0.998], t$95$2, N[Sin[th], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
t_2 := \frac{\sin ky \cdot th}{t\_1}\\
t_3 := {\sin ky}^{2}\\
t_4 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + t\_3}}\\
\mathbf{if}\;t\_4 \leq -1:\\
\;\;\;\;\left(\sqrt{{t\_3}^{-1}} \cdot \sin ky\right) \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq -0.1:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_4 \leq 0.07:\\
\;\;\;\;\frac{\sin th \cdot ky}{t\_1}\\
\mathbf{elif}\;t\_4 \leq 0.998:\\
\;\;\;\;t\_2\\
\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))))) < -1Initial program 87.6%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/A
lower-*.f6487.6
Applied rewrites87.6%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites59.2%
Taylor expanded in kx around 0
Applied rewrites87.4%
if -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))))) < -0.10000000000000001 or 0.070000000000000007 < (/.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.998Initial program 99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.4
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6448.7
Applied rewrites48.7%
if -0.10000000000000001 < (/.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.070000000000000007Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.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.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6497.3
Applied rewrites97.3%
if 0.998 < (/.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 86.3%
Taylor expanded in kx around 0
lower-sin.f6493.2
Applied rewrites93.2%
Final simplification81.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx)))
(t_2 (/ (* (sin ky) th) t_1))
(t_3 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_3 -0.1)
t_2
(if (<= t_3 0.07)
(/ (* (sin th) ky) t_1)
(if (<= t_3 0.998) t_2 (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double t_2 = (sin(ky) * th) / t_1;
double t_3 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 0.07) {
tmp = (sin(th) * ky) / t_1;
} else if (t_3 <= 0.998) {
tmp = t_2;
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(ky), Math.sin(kx));
double t_2 = (Math.sin(ky) * th) / t_1;
double t_3 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
double tmp;
if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 0.07) {
tmp = (Math.sin(th) * ky) / t_1;
} else if (t_3 <= 0.998) {
tmp = t_2;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) t_2 = (math.sin(ky) * th) / t_1 t_3 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))) tmp = 0 if t_3 <= -0.1: tmp = t_2 elif t_3 <= 0.07: tmp = (math.sin(th) * ky) / t_1 elif t_3 <= 0.998: tmp = t_2 else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) t_2 = Float64(Float64(sin(ky) * th) / t_1) t_3 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 0.07) tmp = Float64(Float64(sin(th) * ky) / t_1); elseif (t_3 <= 0.998) tmp = t_2; else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); t_2 = (sin(ky) * th) / t_1; t_3 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); tmp = 0.0; if (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 0.07) tmp = (sin(th) * ky) / t_1; elseif (t_3 <= 0.998) tmp = t_2; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = 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$3, -0.1], t$95$2, If[LessEqual[t$95$3, 0.07], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, 0.998], t$95$2, N[Sin[th], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
t_2 := \frac{\sin ky \cdot th}{t\_1}\\
t_3 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_3 \leq -0.1:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 0.07:\\
\;\;\;\;\frac{\sin th \cdot ky}{t\_1}\\
\mathbf{elif}\;t\_3 \leq 0.998:\\
\;\;\;\;t\_2\\
\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.10000000000000001 or 0.070000000000000007 < (/.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.998Initial program 94.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/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.f6496.4
Applied rewrites96.4%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6442.8
Applied rewrites42.8%
if -0.10000000000000001 < (/.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.070000000000000007Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.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.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6497.3
Applied rewrites97.3%
if 0.998 < (/.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 86.3%
Taylor expanded in kx around 0
lower-sin.f6493.2
Applied rewrites93.2%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (* (sin ky) th) (hypot (sin ky) (sin kx))))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_2 -0.1)
t_1
(if (<= t_2 0.07)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= t_2 0.998) t_1 (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = (sin(ky) * th) / hypot(sin(ky), sin(kx));
double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= -0.1) {
tmp = t_1;
} else if (t_2 <= 0.07) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (t_2 <= 0.998) {
tmp = t_1;
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = (Math.sin(ky) * th) / 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 tmp;
if (t_2 <= -0.1) {
tmp = t_1;
} else if (t_2 <= 0.07) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (t_2 <= 0.998) {
tmp = t_1;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = (math.sin(ky) * th) / 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))) tmp = 0 if t_2 <= -0.1: tmp = t_1 elif t_2 <= 0.07: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif t_2 <= 0.998: tmp = t_1 else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(Float64(sin(ky) * th) / hypot(sin(ky), sin(kx))) t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.1) tmp = t_1; elseif (t_2 <= 0.07) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (t_2 <= 0.998) tmp = t_1; else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (sin(ky) * th) / hypot(sin(ky), sin(kx)); t_2 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); tmp = 0.0; if (t_2 <= -0.1) tmp = t_1; elseif (t_2 <= 0.07) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (t_2 <= 0.998) tmp = t_1; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $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]}, If[LessEqual[t$95$2, -0.1], t$95$1, If[LessEqual[t$95$2, 0.07], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.998], t$95$1, N[Sin[th], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky \cdot th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.1:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 0.07:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;t\_2 \leq 0.998:\\
\;\;\;\;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.10000000000000001 or 0.070000000000000007 < (/.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.998Initial program 94.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/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.f6496.4
Applied rewrites96.4%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6442.8
Applied rewrites42.8%
if -0.10000000000000001 < (/.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.070000000000000007Initial program 99.6%
Taylor expanded in ky around 0
lower-sin.f6470.7
Applied rewrites70.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6470.7
Applied rewrites70.7%
if 0.998 < (/.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 86.3%
Taylor expanded in kx around 0
lower-sin.f6493.2
Applied rewrites93.2%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1
(*
(/
(sin ky)
(/
(sqrt
(fma
(- 1.0 (cos (* 2.0 ky)))
2.0
(* 2.0 (- 1.0 (cos (* 2.0 kx))))))
2.0))
(* (fma (* th th) -0.16666666666666666 1.0) th)))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
(if (<= t_2 -0.1)
t_1
(if (<= t_2 0.07)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= t_2 0.998) t_1 (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = (sin(ky) / (sqrt(fma((1.0 - cos((2.0 * ky))), 2.0, (2.0 * (1.0 - cos((2.0 * kx)))))) / 2.0)) * (fma((th * th), -0.16666666666666666, 1.0) * th);
double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= -0.1) {
tmp = t_1;
} else if (t_2 <= 0.07) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (t_2 <= 0.998) {
tmp = t_1;
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(Float64(sin(ky) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(2.0 * ky))), 2.0, Float64(2.0 * Float64(1.0 - cos(Float64(2.0 * kx)))))) / 2.0)) * Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th)) t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.1) tmp = t_1; elseif (t_2 <= 0.07) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (t_2 <= 0.998) tmp = t_1; else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $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[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $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]}, If[LessEqual[t$95$2, -0.1], t$95$1, If[LessEqual[t$95$2, 0.07], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.998], t$95$1, N[Sin[th], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 2, 2 \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}{2}} \cdot \left(\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th\right)\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.1:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 0.07:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;t\_2 \leq 0.998:\\
\;\;\;\;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.10000000000000001 or 0.070000000000000007 < (/.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.998Initial program 94.6%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6445.7
Applied rewrites45.7%
lift-hypot.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
frac-addN/A
metadata-evalN/A
metadata-evalN/A
sqrt-divN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
Applied rewrites37.7%
if -0.10000000000000001 < (/.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.070000000000000007Initial program 99.6%
Taylor expanded in ky around 0
lower-sin.f6470.7
Applied rewrites70.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6470.7
Applied rewrites70.7%
if 0.998 < (/.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 86.3%
Taylor expanded in kx around 0
lower-sin.f6493.2
Applied rewrites93.2%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.1) (* (sin ky) (/ (sin th) (sin kx))) (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)))) <= 0.1) {
tmp = sin(ky) * (sin(th) / sin(kx));
} 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)))) <= 0.1d0) then
tmp = sin(ky) * (sin(th) / sin(kx))
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)))) <= 0.1) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} 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)))) <= 0.1: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) 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)))) <= 0.1) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); 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)))) <= 0.1) tmp = sin(ky) * (sin(th) / sin(kx)); 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], 0.1], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $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 0.1:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\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.10000000000000001Initial program 96.2%
Taylor expanded in ky around 0
lower-sin.f6438.6
Applied rewrites38.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.6
Applied rewrites38.6%
if 0.10000000000000001 < (/.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.0%
Taylor expanded in kx around 0
lower-sin.f6467.1
Applied rewrites67.1%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.06) (* (/ 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)))) <= 0.06) {
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)))) <= 0.06d0) 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)))) <= 0.06) {
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)))) <= 0.06: 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)))) <= 0.06) 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)))) <= 0.06) 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], 0.06], 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 0.06:\\
\;\;\;\;\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))))) < 0.059999999999999998Initial program 96.2%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6437.1
Applied rewrites37.1%
if 0.059999999999999998 < (/.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.1%
Taylor expanded in kx around 0
lower-sin.f6466.6
Applied rewrites66.6%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.06) (/ (* (sin th) ky) (sin kx)) (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)))) <= 0.06) {
tmp = (sin(th) * ky) / sin(kx);
} 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)))) <= 0.06d0) then
tmp = (sin(th) * ky) / sin(kx)
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)))) <= 0.06) {
tmp = (Math.sin(th) * ky) / Math.sin(kx);
} 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)))) <= 0.06: tmp = (math.sin(th) * ky) / math.sin(kx) 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)))) <= 0.06) tmp = Float64(Float64(sin(th) * ky) / sin(kx)); 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)))) <= 0.06) tmp = (sin(th) * ky) / sin(kx); 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], 0.06], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Sin[kx], $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 0.06:\\
\;\;\;\;\frac{\sin th \cdot ky}{\sin kx}\\
\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.059999999999999998Initial program 96.2%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6436.6
Applied rewrites36.6%
if 0.059999999999999998 < (/.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.1%
Taylor expanded in kx around 0
lower-sin.f6466.6
Applied rewrites66.6%
Final simplification47.1%
(FPCore (kx ky th)
:precision binary64
(if (<=
(*
(/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))
(sin th))
1e-322)
(* (* (* -0.16666666666666666 th) th) th)
(*
(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-322) {
tmp = ((-0.16666666666666666 * th) * th) * th;
} else {
tmp = 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-322) tmp = Float64(Float64(Float64(-0.16666666666666666 * th) * th) * th); else tmp = Float64(fma(Float64(Float64(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-322], N[(N[(N[(-0.16666666666666666 * th), $MachinePrecision] * th), $MachinePrecision] * th), $MachinePrecision], N[(N[(N[(N[(N[(th * th), $MachinePrecision] * 0.008333333333333333), $MachinePrecision] - 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^{-322}:\\
\;\;\;\;\left(\left(-0.16666666666666666 \cdot th\right) \cdot th\right) \cdot th\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(th \cdot th\right) \cdot 0.008333333333333333 - 0.16666666666666666, 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.88131e-323Initial program 94.7%
Taylor expanded in kx around 0
lower-sin.f6426.9
Applied rewrites26.9%
Taylor expanded in th around 0
Applied rewrites13.5%
Taylor expanded in th around inf
Applied rewrites13.4%
Applied rewrites13.4%
if 9.88131e-323 < (*.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 94.0%
Taylor expanded in kx around 0
lower-sin.f6424.7
Applied rewrites24.7%
Taylor expanded in th around 0
Applied rewrites16.7%
(FPCore (kx ky th)
:precision binary64
(if (<=
(*
(/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))
(sin th))
1e-322)
(* (* (* -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-322) {
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-322) 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-322], 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^{-322}:\\
\;\;\;\;\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.88131e-323Initial program 94.7%
Taylor expanded in kx around 0
lower-sin.f6426.9
Applied rewrites26.9%
Taylor expanded in th around 0
Applied rewrites13.5%
Taylor expanded in th around inf
Applied rewrites13.4%
Applied rewrites13.4%
if 9.88131e-323 < (*.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 94.0%
Taylor expanded in kx around 0
lower-sin.f6424.7
Applied rewrites24.7%
Taylor expanded in th around 0
Applied rewrites16.8%
Applied rewrites16.8%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 5e-5) (/ (* (sin th) ky) kx) (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-5) {
tmp = (sin(th) * ky) / kx;
} 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-5) then
tmp = (sin(th) * ky) / kx
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-5) {
tmp = (Math.sin(th) * ky) / kx;
} 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-5: tmp = (math.sin(th) * ky) / kx 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-5) tmp = Float64(Float64(sin(th) * ky) / kx); 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-5) tmp = (sin(th) * ky) / kx; 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-5], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / kx), $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^{-5}:\\
\;\;\;\;\frac{\sin th \cdot ky}{kx}\\
\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.00000000000000024e-5Initial program 96.2%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/A
lower-*.f6483.3
Applied rewrites83.3%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6436.4
Applied rewrites36.4%
Taylor expanded in kx around 0
Applied rewrites21.1%
if 5.00000000000000024e-5 < (/.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.1%
Taylor expanded in kx around 0
lower-sin.f6466.0
Applied rewrites66.0%
(FPCore (kx ky th)
:precision binary64
(if (<=
(/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))
1.06e-33)
(* (* (* -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)))) <= 1.06e-33) {
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)))) <= 1.06d-33) 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)))) <= 1.06e-33) {
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)))) <= 1.06e-33: 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)))) <= 1.06e-33) 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)))) <= 1.06e-33) 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], 1.06e-33], 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 1.06 \cdot 10^{-33}:\\
\;\;\;\;\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))))) < 1.0599999999999999e-33Initial program 96.1%
Taylor expanded in kx around 0
lower-sin.f643.6
Applied rewrites3.6%
Taylor expanded in th around 0
Applied rewrites3.2%
Taylor expanded in th around inf
Applied rewrites11.5%
Applied rewrites11.5%
if 1.0599999999999999e-33 < (/.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.2%
Taylor expanded in kx around 0
lower-sin.f6465.4
Applied rewrites65.4%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) 1e-151)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin ky) 5e-5)
(*
(/
(sin ky)
(sqrt
(+
(- 0.5 (* (cos (* 2.0 kx)) 0.5))
(* (fma (* ky ky) -0.3333333333333333 1.0) (* ky ky)))))
(sin th))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-151) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(ky) <= 5e-5) {
tmp = (sin(ky) / sqrt(((0.5 - (cos((2.0 * kx)) * 0.5)) + (fma((ky * ky), -0.3333333333333333, 1.0) * (ky * ky))))) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-151) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(ky) <= 5e-5) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(0.5 - Float64(cos(Float64(2.0 * kx)) * 0.5)) + Float64(fma(Float64(ky * ky), -0.3333333333333333, 1.0) * Float64(ky * ky))))) * sin(th)); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-151], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-5], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(ky * ky), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-151}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\left(0.5 - \cos \left(2 \cdot kx\right) \cdot 0.5\right) + \mathsf{fma}\left(ky \cdot ky, -0.3333333333333333, 1\right) \cdot \left(ky \cdot ky\right)}} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.9999999999999994e-152Initial program 90.8%
Taylor expanded in ky around 0
lower-sin.f6434.1
Applied rewrites34.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6434.1
Applied rewrites34.1%
if 9.9999999999999994e-152 < (sin.f64 ky) < 5.00000000000000024e-5Initial program 99.9%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/A
lower-*.f6496.8
Applied rewrites96.8%
if 5.00000000000000024e-5 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0
lower-sin.f6460.1
Applied rewrites60.1%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 0.00156)
(/
(* (* (fma -0.16666666666666666 (* ky ky) 1.0) (sin th)) ky)
(hypot (sin ky) (sin kx)))
(*
(*
(sqrt
(pow (/ (+ (- 1.0 (cos (* 2.0 ky))) (- 1.0 (cos (* 2.0 kx)))) 2.0) -1.0))
(sin ky))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.00156) {
tmp = ((fma(-0.16666666666666666, (ky * ky), 1.0) * sin(th)) * ky) / hypot(sin(ky), sin(kx));
} else {
tmp = (sqrt(pow((((1.0 - cos((2.0 * ky))) + (1.0 - cos((2.0 * kx)))) / 2.0), -1.0)) * sin(ky)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (ky <= 0.00156) tmp = Float64(Float64(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * sin(th)) * ky) / hypot(sin(ky), sin(kx))); else tmp = Float64(Float64(sqrt((Float64(Float64(Float64(1.0 - cos(Float64(2.0 * ky))) + Float64(1.0 - cos(Float64(2.0 * kx)))) / 2.0) ^ -1.0)) * sin(ky)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[ky, 0.00156], N[(N[(N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[Power[N[(N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 0.00156:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot \sin th\right) \cdot ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{{\left(\frac{\left(1 - \cos \left(2 \cdot ky\right)\right) + \left(1 - \cos \left(2 \cdot kx\right)\right)}{2}\right)}^{-1}} \cdot \sin ky\right) \cdot \sin th\\
\end{array}
\end{array}
if ky < 0.00155999999999999997Initial program 92.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6490.3
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6494.8
Applied rewrites94.8%
Taylor expanded in ky around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f6460.5
Applied rewrites60.5%
if 0.00155999999999999997 < ky Initial program 99.7%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.7%
Applied rewrites98.9%
Final simplification70.7%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 0.00156)
(/
(* (* (fma -0.16666666666666666 (* ky ky) 1.0) (sin th)) ky)
(hypot (sin ky) (sin kx)))
(*
(/
(sin ky)
(sqrt
(+ (- 0.5 (* (cos (* 2.0 kx)) 0.5)) (- 0.5 (* (cos (* 2.0 ky)) 0.5)))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.00156) {
tmp = ((fma(-0.16666666666666666, (ky * ky), 1.0) * sin(th)) * ky) / hypot(sin(ky), sin(kx));
} else {
tmp = (sin(ky) / sqrt(((0.5 - (cos((2.0 * kx)) * 0.5)) + (0.5 - (cos((2.0 * ky)) * 0.5))))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (ky <= 0.00156) tmp = Float64(Float64(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * sin(th)) * ky) / hypot(sin(ky), sin(kx))); else tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(0.5 - Float64(cos(Float64(2.0 * kx)) * 0.5)) + Float64(0.5 - Float64(cos(Float64(2.0 * ky)) * 0.5))))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[ky, 0.00156], N[(N[(N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 0.00156:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot \sin th\right) \cdot ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\left(0.5 - \cos \left(2 \cdot kx\right) \cdot 0.5\right) + \left(0.5 - \cos \left(2 \cdot ky\right) \cdot 0.5\right)}} \cdot \sin th\\
\end{array}
\end{array}
if ky < 0.00155999999999999997Initial program 92.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6490.3
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6494.8
Applied rewrites94.8%
Taylor expanded in ky around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f6460.5
Applied rewrites60.5%
if 0.00155999999999999997 < ky Initial program 99.7%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/A
lower-*.f6499.6
Applied rewrites99.6%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/A
lower-*.f6499.0
Applied rewrites99.0%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 1.26e-144)
(sin th)
(if (<= kx 1.4e-6)
(*
(/
(sin ky)
(sqrt
(+ (* kx kx) (* (fma (* ky ky) -0.3333333333333333 1.0) (* ky ky)))))
(sin th))
(*
(* (sqrt (pow (- 0.5 (* (cos (* 2.0 kx)) 0.5)) -1.0)) (sin ky))
(sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.26e-144) {
tmp = sin(th);
} else if (kx <= 1.4e-6) {
tmp = (sin(ky) / sqrt(((kx * kx) + (fma((ky * ky), -0.3333333333333333, 1.0) * (ky * ky))))) * sin(th);
} else {
tmp = (sqrt(pow((0.5 - (cos((2.0 * kx)) * 0.5)), -1.0)) * sin(ky)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.26e-144) tmp = sin(th); elseif (kx <= 1.4e-6) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(kx * kx) + Float64(fma(Float64(ky * ky), -0.3333333333333333, 1.0) * Float64(ky * ky))))) * sin(th)); else tmp = Float64(Float64(sqrt((Float64(0.5 - Float64(cos(Float64(2.0 * kx)) * 0.5)) ^ -1.0)) * sin(ky)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.26e-144], N[Sin[th], $MachinePrecision], If[LessEqual[kx, 1.4e-6], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(kx * kx), $MachinePrecision] + N[(N[(N[(ky * ky), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[Power[N[(0.5 - N[(N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.26 \cdot 10^{-144}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;kx \leq 1.4 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{kx \cdot kx + \mathsf{fma}\left(ky \cdot ky, -0.3333333333333333, 1\right) \cdot \left(ky \cdot ky\right)}} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{{\left(0.5 - \cos \left(2 \cdot kx\right) \cdot 0.5\right)}^{-1}} \cdot \sin ky\right) \cdot \sin th\\
\end{array}
\end{array}
if kx < 1.26e-144Initial program 91.4%
Taylor expanded in kx around 0
lower-sin.f6430.7
Applied rewrites30.7%
if 1.26e-144 < kx < 1.39999999999999994e-6Initial program 99.9%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6456.5
Applied rewrites56.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6453.9
Applied rewrites53.9%
Taylor expanded in kx around 0
unpow2N/A
lower-*.f6453.9
Applied rewrites53.9%
if 1.39999999999999994e-6 < kx Initial program 99.6%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/A
lower-*.f6499.4
Applied rewrites99.4%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.4%
Taylor expanded in ky around 0
Applied rewrites57.4%
Final simplification39.8%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 1.26e-144)
(sin th)
(if (<= kx 1.4e-6)
(*
(/
(sin ky)
(sqrt
(+ (* kx kx) (* (fma (* ky ky) -0.3333333333333333 1.0) (* ky ky)))))
(sin th))
(* (/ (sin ky) (sqrt (- 0.5 (* (cos (* -2.0 kx)) 0.5)))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.26e-144) {
tmp = sin(th);
} else if (kx <= 1.4e-6) {
tmp = (sin(ky) / sqrt(((kx * kx) + (fma((ky * ky), -0.3333333333333333, 1.0) * (ky * ky))))) * sin(th);
} else {
tmp = (sin(ky) / sqrt((0.5 - (cos((-2.0 * kx)) * 0.5)))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.26e-144) tmp = sin(th); elseif (kx <= 1.4e-6) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(kx * kx) + Float64(fma(Float64(ky * ky), -0.3333333333333333, 1.0) * Float64(ky * ky))))) * sin(th)); else tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 - Float64(cos(Float64(-2.0 * kx)) * 0.5)))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.26e-144], N[Sin[th], $MachinePrecision], If[LessEqual[kx, 1.4e-6], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(kx * kx), $MachinePrecision] + N[(N[(N[(ky * ky), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 - N[(N[Cos[N[(-2.0 * kx), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.26 \cdot 10^{-144}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;kx \leq 1.4 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{kx \cdot kx + \mathsf{fma}\left(ky \cdot ky, -0.3333333333333333, 1\right) \cdot \left(ky \cdot ky\right)}} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5 - \cos \left(-2 \cdot kx\right) \cdot 0.5}} \cdot \sin th\\
\end{array}
\end{array}
if kx < 1.26e-144Initial program 91.4%
Taylor expanded in kx around 0
lower-sin.f6430.7
Applied rewrites30.7%
if 1.26e-144 < kx < 1.39999999999999994e-6Initial program 99.9%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6456.5
Applied rewrites56.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6453.9
Applied rewrites53.9%
Taylor expanded in kx around 0
unpow2N/A
lower-*.f6453.9
Applied rewrites53.9%
if 1.39999999999999994e-6 < kx Initial program 99.6%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-cos.f64N/A
count-2-revN/A
lower-*.f6499.4
Applied rewrites99.4%
Taylor expanded in ky around 0
lower-sqrt.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval57.3
Applied rewrites57.3%
(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 94.4%
Taylor expanded in kx around 0
lower-sin.f6425.8
Applied rewrites25.8%
Taylor expanded in th around 0
Applied rewrites15.1%
Taylor expanded in th around inf
Applied rewrites8.7%
Applied rewrites8.7%
herbie shell --seed 2024332
(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)))