Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.4% → 99.7%
Time: 12.8s
Alternatives: 25
Speedup: 1.2×

Specification

?
\[\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) (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:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 25 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 94.4% accurate, 1.0× speedup?

\[\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) (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}

Alternative 1: 99.7% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \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}
Derivation
  1. Initial program 94.8%

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
    2. unpow2N/A

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
    3. unpow2N/A

      \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
    4. accelerator-lowering-hypot.f64N/A

      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
    5. sin-lowering-sin.f64N/A

      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
    6. sin-lowering-sin.f6499.8

      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
  4. Applied egg-rr99.8%

    \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
  5. Add Preprocessing

Alternative 2: 82.7% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ t_2 := {\sin ky}^{2}\\ t_3 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + t\_2}}\\ \mathbf{if}\;t\_3 \leq -0.999:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{t\_2 + kx \cdot kx}}\\ \mathbf{elif}\;t\_3 \leq -0.2:\\ \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-29}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_3 \leq 0.86:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\ \mathbf{elif}\;t\_3 \leq 2:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (* (sin th) (/ (sin ky) (hypot ky (sin kx)))))
        (t_2 (pow (sin ky) 2.0))
        (t_3 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) t_2)))))
   (if (<= t_3 -0.999)
     (* (sin th) (/ (sin ky) (sqrt (+ t_2 (* kx kx)))))
     (if (<= t_3 -0.2)
       (*
        (sin ky)
        (/
         th
         (sqrt
          (fma (- 1.0 (cos (+ ky ky))) 0.5 (+ 0.5 (* -0.5 (cos (+ kx kx))))))))
       (if (<= t_3 2e-29)
         t_1
         (if (<= t_3 0.86)
           (* (/ (sin ky) (hypot (sin ky) (sin kx))) th)
           (if (<= t_3 2.0) (sin th) t_1)))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
	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.999) {
		tmp = sin(th) * (sin(ky) / sqrt((t_2 + (kx * kx))));
	} else if (t_3 <= -0.2) {
		tmp = sin(ky) * (th / sqrt(fma((1.0 - cos((ky + ky))), 0.5, (0.5 + (-0.5 * cos((kx + kx)))))));
	} else if (t_3 <= 2e-29) {
		tmp = t_1;
	} else if (t_3 <= 0.86) {
		tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
	} else if (t_3 <= 2.0) {
		tmp = sin(th);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(kx, ky, th)
	t_1 = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx))))
	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.999)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(Float64(t_2 + Float64(kx * kx)))));
	elseif (t_3 <= -0.2)
		tmp = Float64(sin(ky) * Float64(th / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx))))))));
	elseif (t_3 <= 2e-29)
		tmp = t_1;
	elseif (t_3 <= 0.86)
		tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th);
	elseif (t_3 <= 2.0)
		tmp = sin(th);
	else
		tmp = t_1;
	end
	return tmp
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $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.999], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$2 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -0.2], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e-29], t$95$1, If[LessEqual[t$95$3, 0.86], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], If[LessEqual[t$95$3, 2.0], N[Sin[th], $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
t_2 := {\sin ky}^{2}\\
t_3 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + t\_2}}\\
\mathbf{if}\;t\_3 \leq -0.999:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{t\_2 + kx \cdot kx}}\\

\mathbf{elif}\;t\_3 \leq -0.2:\\
\;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\

\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-29}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_3 \leq 0.86:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\

\mathbf{elif}\;t\_3 \leq 2:\\
\;\;\;\;\sin th\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. 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.998999999999999999

    1. Initial program 82.5%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{kx}^{2}} + {\sin ky}^{2}}} \cdot \sin th \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot \sin th \]
      2. *-lowering-*.f6482.5

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot \sin th \]
    5. Simplified82.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot \sin th \]

    if -0.998999999999999999 < (/.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.20000000000000001

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. accelerator-lowering-hypot.f64N/A

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
      5. sin-lowering-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
      6. sin-lowering-sin.f6499.5

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
    4. Applied egg-rr99.5%

      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
    5. Taylor expanded in th around 0

      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
    6. Step-by-step derivation
      1. Simplified51.8%

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
      2. Step-by-step derivation
        1. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{\sin ky \cdot th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
        2. associate-/l*N/A

          \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
        3. *-lowering-*.f64N/A

          \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
        4. sin-lowering-sin.f64N/A

          \[\leadsto \color{blue}{\sin ky} \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \]
        5. /-lowering-/.f64N/A

          \[\leadsto \sin ky \cdot \color{blue}{\frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
        6. sqrt-lowering-sqrt.f64N/A

          \[\leadsto \sin ky \cdot \frac{th}{\color{blue}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
        7. sin-multN/A

          \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + \sin kx \cdot \sin kx}} \]
        8. div-invN/A

          \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + \sin kx \cdot \sin kx}} \]
        9. metadata-evalN/A

          \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + \sin kx \cdot \sin kx}} \]
        10. accelerator-lowering-fma.f64N/A

          \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, \sin kx \cdot \sin kx\right)}}} \]
      3. Applied egg-rr51.7%

        \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \]

      if -0.20000000000000001 < (/.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.99999999999999989e-29 or 2 < (/.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. Initial program 95.7%

        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
        2. unpow2N/A

          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
        3. unpow2N/A

          \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
        4. accelerator-lowering-hypot.f64N/A

          \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
        5. sin-lowering-sin.f64N/A

          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
        6. sin-lowering-sin.f6499.7

          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
      4. Applied egg-rr99.7%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
      5. Taylor expanded in ky around 0

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \cdot \sin th \]
      6. Step-by-step derivation
        1. Simplified94.8%

          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \cdot \sin th \]

        if 1.99999999999999989e-29 < (/.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.859999999999999987

        1. Initial program 99.4%

          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
          2. unpow2N/A

            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
          3. unpow2N/A

            \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
          4. accelerator-lowering-hypot.f64N/A

            \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
          5. sin-lowering-sin.f64N/A

            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
          6. sin-lowering-sin.f6499.5

            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
        4. Applied egg-rr99.5%

          \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
        5. Taylor expanded in th around 0

          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
        6. Step-by-step derivation
          1. Simplified65.0%

            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]

          if 0.859999999999999987 < (/.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

          1. Initial program 99.8%

            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
          2. Add Preprocessing
          3. Taylor expanded in kx around 0

            \[\leadsto \color{blue}{\sin th} \]
          4. Step-by-step derivation
            1. sin-lowering-sin.f6487.2

              \[\leadsto \color{blue}{\sin th} \]
          5. Simplified87.2%

            \[\leadsto \color{blue}{\sin th} \]
        7. Recombined 5 regimes into one program.
        8. Final simplification83.6%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.999:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{{\sin ky}^{2} + kx \cdot kx}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.2:\\ \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-29}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.86:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \end{array} \]
        9. Add Preprocessing

        Alternative 3: 78.1% accurate, 0.2× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ t_2 := 1 - \cos \left(ky + ky\right)\\ t_3 := \sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{if}\;t\_1 \leq -0.999:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\ \mathbf{elif}\;t\_1 \leq -0.2:\\ \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-29}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_1 \leq 0.86:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\ \mathbf{elif}\;t\_1 \leq 2:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \end{array} \]
        (FPCore (kx ky th)
         :precision binary64
         (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
                (t_2 (- 1.0 (cos (+ ky ky))))
                (t_3 (* (sin th) (/ (sin ky) (hypot ky (sin kx))))))
           (if (<= t_1 -0.999)
             (*
              (sin th)
              (/
               (sin ky)
               (sqrt
                (fma t_2 0.5 (* (* kx kx) (fma (* kx kx) -0.3333333333333333 1.0))))))
             (if (<= t_1 -0.2)
               (*
                (sin ky)
                (/ th (sqrt (fma t_2 0.5 (+ 0.5 (* -0.5 (cos (+ kx kx))))))))
               (if (<= t_1 2e-29)
                 t_3
                 (if (<= t_1 0.86)
                   (* (/ (sin ky) (hypot (sin ky) (sin kx))) th)
                   (if (<= t_1 2.0) (sin th) t_3)))))))
        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 t_2 = 1.0 - cos((ky + ky));
        	double t_3 = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
        	double tmp;
        	if (t_1 <= -0.999) {
        		tmp = sin(th) * (sin(ky) / sqrt(fma(t_2, 0.5, ((kx * kx) * fma((kx * kx), -0.3333333333333333, 1.0)))));
        	} else if (t_1 <= -0.2) {
        		tmp = sin(ky) * (th / sqrt(fma(t_2, 0.5, (0.5 + (-0.5 * cos((kx + kx)))))));
        	} else if (t_1 <= 2e-29) {
        		tmp = t_3;
        	} else if (t_1 <= 0.86) {
        		tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
        	} else if (t_1 <= 2.0) {
        		tmp = sin(th);
        	} else {
        		tmp = t_3;
        	}
        	return tmp;
        }
        
        function code(kx, ky, th)
        	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
        	t_2 = Float64(1.0 - cos(Float64(ky + ky)))
        	t_3 = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx))))
        	tmp = 0.0
        	if (t_1 <= -0.999)
        		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(t_2, 0.5, Float64(Float64(kx * kx) * fma(Float64(kx * kx), -0.3333333333333333, 1.0))))));
        	elseif (t_1 <= -0.2)
        		tmp = Float64(sin(ky) * Float64(th / sqrt(fma(t_2, 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx))))))));
        	elseif (t_1 <= 2e-29)
        		tmp = t_3;
        	elseif (t_1 <= 0.86)
        		tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th);
        	elseif (t_1 <= 2.0)
        		tmp = sin(th);
        	else
        		tmp = t_3;
        	end
        	return 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]}, Block[{t$95$2 = N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.999], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$2 * 0.5 + N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.2], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[(t$95$2 * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-29], t$95$3, If[LessEqual[t$95$1, 0.86], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], t$95$3]]]]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
        t_2 := 1 - \cos \left(ky + ky\right)\\
        t_3 := \sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
        \mathbf{if}\;t\_1 \leq -0.999:\\
        \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\
        
        \mathbf{elif}\;t\_1 \leq -0.2:\\
        \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\
        
        \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-29}:\\
        \;\;\;\;t\_3\\
        
        \mathbf{elif}\;t\_1 \leq 0.86:\\
        \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
        
        \mathbf{elif}\;t\_1 \leq 2:\\
        \;\;\;\;\sin th\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_3\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 5 regimes
        2. 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.998999999999999999

          1. Initial program 82.5%

            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. sqrt-lowering-sqrt.f64N/A

              \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
            2. +-commutativeN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
            3. unpow2N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
            4. sin-multN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
            5. div-invN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
            6. metadata-evalN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
            7. accelerator-lowering-fma.f64N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
            8. count-2N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
            9. +-inversesN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
            10. cos-0N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
            11. --lowering--.f64N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
            12. count-2N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
            13. cos-lowering-cos.f64N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
            14. +-lowering-+.f64N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
            15. unpow2N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
            16. sqr-sin-aN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
            17. cancel-sign-sub-invN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
            18. +-lowering-+.f64N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
            19. *-lowering-*.f64N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
            20. metadata-evalN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
            21. count-2N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
            22. cos-lowering-cos.f64N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
            23. +-lowering-+.f6463.6

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
          4. Applied egg-rr63.6%

            \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
          5. Taylor expanded in kx around 0

            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)}\right)}} \cdot \sin th \]
          6. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)}\right)}} \cdot \sin th \]
            2. unpow2N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)\right)}} \cdot \sin th \]
            3. *-lowering-*.f64N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)\right)}} \cdot \sin th \]
            4. +-commutativeN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\left(\frac{-1}{3} \cdot {kx}^{2} + 1\right)}\right)}} \cdot \sin th \]
            5. *-commutativeN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \left(\color{blue}{{kx}^{2} \cdot \frac{-1}{3}} + 1\right)\right)}} \cdot \sin th \]
            6. accelerator-lowering-fma.f64N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{-1}{3}, 1\right)}\right)}} \cdot \sin th \]
            7. unpow2N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{-1}{3}, 1\right)\right)}} \cdot \sin th \]
            8. *-lowering-*.f6464.1

              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, -0.3333333333333333, 1\right)\right)}} \cdot \sin th \]
          7. Simplified64.1%

            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{\left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)}\right)}} \cdot \sin th \]

          if -0.998999999999999999 < (/.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.20000000000000001

          1. Initial program 99.6%

            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
            2. unpow2N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
            3. unpow2N/A

              \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
            4. accelerator-lowering-hypot.f64N/A

              \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
            5. sin-lowering-sin.f64N/A

              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
            6. sin-lowering-sin.f6499.5

              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
          4. Applied egg-rr99.5%

            \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
          5. Taylor expanded in th around 0

            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
          6. Step-by-step derivation
            1. Simplified51.8%

              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
            2. Step-by-step derivation
              1. associate-*l/N/A

                \[\leadsto \color{blue}{\frac{\sin ky \cdot th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
              2. associate-/l*N/A

                \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
              3. *-lowering-*.f64N/A

                \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
              4. sin-lowering-sin.f64N/A

                \[\leadsto \color{blue}{\sin ky} \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \]
              5. /-lowering-/.f64N/A

                \[\leadsto \sin ky \cdot \color{blue}{\frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
              6. sqrt-lowering-sqrt.f64N/A

                \[\leadsto \sin ky \cdot \frac{th}{\color{blue}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
              7. sin-multN/A

                \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + \sin kx \cdot \sin kx}} \]
              8. div-invN/A

                \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + \sin kx \cdot \sin kx}} \]
              9. metadata-evalN/A

                \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + \sin kx \cdot \sin kx}} \]
              10. accelerator-lowering-fma.f64N/A

                \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, \sin kx \cdot \sin kx\right)}}} \]
            3. Applied egg-rr51.7%

              \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \]

            if -0.20000000000000001 < (/.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.99999999999999989e-29 or 2 < (/.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. Initial program 95.7%

              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
              2. unpow2N/A

                \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
              3. unpow2N/A

                \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
              4. accelerator-lowering-hypot.f64N/A

                \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
              5. sin-lowering-sin.f64N/A

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
              6. sin-lowering-sin.f6499.7

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
            4. Applied egg-rr99.7%

              \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
            5. Taylor expanded in ky around 0

              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \cdot \sin th \]
            6. Step-by-step derivation
              1. Simplified94.8%

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \cdot \sin th \]

              if 1.99999999999999989e-29 < (/.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.859999999999999987

              1. Initial program 99.4%

                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
              2. Add Preprocessing
              3. Step-by-step derivation
                1. +-commutativeN/A

                  \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                2. unpow2N/A

                  \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                3. unpow2N/A

                  \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                4. accelerator-lowering-hypot.f64N/A

                  \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                5. sin-lowering-sin.f64N/A

                  \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                6. sin-lowering-sin.f6499.5

                  \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
              4. Applied egg-rr99.5%

                \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
              5. Taylor expanded in th around 0

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
              6. Step-by-step derivation
                1. Simplified65.0%

                  \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]

                if 0.859999999999999987 < (/.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

                1. Initial program 99.8%

                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                2. Add Preprocessing
                3. Taylor expanded in kx around 0

                  \[\leadsto \color{blue}{\sin th} \]
                4. Step-by-step derivation
                  1. sin-lowering-sin.f6487.2

                    \[\leadsto \color{blue}{\sin th} \]
                5. Simplified87.2%

                  \[\leadsto \color{blue}{\sin th} \]
              7. Recombined 5 regimes into one program.
              8. Final simplification80.0%

                \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.999:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.2:\\ \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-29}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.86:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \end{array} \]
              9. Add Preprocessing

              Alternative 4: 78.3% accurate, 0.2× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ t_2 := 1 - \cos \left(ky + ky\right)\\ t_3 := \sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ t_4 := \sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{if}\;t\_1 \leq -0.999:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\ \mathbf{elif}\;t\_1 \leq -0.2:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_1 \leq 10^{-15}:\\ \;\;\;\;t\_4\\ \mathbf{elif}\;t\_1 \leq 0.86:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_1 \leq 2:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;t\_4\\ \end{array} \end{array} \]
              (FPCore (kx ky th)
               :precision binary64
               (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
                      (t_2 (- 1.0 (cos (+ ky ky))))
                      (t_3
                       (*
                        (sin ky)
                        (/ th (sqrt (fma t_2 0.5 (+ 0.5 (* -0.5 (cos (+ kx kx)))))))))
                      (t_4 (* (sin th) (/ (sin ky) (hypot ky (sin kx))))))
                 (if (<= t_1 -0.999)
                   (*
                    (sin th)
                    (/
                     (sin ky)
                     (sqrt
                      (fma t_2 0.5 (* (* kx kx) (fma (* kx kx) -0.3333333333333333 1.0))))))
                   (if (<= t_1 -0.2)
                     t_3
                     (if (<= t_1 1e-15)
                       t_4
                       (if (<= t_1 0.86) t_3 (if (<= t_1 2.0) (sin th) t_4)))))))
              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 t_2 = 1.0 - cos((ky + ky));
              	double t_3 = sin(ky) * (th / sqrt(fma(t_2, 0.5, (0.5 + (-0.5 * cos((kx + kx)))))));
              	double t_4 = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
              	double tmp;
              	if (t_1 <= -0.999) {
              		tmp = sin(th) * (sin(ky) / sqrt(fma(t_2, 0.5, ((kx * kx) * fma((kx * kx), -0.3333333333333333, 1.0)))));
              	} else if (t_1 <= -0.2) {
              		tmp = t_3;
              	} else if (t_1 <= 1e-15) {
              		tmp = t_4;
              	} else if (t_1 <= 0.86) {
              		tmp = t_3;
              	} else if (t_1 <= 2.0) {
              		tmp = sin(th);
              	} else {
              		tmp = t_4;
              	}
              	return tmp;
              }
              
              function code(kx, ky, th)
              	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
              	t_2 = Float64(1.0 - cos(Float64(ky + ky)))
              	t_3 = Float64(sin(ky) * Float64(th / sqrt(fma(t_2, 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx))))))))
              	t_4 = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx))))
              	tmp = 0.0
              	if (t_1 <= -0.999)
              		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(t_2, 0.5, Float64(Float64(kx * kx) * fma(Float64(kx * kx), -0.3333333333333333, 1.0))))));
              	elseif (t_1 <= -0.2)
              		tmp = t_3;
              	elseif (t_1 <= 1e-15)
              		tmp = t_4;
              	elseif (t_1 <= 0.86)
              		tmp = t_3;
              	elseif (t_1 <= 2.0)
              		tmp = sin(th);
              	else
              		tmp = t_4;
              	end
              	return 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]}, Block[{t$95$2 = N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[(t$95$2 * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.999], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$2 * 0.5 + N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.2], t$95$3, If[LessEqual[t$95$1, 1e-15], t$95$4, If[LessEqual[t$95$1, 0.86], t$95$3, If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], t$95$4]]]]]]]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
              t_2 := 1 - \cos \left(ky + ky\right)\\
              t_3 := \sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\
              t_4 := \sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
              \mathbf{if}\;t\_1 \leq -0.999:\\
              \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\
              
              \mathbf{elif}\;t\_1 \leq -0.2:\\
              \;\;\;\;t\_3\\
              
              \mathbf{elif}\;t\_1 \leq 10^{-15}:\\
              \;\;\;\;t\_4\\
              
              \mathbf{elif}\;t\_1 \leq 0.86:\\
              \;\;\;\;t\_3\\
              
              \mathbf{elif}\;t\_1 \leq 2:\\
              \;\;\;\;\sin th\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_4\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 4 regimes
              2. 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.998999999999999999

                1. Initial program 82.5%

                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. sqrt-lowering-sqrt.f64N/A

                    \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                  2. +-commutativeN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                  3. unpow2N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                  4. sin-multN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                  5. div-invN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                  6. metadata-evalN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                  7. accelerator-lowering-fma.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                  8. count-2N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                  9. +-inversesN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                  10. cos-0N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                  11. --lowering--.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                  12. count-2N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                  13. cos-lowering-cos.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                  14. +-lowering-+.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                  15. unpow2N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                  16. sqr-sin-aN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                  17. cancel-sign-sub-invN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                  18. +-lowering-+.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                  19. *-lowering-*.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                  20. metadata-evalN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                  21. count-2N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                  22. cos-lowering-cos.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                  23. +-lowering-+.f6463.6

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                4. Applied egg-rr63.6%

                  \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                5. Taylor expanded in kx around 0

                  \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)}\right)}} \cdot \sin th \]
                6. Step-by-step derivation
                  1. *-lowering-*.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)}\right)}} \cdot \sin th \]
                  2. unpow2N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)\right)}} \cdot \sin th \]
                  3. *-lowering-*.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)\right)}} \cdot \sin th \]
                  4. +-commutativeN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\left(\frac{-1}{3} \cdot {kx}^{2} + 1\right)}\right)}} \cdot \sin th \]
                  5. *-commutativeN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \left(\color{blue}{{kx}^{2} \cdot \frac{-1}{3}} + 1\right)\right)}} \cdot \sin th \]
                  6. accelerator-lowering-fma.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{-1}{3}, 1\right)}\right)}} \cdot \sin th \]
                  7. unpow2N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{-1}{3}, 1\right)\right)}} \cdot \sin th \]
                  8. *-lowering-*.f6464.1

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, -0.3333333333333333, 1\right)\right)}} \cdot \sin th \]
                7. Simplified64.1%

                  \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{\left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)}\right)}} \cdot \sin th \]

                if -0.998999999999999999 < (/.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.20000000000000001 or 1.0000000000000001e-15 < (/.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.859999999999999987

                1. Initial program 99.5%

                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                  2. unpow2N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                  3. unpow2N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                  4. accelerator-lowering-hypot.f64N/A

                    \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                  5. sin-lowering-sin.f64N/A

                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                  6. sin-lowering-sin.f6499.5

                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                4. Applied egg-rr99.5%

                  \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                5. Taylor expanded in th around 0

                  \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                6. Step-by-step derivation
                  1. Simplified55.8%

                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                  2. Step-by-step derivation
                    1. associate-*l/N/A

                      \[\leadsto \color{blue}{\frac{\sin ky \cdot th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                    2. associate-/l*N/A

                      \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                    3. *-lowering-*.f64N/A

                      \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                    4. sin-lowering-sin.f64N/A

                      \[\leadsto \color{blue}{\sin ky} \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \]
                    5. /-lowering-/.f64N/A

                      \[\leadsto \sin ky \cdot \color{blue}{\frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                    6. sqrt-lowering-sqrt.f64N/A

                      \[\leadsto \sin ky \cdot \frac{th}{\color{blue}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                    7. sin-multN/A

                      \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + \sin kx \cdot \sin kx}} \]
                    8. div-invN/A

                      \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + \sin kx \cdot \sin kx}} \]
                    9. metadata-evalN/A

                      \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + \sin kx \cdot \sin kx}} \]
                    10. accelerator-lowering-fma.f64N/A

                      \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, \sin kx \cdot \sin kx\right)}}} \]
                  3. Applied egg-rr55.7%

                    \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \]

                  if -0.20000000000000001 < (/.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.0000000000000001e-15 or 2 < (/.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. Initial program 95.8%

                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                  2. Add Preprocessing
                  3. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                    2. unpow2N/A

                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                    3. unpow2N/A

                      \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                    4. accelerator-lowering-hypot.f64N/A

                      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                    5. sin-lowering-sin.f64N/A

                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                    6. sin-lowering-sin.f6499.7

                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                  4. Applied egg-rr99.7%

                    \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                  5. Taylor expanded in ky around 0

                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \cdot \sin th \]
                  6. Step-by-step derivation
                    1. Simplified95.0%

                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \cdot \sin th \]

                    if 0.859999999999999987 < (/.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

                    1. Initial program 99.8%

                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                    2. Add Preprocessing
                    3. Taylor expanded in kx around 0

                      \[\leadsto \color{blue}{\sin th} \]
                    4. Step-by-step derivation
                      1. sin-lowering-sin.f6487.2

                        \[\leadsto \color{blue}{\sin th} \]
                    5. Simplified87.2%

                      \[\leadsto \color{blue}{\sin th} \]
                  7. Recombined 4 regimes into one program.
                  8. Final simplification80.0%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.999:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.2:\\ \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-15}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.86:\\ \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \end{array} \]
                  9. Add Preprocessing

                  Alternative 5: 67.3% accurate, 0.2× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ t_2 := 1 - \cos \left(ky + ky\right)\\ t_3 := \sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{if}\;t\_1 \leq -0.999:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\ \mathbf{elif}\;t\_1 \leq -0.5:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;t\_1 \leq 10^{-15}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{elif}\;t\_1 \leq 0.86:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                  (FPCore (kx ky th)
                   :precision binary64
                   (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
                          (t_2 (- 1.0 (cos (+ ky ky))))
                          (t_3
                           (*
                            (sin ky)
                            (/ th (sqrt (fma t_2 0.5 (+ 0.5 (* -0.5 (cos (+ kx kx))))))))))
                     (if (<= t_1 -0.999)
                       (*
                        (sin th)
                        (/
                         (sin ky)
                         (sqrt
                          (fma t_2 0.5 (* (* kx kx) (fma (* kx kx) -0.3333333333333333 1.0))))))
                       (if (<= t_1 -0.5)
                         t_3
                         (if (<= t_1 2e-176)
                           (* (sin ky) (/ (sin th) (sqrt (fma -0.5 (cos (* kx -2.0)) 0.5))))
                           (if (<= t_1 1e-15)
                             (* (sin th) (/ (sin ky) (sin kx)))
                             (if (<= t_1 0.86) t_3 (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 t_2 = 1.0 - cos((ky + ky));
                  	double t_3 = sin(ky) * (th / sqrt(fma(t_2, 0.5, (0.5 + (-0.5 * cos((kx + kx)))))));
                  	double tmp;
                  	if (t_1 <= -0.999) {
                  		tmp = sin(th) * (sin(ky) / sqrt(fma(t_2, 0.5, ((kx * kx) * fma((kx * kx), -0.3333333333333333, 1.0)))));
                  	} else if (t_1 <= -0.5) {
                  		tmp = t_3;
                  	} else if (t_1 <= 2e-176) {
                  		tmp = sin(ky) * (sin(th) / sqrt(fma(-0.5, cos((kx * -2.0)), 0.5)));
                  	} else if (t_1 <= 1e-15) {
                  		tmp = sin(th) * (sin(ky) / sin(kx));
                  	} else if (t_1 <= 0.86) {
                  		tmp = t_3;
                  	} else {
                  		tmp = sin(th);
                  	}
                  	return tmp;
                  }
                  
                  function code(kx, ky, th)
                  	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
                  	t_2 = Float64(1.0 - cos(Float64(ky + ky)))
                  	t_3 = Float64(sin(ky) * Float64(th / sqrt(fma(t_2, 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx))))))))
                  	tmp = 0.0
                  	if (t_1 <= -0.999)
                  		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(t_2, 0.5, Float64(Float64(kx * kx) * fma(Float64(kx * kx), -0.3333333333333333, 1.0))))));
                  	elseif (t_1 <= -0.5)
                  		tmp = t_3;
                  	elseif (t_1 <= 2e-176)
                  		tmp = Float64(sin(ky) * Float64(sin(th) / sqrt(fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
                  	elseif (t_1 <= 1e-15)
                  		tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx)));
                  	elseif (t_1 <= 0.86)
                  		tmp = t_3;
                  	else
                  		tmp = sin(th);
                  	end
                  	return 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]}, Block[{t$95$2 = N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[(t$95$2 * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.999], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$2 * 0.5 + N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.5], t$95$3, If[LessEqual[t$95$1, 2e-176], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-15], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.86], t$95$3, N[Sin[th], $MachinePrecision]]]]]]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
                  t_2 := 1 - \cos \left(ky + ky\right)\\
                  t_3 := \sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\
                  \mathbf{if}\;t\_1 \leq -0.999:\\
                  \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\
                  
                  \mathbf{elif}\;t\_1 \leq -0.5:\\
                  \;\;\;\;t\_3\\
                  
                  \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\
                  \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\
                  
                  \mathbf{elif}\;t\_1 \leq 10^{-15}:\\
                  \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
                  
                  \mathbf{elif}\;t\_1 \leq 0.86:\\
                  \;\;\;\;t\_3\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\sin th\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 5 regimes
                  2. 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.998999999999999999

                    1. Initial program 82.5%

                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                    2. Add Preprocessing
                    3. Step-by-step derivation
                      1. sqrt-lowering-sqrt.f64N/A

                        \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                      2. +-commutativeN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                      3. unpow2N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                      4. sin-multN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                      5. div-invN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                      6. metadata-evalN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                      7. accelerator-lowering-fma.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                      8. count-2N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                      9. +-inversesN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                      10. cos-0N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                      11. --lowering--.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                      12. count-2N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                      13. cos-lowering-cos.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                      14. +-lowering-+.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                      15. unpow2N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                      16. sqr-sin-aN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                      17. cancel-sign-sub-invN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                      18. +-lowering-+.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                      19. *-lowering-*.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                      20. metadata-evalN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                      21. count-2N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                      22. cos-lowering-cos.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                      23. +-lowering-+.f6463.6

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                    4. Applied egg-rr63.6%

                      \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                    5. Taylor expanded in kx around 0

                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)}\right)}} \cdot \sin th \]
                    6. Step-by-step derivation
                      1. *-lowering-*.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)}\right)}} \cdot \sin th \]
                      2. unpow2N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)\right)}} \cdot \sin th \]
                      3. *-lowering-*.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)\right)}} \cdot \sin th \]
                      4. +-commutativeN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\left(\frac{-1}{3} \cdot {kx}^{2} + 1\right)}\right)}} \cdot \sin th \]
                      5. *-commutativeN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \left(\color{blue}{{kx}^{2} \cdot \frac{-1}{3}} + 1\right)\right)}} \cdot \sin th \]
                      6. accelerator-lowering-fma.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{-1}{3}, 1\right)}\right)}} \cdot \sin th \]
                      7. unpow2N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{-1}{3}, 1\right)\right)}} \cdot \sin th \]
                      8. *-lowering-*.f6464.1

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, -0.3333333333333333, 1\right)\right)}} \cdot \sin th \]
                    7. Simplified64.1%

                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{\left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)}\right)}} \cdot \sin th \]

                    if -0.998999999999999999 < (/.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.5 or 1.0000000000000001e-15 < (/.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.859999999999999987

                    1. Initial program 99.5%

                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                    2. Add Preprocessing
                    3. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                      2. unpow2N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                      3. unpow2N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                      4. accelerator-lowering-hypot.f64N/A

                        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                      5. sin-lowering-sin.f64N/A

                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                      6. sin-lowering-sin.f6499.5

                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                    4. Applied egg-rr99.5%

                      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                    5. Taylor expanded in th around 0

                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                    6. Step-by-step derivation
                      1. Simplified57.1%

                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                      2. Step-by-step derivation
                        1. associate-*l/N/A

                          \[\leadsto \color{blue}{\frac{\sin ky \cdot th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                        2. associate-/l*N/A

                          \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                        3. *-lowering-*.f64N/A

                          \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                        4. sin-lowering-sin.f64N/A

                          \[\leadsto \color{blue}{\sin ky} \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \]
                        5. /-lowering-/.f64N/A

                          \[\leadsto \sin ky \cdot \color{blue}{\frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                        6. sqrt-lowering-sqrt.f64N/A

                          \[\leadsto \sin ky \cdot \frac{th}{\color{blue}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                        7. sin-multN/A

                          \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + \sin kx \cdot \sin kx}} \]
                        8. div-invN/A

                          \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + \sin kx \cdot \sin kx}} \]
                        9. metadata-evalN/A

                          \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + \sin kx \cdot \sin kx}} \]
                        10. accelerator-lowering-fma.f64N/A

                          \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, \sin kx \cdot \sin kx\right)}}} \]
                      3. Applied egg-rr57.0%

                        \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \]

                      if -0.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))))) < 2e-176

                      1. Initial program 99.8%

                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                      2. Add Preprocessing
                      3. Step-by-step derivation
                        1. associate-*l/N/A

                          \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        2. associate-/l*N/A

                          \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        3. *-commutativeN/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                        4. *-lowering-*.f64N/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                      4. Applied egg-rr82.5%

                        \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \sin ky} \]
                      5. Taylor expanded in ky around 0

                        \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \cdot \sin ky \]
                      6. Step-by-step derivation
                        1. +-commutativeN/A

                          \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \cdot \sin ky \]
                        2. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \cdot \sin ky \]
                        3. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \cdot \sin ky \]
                        4. accelerator-lowering-fma.f64N/A

                          \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \cdot \sin ky \]
                        5. cos-negN/A

                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                        6. cos-lowering-cos.f64N/A

                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                        7. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                        8. *-lowering-*.f6474.6

                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \cdot \sin ky \]
                      7. Simplified74.6%

                        \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \cdot \sin ky \]

                      if 2e-176 < (/.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.0000000000000001e-15

                      1. Initial program 99.7%

                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                      2. Add Preprocessing
                      3. Taylor expanded in ky around 0

                        \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                      4. Step-by-step derivation
                        1. sin-lowering-sin.f6476.8

                          \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                      5. Simplified76.8%

                        \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]

                      if 0.859999999999999987 < (/.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. Initial program 94.0%

                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                      2. Add Preprocessing
                      3. Taylor expanded in kx around 0

                        \[\leadsto \color{blue}{\sin th} \]
                      4. Step-by-step derivation
                        1. sin-lowering-sin.f6485.2

                          \[\leadsto \color{blue}{\sin th} \]
                      5. Simplified85.2%

                        \[\leadsto \color{blue}{\sin th} \]
                    7. Recombined 5 regimes into one program.
                    8. Final simplification72.5%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.999:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.5:\\ \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-15}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.86:\\ \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                    9. Add Preprocessing

                    Alternative 6: 67.3% accurate, 0.2× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ t_2 := 1 - \cos \left(ky + ky\right)\\ t_3 := \sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{if}\;t\_1 \leq -0.999:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;t\_1 \leq -0.5:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;t\_1 \leq 10^{-15}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{elif}\;t\_1 \leq 0.86:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                    (FPCore (kx ky th)
                     :precision binary64
                     (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
                            (t_2 (- 1.0 (cos (+ ky ky))))
                            (t_3
                             (*
                              (sin ky)
                              (/ th (sqrt (fma t_2 0.5 (+ 0.5 (* -0.5 (cos (+ kx kx))))))))))
                       (if (<= t_1 -0.999)
                         (* (sin th) (/ (sin ky) (sqrt (fma t_2 0.5 (* kx kx)))))
                         (if (<= t_1 -0.5)
                           t_3
                           (if (<= t_1 2e-176)
                             (* (sin ky) (/ (sin th) (sqrt (fma -0.5 (cos (* kx -2.0)) 0.5))))
                             (if (<= t_1 1e-15)
                               (* (sin th) (/ (sin ky) (sin kx)))
                               (if (<= t_1 0.86) t_3 (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 t_2 = 1.0 - cos((ky + ky));
                    	double t_3 = sin(ky) * (th / sqrt(fma(t_2, 0.5, (0.5 + (-0.5 * cos((kx + kx)))))));
                    	double tmp;
                    	if (t_1 <= -0.999) {
                    		tmp = sin(th) * (sin(ky) / sqrt(fma(t_2, 0.5, (kx * kx))));
                    	} else if (t_1 <= -0.5) {
                    		tmp = t_3;
                    	} else if (t_1 <= 2e-176) {
                    		tmp = sin(ky) * (sin(th) / sqrt(fma(-0.5, cos((kx * -2.0)), 0.5)));
                    	} else if (t_1 <= 1e-15) {
                    		tmp = sin(th) * (sin(ky) / sin(kx));
                    	} else if (t_1 <= 0.86) {
                    		tmp = t_3;
                    	} else {
                    		tmp = sin(th);
                    	}
                    	return tmp;
                    }
                    
                    function code(kx, ky, th)
                    	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
                    	t_2 = Float64(1.0 - cos(Float64(ky + ky)))
                    	t_3 = Float64(sin(ky) * Float64(th / sqrt(fma(t_2, 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx))))))))
                    	tmp = 0.0
                    	if (t_1 <= -0.999)
                    		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(t_2, 0.5, Float64(kx * kx)))));
                    	elseif (t_1 <= -0.5)
                    		tmp = t_3;
                    	elseif (t_1 <= 2e-176)
                    		tmp = Float64(sin(ky) * Float64(sin(th) / sqrt(fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
                    	elseif (t_1 <= 1e-15)
                    		tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx)));
                    	elseif (t_1 <= 0.86)
                    		tmp = t_3;
                    	else
                    		tmp = sin(th);
                    	end
                    	return 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]}, Block[{t$95$2 = N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[(t$95$2 * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.999], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$2 * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.5], t$95$3, If[LessEqual[t$95$1, 2e-176], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-15], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.86], t$95$3, N[Sin[th], $MachinePrecision]]]]]]]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
                    t_2 := 1 - \cos \left(ky + ky\right)\\
                    t_3 := \sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\
                    \mathbf{if}\;t\_1 \leq -0.999:\\
                    \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(t\_2, 0.5, kx \cdot kx\right)}}\\
                    
                    \mathbf{elif}\;t\_1 \leq -0.5:\\
                    \;\;\;\;t\_3\\
                    
                    \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\
                    \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\
                    
                    \mathbf{elif}\;t\_1 \leq 10^{-15}:\\
                    \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
                    
                    \mathbf{elif}\;t\_1 \leq 0.86:\\
                    \;\;\;\;t\_3\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\sin th\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 5 regimes
                    2. 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.998999999999999999

                      1. Initial program 82.5%

                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                      2. Add Preprocessing
                      3. Step-by-step derivation
                        1. sqrt-lowering-sqrt.f64N/A

                          \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                        2. +-commutativeN/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                        3. unpow2N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                        4. sin-multN/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                        5. div-invN/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                        6. metadata-evalN/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                        7. accelerator-lowering-fma.f64N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                        8. count-2N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                        9. +-inversesN/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                        10. cos-0N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                        11. --lowering--.f64N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                        12. count-2N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                        13. cos-lowering-cos.f64N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                        14. +-lowering-+.f64N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                        15. unpow2N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                        16. sqr-sin-aN/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                        17. cancel-sign-sub-invN/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                        18. +-lowering-+.f64N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                        19. *-lowering-*.f64N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                        20. metadata-evalN/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                        21. count-2N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                        22. cos-lowering-cos.f64N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                        23. +-lowering-+.f6463.6

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                      4. Applied egg-rr63.6%

                        \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                      5. Taylor expanded in kx around 0

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
                      6. Step-by-step derivation
                        1. unpow2N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
                        2. *-lowering-*.f6464.1

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
                      7. Simplified64.1%

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]

                      if -0.998999999999999999 < (/.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.5 or 1.0000000000000001e-15 < (/.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.859999999999999987

                      1. Initial program 99.5%

                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                      2. Add Preprocessing
                      3. Step-by-step derivation
                        1. +-commutativeN/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                        2. unpow2N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                        3. unpow2N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                        4. accelerator-lowering-hypot.f64N/A

                          \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                        5. sin-lowering-sin.f64N/A

                          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                        6. sin-lowering-sin.f6499.5

                          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                      4. Applied egg-rr99.5%

                        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                      5. Taylor expanded in th around 0

                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                      6. Step-by-step derivation
                        1. Simplified57.1%

                          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                        2. Step-by-step derivation
                          1. associate-*l/N/A

                            \[\leadsto \color{blue}{\frac{\sin ky \cdot th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                          2. associate-/l*N/A

                            \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                          3. *-lowering-*.f64N/A

                            \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                          4. sin-lowering-sin.f64N/A

                            \[\leadsto \color{blue}{\sin ky} \cdot \frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \]
                          5. /-lowering-/.f64N/A

                            \[\leadsto \sin ky \cdot \color{blue}{\frac{th}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                          6. sqrt-lowering-sqrt.f64N/A

                            \[\leadsto \sin ky \cdot \frac{th}{\color{blue}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \]
                          7. sin-multN/A

                            \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + \sin kx \cdot \sin kx}} \]
                          8. div-invN/A

                            \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + \sin kx \cdot \sin kx}} \]
                          9. metadata-evalN/A

                            \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + \sin kx \cdot \sin kx}} \]
                          10. accelerator-lowering-fma.f64N/A

                            \[\leadsto \sin ky \cdot \frac{th}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, \sin kx \cdot \sin kx\right)}}} \]
                        3. Applied egg-rr57.0%

                          \[\leadsto \color{blue}{\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \]

                        if -0.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))))) < 2e-176

                        1. Initial program 99.8%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Step-by-step derivation
                          1. associate-*l/N/A

                            \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          2. associate-/l*N/A

                            \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          3. *-commutativeN/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                          4. *-lowering-*.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                        4. Applied egg-rr82.5%

                          \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \sin ky} \]
                        5. Taylor expanded in ky around 0

                          \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \cdot \sin ky \]
                        6. Step-by-step derivation
                          1. +-commutativeN/A

                            \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \cdot \sin ky \]
                          2. metadata-evalN/A

                            \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \cdot \sin ky \]
                          3. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \cdot \sin ky \]
                          4. accelerator-lowering-fma.f64N/A

                            \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \cdot \sin ky \]
                          5. cos-negN/A

                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                          6. cos-lowering-cos.f64N/A

                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                          7. *-commutativeN/A

                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                          8. *-lowering-*.f6474.6

                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \cdot \sin ky \]
                        7. Simplified74.6%

                          \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \cdot \sin ky \]

                        if 2e-176 < (/.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.0000000000000001e-15

                        1. Initial program 99.7%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Taylor expanded in ky around 0

                          \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                        4. Step-by-step derivation
                          1. sin-lowering-sin.f6476.8

                            \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                        5. Simplified76.8%

                          \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]

                        if 0.859999999999999987 < (/.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. Initial program 94.0%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Taylor expanded in kx around 0

                          \[\leadsto \color{blue}{\sin th} \]
                        4. Step-by-step derivation
                          1. sin-lowering-sin.f6485.2

                            \[\leadsto \color{blue}{\sin th} \]
                        5. Simplified85.2%

                          \[\leadsto \color{blue}{\sin th} \]
                      7. Recombined 5 regimes into one program.
                      8. Final simplification72.5%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.999:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.5:\\ \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-15}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.86:\\ \;\;\;\;\sin ky \cdot \frac{th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                      9. Add Preprocessing

                      Alternative 7: 61.5% accurate, 0.3× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.71:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;t\_1 \leq 0.1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                      (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 -0.71)
                           (* (sin th) (/ (sin ky) (sqrt (* 0.5 (- 1.0 (cos (* ky -2.0)))))))
                           (if (<= t_1 2e-176)
                             (* (sin ky) (/ (sin th) (sqrt (fma -0.5 (cos (* kx -2.0)) 0.5))))
                             (if (<= t_1 0.1) (* (sin th) (/ (sin ky) (sin kx))) (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 <= -0.71) {
                      		tmp = sin(th) * (sin(ky) / sqrt((0.5 * (1.0 - cos((ky * -2.0))))));
                      	} else if (t_1 <= 2e-176) {
                      		tmp = sin(ky) * (sin(th) / sqrt(fma(-0.5, cos((kx * -2.0)), 0.5)));
                      	} else if (t_1 <= 0.1) {
                      		tmp = sin(th) * (sin(ky) / sin(kx));
                      	} else {
                      		tmp = 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 <= -0.71)
                      		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(ky * -2.0)))))));
                      	elseif (t_1 <= 2e-176)
                      		tmp = Float64(sin(ky) * Float64(sin(th) / sqrt(fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
                      	elseif (t_1 <= 0.1)
                      		tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx)));
                      	else
                      		tmp = sin(th);
                      	end
                      	return 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, -0.71], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 * N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-176], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.1], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $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 -0.71:\\
                      \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}\\
                      
                      \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\
                      \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\
                      
                      \mathbf{elif}\;t\_1 \leq 0.1:\\
                      \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\sin th\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 4 regimes
                      2. 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.70999999999999996

                        1. Initial program 86.2%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Step-by-step derivation
                          1. sqrt-lowering-sqrt.f64N/A

                            \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                          2. +-commutativeN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                          3. unpow2N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                          4. sin-multN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                          5. div-invN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                          6. metadata-evalN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                          7. accelerator-lowering-fma.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                          8. count-2N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                          9. +-inversesN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                          10. cos-0N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                          11. --lowering--.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                          12. count-2N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                          13. cos-lowering-cos.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                          14. +-lowering-+.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                          15. unpow2N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                          16. sqr-sin-aN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                          17. cancel-sign-sub-invN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                          18. +-lowering-+.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                          19. *-lowering-*.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                          20. metadata-evalN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                          21. count-2N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                          22. cos-lowering-cos.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                          23. +-lowering-+.f6471.3

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                        4. Applied egg-rr71.3%

                          \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                        5. Taylor expanded in kx around 0

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin th \]
                        6. Step-by-step derivation
                          1. *-lowering-*.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin th \]
                          2. metadata-evalN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right)}} \cdot \sin th \]
                          3. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right)}} \cdot \sin th \]
                          4. --lowering--.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)}}} \cdot \sin th \]
                          5. cos-negN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \left(1 - \color{blue}{\cos \left(-2 \cdot ky\right)}\right)}} \cdot \sin th \]
                          6. cos-lowering-cos.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \left(1 - \color{blue}{\cos \left(-2 \cdot ky\right)}\right)}} \cdot \sin th \]
                          7. *-commutativeN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \color{blue}{\left(ky \cdot -2\right)}\right)}} \cdot \sin th \]
                          8. *-lowering-*.f6454.9

                            \[\leadsto \frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \color{blue}{\left(ky \cdot -2\right)}\right)}} \cdot \sin th \]
                        7. Simplified54.9%

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}} \cdot \sin th \]

                        if -0.70999999999999996 < (/.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))))) < 2e-176

                        1. Initial program 99.8%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Step-by-step derivation
                          1. associate-*l/N/A

                            \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          2. associate-/l*N/A

                            \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          3. *-commutativeN/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                          4. *-lowering-*.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                        4. Applied egg-rr83.9%

                          \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \sin ky} \]
                        5. Taylor expanded in ky around 0

                          \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \cdot \sin ky \]
                        6. Step-by-step derivation
                          1. +-commutativeN/A

                            \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \cdot \sin ky \]
                          2. metadata-evalN/A

                            \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \cdot \sin ky \]
                          3. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \cdot \sin ky \]
                          4. accelerator-lowering-fma.f64N/A

                            \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \cdot \sin ky \]
                          5. cos-negN/A

                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                          6. cos-lowering-cos.f64N/A

                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                          7. *-commutativeN/A

                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                          8. *-lowering-*.f6470.0

                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \cdot \sin ky \]
                        7. Simplified70.0%

                          \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \cdot \sin ky \]

                        if 2e-176 < (/.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

                        1. Initial program 99.7%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Taylor expanded in ky around 0

                          \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                        4. Step-by-step derivation
                          1. sin-lowering-sin.f6469.1

                            \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                        5. Simplified69.1%

                          \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]

                        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)))))

                        1. Initial program 95.2%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Taylor expanded in kx around 0

                          \[\leadsto \color{blue}{\sin th} \]
                        4. Step-by-step derivation
                          1. sin-lowering-sin.f6470.7

                            \[\leadsto \color{blue}{\sin th} \]
                        5. Simplified70.7%

                          \[\leadsto \color{blue}{\sin th} \]
                      3. Recombined 4 regimes into one program.
                      4. Final simplification66.4%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.71:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                      5. Add Preprocessing

                      Alternative 8: 58.3% accurate, 0.3× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -1:\\ \;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;t\_1 \leq 0.1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                      (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 -1.0)
                           (* th (/ (sin ky) (hypot (sin ky) kx)))
                           (if (<= t_1 2e-176)
                             (* (sin ky) (/ (sin th) (sqrt (fma -0.5 (cos (* kx -2.0)) 0.5))))
                             (if (<= t_1 0.1) (* (sin th) (/ (sin ky) (sin kx))) (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 <= -1.0) {
                      		tmp = th * (sin(ky) / hypot(sin(ky), kx));
                      	} else if (t_1 <= 2e-176) {
                      		tmp = sin(ky) * (sin(th) / sqrt(fma(-0.5, cos((kx * -2.0)), 0.5)));
                      	} else if (t_1 <= 0.1) {
                      		tmp = sin(th) * (sin(ky) / sin(kx));
                      	} else {
                      		tmp = 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 <= -1.0)
                      		tmp = Float64(th * Float64(sin(ky) / hypot(sin(ky), kx)));
                      	elseif (t_1 <= 2e-176)
                      		tmp = Float64(sin(ky) * Float64(sin(th) / sqrt(fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
                      	elseif (t_1 <= 0.1)
                      		tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx)));
                      	else
                      		tmp = sin(th);
                      	end
                      	return 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, -1.0], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-176], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.1], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $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 -1:\\
                      \;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
                      
                      \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\
                      \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\
                      
                      \mathbf{elif}\;t\_1 \leq 0.1:\\
                      \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\sin th\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 4 regimes
                      2. 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

                        1. Initial program 82.1%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Step-by-step derivation
                          1. +-commutativeN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                          2. unpow2N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                          3. unpow2N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                          4. accelerator-lowering-hypot.f64N/A

                            \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                          5. sin-lowering-sin.f64N/A

                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                          6. sin-lowering-sin.f6499.9

                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                        4. Applied egg-rr99.9%

                          \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                        5. Taylor expanded in th around 0

                          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                        6. Step-by-step derivation
                          1. Simplified43.6%

                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                          2. Taylor expanded in kx around 0

                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx}\right)} \cdot th \]
                          3. Step-by-step derivation
                            1. Simplified43.6%

                              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx}\right)} \cdot th \]

                            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))))) < 2e-176

                            1. Initial program 99.7%

                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                            2. Add Preprocessing
                            3. Step-by-step derivation
                              1. associate-*l/N/A

                                \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                              2. associate-/l*N/A

                                \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                              3. *-commutativeN/A

                                \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                              4. *-lowering-*.f64N/A

                                \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                            4. Applied egg-rr85.3%

                              \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \sin ky} \]
                            5. Taylor expanded in ky around 0

                              \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \cdot \sin ky \]
                            6. Step-by-step derivation
                              1. +-commutativeN/A

                                \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \cdot \sin ky \]
                              2. metadata-evalN/A

                                \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \cdot \sin ky \]
                              3. distribute-lft-neg-inN/A

                                \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \cdot \sin ky \]
                              4. accelerator-lowering-fma.f64N/A

                                \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \cdot \sin ky \]
                              5. cos-negN/A

                                \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                              6. cos-lowering-cos.f64N/A

                                \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                              7. *-commutativeN/A

                                \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                              8. *-lowering-*.f6461.8

                                \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \cdot \sin ky \]
                            7. Simplified61.8%

                              \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \cdot \sin ky \]

                            if 2e-176 < (/.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

                            1. Initial program 99.7%

                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                            2. Add Preprocessing
                            3. Taylor expanded in ky around 0

                              \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                            4. Step-by-step derivation
                              1. sin-lowering-sin.f6469.1

                                \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                            5. Simplified69.1%

                              \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]

                            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)))))

                            1. Initial program 95.2%

                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                            2. Add Preprocessing
                            3. Taylor expanded in kx around 0

                              \[\leadsto \color{blue}{\sin th} \]
                            4. Step-by-step derivation
                              1. sin-lowering-sin.f6470.7

                                \[\leadsto \color{blue}{\sin th} \]
                            5. Simplified70.7%

                              \[\leadsto \color{blue}{\sin th} \]
                          4. Recombined 4 regimes into one program.
                          5. Final simplification62.0%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -1:\\ \;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                          6. Add Preprocessing

                          Alternative 9: 58.3% accurate, 0.3× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -1:\\ \;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;t\_1 \leq 0.1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                          (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 -1.0)
                               (* th (/ (sin ky) (hypot (sin ky) kx)))
                               (if (<= t_1 2e-176)
                                 (* (sin th) (/ (sin ky) (sqrt (fma -0.5 (cos (* kx -2.0)) 0.5))))
                                 (if (<= t_1 0.1) (* (sin th) (/ (sin ky) (sin kx))) (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 <= -1.0) {
                          		tmp = th * (sin(ky) / hypot(sin(ky), kx));
                          	} else if (t_1 <= 2e-176) {
                          		tmp = sin(th) * (sin(ky) / sqrt(fma(-0.5, cos((kx * -2.0)), 0.5)));
                          	} else if (t_1 <= 0.1) {
                          		tmp = sin(th) * (sin(ky) / sin(kx));
                          	} else {
                          		tmp = 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 <= -1.0)
                          		tmp = Float64(th * Float64(sin(ky) / hypot(sin(ky), kx)));
                          	elseif (t_1 <= 2e-176)
                          		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
                          	elseif (t_1 <= 0.1)
                          		tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx)));
                          	else
                          		tmp = sin(th);
                          	end
                          	return 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, -1.0], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-176], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.1], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $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 -1:\\
                          \;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
                          
                          \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\
                          \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\
                          
                          \mathbf{elif}\;t\_1 \leq 0.1:\\
                          \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\sin th\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 4 regimes
                          2. 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

                            1. Initial program 82.1%

                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                            2. Add Preprocessing
                            3. Step-by-step derivation
                              1. +-commutativeN/A

                                \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                              2. unpow2N/A

                                \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                              3. unpow2N/A

                                \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                              4. accelerator-lowering-hypot.f64N/A

                                \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                              5. sin-lowering-sin.f64N/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                              6. sin-lowering-sin.f6499.9

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                            4. Applied egg-rr99.9%

                              \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                            5. Taylor expanded in th around 0

                              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                            6. Step-by-step derivation
                              1. Simplified43.6%

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                              2. Taylor expanded in kx around 0

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx}\right)} \cdot th \]
                              3. Step-by-step derivation
                                1. Simplified43.6%

                                  \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx}\right)} \cdot th \]

                                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))))) < 2e-176

                                1. Initial program 99.7%

                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                2. Add Preprocessing
                                3. Step-by-step derivation
                                  1. sqrt-lowering-sqrt.f64N/A

                                    \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                                  2. +-commutativeN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                  3. unpow2N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                  4. sin-multN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                  5. div-invN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                  6. metadata-evalN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                  7. accelerator-lowering-fma.f64N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                                  8. count-2N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                  9. +-inversesN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                  10. cos-0N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                  11. --lowering--.f64N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                  12. count-2N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                  13. cos-lowering-cos.f64N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                  14. +-lowering-+.f64N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                  15. unpow2N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                                  16. sqr-sin-aN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                  17. cancel-sign-sub-invN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                  18. +-lowering-+.f64N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                  19. *-lowering-*.f64N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                  20. metadata-evalN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                                  21. count-2N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                  22. cos-lowering-cos.f64N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                                  23. +-lowering-+.f6485.2

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                4. Applied egg-rr85.2%

                                  \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                                5. Taylor expanded in ky around 0

                                  \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \cdot \sin th \]
                                6. Step-by-step derivation
                                  1. +-commutativeN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \cdot \sin th \]
                                  2. metadata-evalN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \cdot \sin th \]
                                  3. distribute-lft-neg-inN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \cdot \sin th \]
                                  4. accelerator-lowering-fma.f64N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \cdot \sin th \]
                                  5. cos-negN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin th \]
                                  6. cos-lowering-cos.f64N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin th \]
                                  7. *-commutativeN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \cdot \sin th \]
                                  8. *-lowering-*.f6461.9

                                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \cdot \sin th \]
                                7. Simplified61.9%

                                  \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \cdot \sin th \]

                                if 2e-176 < (/.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

                                1. Initial program 99.7%

                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                2. Add Preprocessing
                                3. Taylor expanded in ky around 0

                                  \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                4. Step-by-step derivation
                                  1. sin-lowering-sin.f6469.1

                                    \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                5. Simplified69.1%

                                  \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]

                                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)))))

                                1. Initial program 95.2%

                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                2. Add Preprocessing
                                3. Taylor expanded in kx around 0

                                  \[\leadsto \color{blue}{\sin th} \]
                                4. Step-by-step derivation
                                  1. sin-lowering-sin.f6470.7

                                    \[\leadsto \color{blue}{\sin th} \]
                                5. Simplified70.7%

                                  \[\leadsto \color{blue}{\sin th} \]
                              4. Recombined 4 regimes into one program.
                              5. Final simplification62.0%

                                \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -1:\\ \;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                              6. Add Preprocessing

                              Alternative 10: 53.7% accurate, 0.3× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.05:\\ \;\;\;\;th \cdot \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\ \mathbf{elif}\;t\_1 \leq 0.1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                              (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 -0.05)
                                   (*
                                    th
                                    (* (sqrt (/ 1.0 (- 1.0 (cos (* ky -2.0))))) (* (sin ky) (sqrt 2.0))))
                                   (if (<= t_1 2e-176)
                                     (* (sin th) (* ky (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5)))))
                                     (if (<= t_1 0.1) (* (sin th) (/ (sin ky) (sin kx))) (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 <= -0.05) {
                              		tmp = th * (sqrt((1.0 / (1.0 - cos((ky * -2.0))))) * (sin(ky) * sqrt(2.0)));
                              	} else if (t_1 <= 2e-176) {
                              		tmp = sin(th) * (ky * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5))));
                              	} else if (t_1 <= 0.1) {
                              		tmp = sin(th) * (sin(ky) / sin(kx));
                              	} else {
                              		tmp = 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 <= -0.05)
                              		tmp = Float64(th * Float64(sqrt(Float64(1.0 / Float64(1.0 - cos(Float64(ky * -2.0))))) * Float64(sin(ky) * sqrt(2.0))));
                              	elseif (t_1 <= 2e-176)
                              		tmp = Float64(sin(th) * Float64(ky * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5)))));
                              	elseif (t_1 <= 0.1)
                              		tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx)));
                              	else
                              		tmp = sin(th);
                              	end
                              	return 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, -0.05], N[(th * N[(N[Sqrt[N[(1.0 / N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-176], N[(N[Sin[th], $MachinePrecision] * N[(ky * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.1], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $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 -0.05:\\
                              \;\;\;\;th \cdot \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)\\
                              
                              \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\
                              \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\
                              
                              \mathbf{elif}\;t\_1 \leq 0.1:\\
                              \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\sin th\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 4 regimes
                              2. 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.050000000000000003

                                1. Initial program 88.3%

                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                2. Add Preprocessing
                                3. Step-by-step derivation
                                  1. +-commutativeN/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                  2. unpow2N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                  3. unpow2N/A

                                    \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                                  4. accelerator-lowering-hypot.f64N/A

                                    \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                  5. sin-lowering-sin.f64N/A

                                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                                  6. sin-lowering-sin.f6499.8

                                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                                4. Applied egg-rr99.8%

                                  \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                5. Taylor expanded in th around 0

                                  \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                                6. Step-by-step derivation
                                  1. Simplified45.8%

                                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                                  2. Step-by-step derivation
                                    1. div-invN/A

                                      \[\leadsto \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}\right)} \cdot th \]
                                    2. *-commutativeN/A

                                      \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \cdot \sin ky\right)} \cdot th \]
                                    3. *-lowering-*.f64N/A

                                      \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \cdot \sin ky\right)} \cdot th \]
                                  3. Applied egg-rr36.2%

                                    \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \sin ky\right)} \cdot th \]
                                  4. Taylor expanded in kx around 0

                                    \[\leadsto \color{blue}{\left(\left(\sin ky \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \left(2 \cdot ky\right)}}\right)} \cdot th \]
                                  5. Step-by-step derivation
                                    1. *-commutativeN/A

                                      \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{1 - \cos \left(2 \cdot ky\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)} \cdot th \]
                                    2. *-lowering-*.f64N/A

                                      \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{1 - \cos \left(2 \cdot ky\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)} \cdot th \]
                                    3. sqrt-lowering-sqrt.f64N/A

                                      \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot ky\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                    4. /-lowering-/.f64N/A

                                      \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{1 - \cos \left(2 \cdot ky\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                    5. metadata-evalN/A

                                      \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                    6. distribute-lft-neg-inN/A

                                      \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                    7. --lowering--.f64N/A

                                      \[\leadsto \left(\sqrt{\frac{1}{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                    8. cos-negN/A

                                      \[\leadsto \left(\sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot ky\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                    9. cos-lowering-cos.f64N/A

                                      \[\leadsto \left(\sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot ky\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                    10. *-commutativeN/A

                                      \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \color{blue}{\left(ky \cdot -2\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                    11. *-lowering-*.f64N/A

                                      \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \color{blue}{\left(ky \cdot -2\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                    12. *-lowering-*.f64N/A

                                      \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \color{blue}{\left(\sin ky \cdot \sqrt{2}\right)}\right) \cdot th \]
                                    13. sin-lowering-sin.f64N/A

                                      \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\color{blue}{\sin ky} \cdot \sqrt{2}\right)\right) \cdot th \]
                                    14. sqrt-lowering-sqrt.f6424.1

                                      \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\sin ky \cdot \color{blue}{\sqrt{2}}\right)\right) \cdot th \]
                                  6. Simplified24.1%

                                    \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)} \cdot th \]

                                  if -0.050000000000000003 < (/.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))))) < 2e-176

                                  1. Initial program 99.8%

                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                  2. Add Preprocessing
                                  3. Step-by-step derivation
                                    1. sqrt-lowering-sqrt.f64N/A

                                      \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                                    2. +-commutativeN/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                    3. unpow2N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                    4. sin-multN/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                    5. div-invN/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                    6. metadata-evalN/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                    7. accelerator-lowering-fma.f64N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                                    8. count-2N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                    9. +-inversesN/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                    10. cos-0N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                    11. --lowering--.f64N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                    12. count-2N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                    13. cos-lowering-cos.f64N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                    14. +-lowering-+.f64N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                    15. unpow2N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                                    16. sqr-sin-aN/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                    17. cancel-sign-sub-invN/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                    18. +-lowering-+.f64N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                    19. *-lowering-*.f64N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                    20. metadata-evalN/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                                    21. count-2N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                    22. cos-lowering-cos.f64N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                                    23. +-lowering-+.f6481.3

                                      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                  4. Applied egg-rr81.3%

                                    \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                                  5. Taylor expanded in ky around 0

                                    \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}\right)} \cdot \sin th \]
                                  6. Step-by-step derivation
                                    1. *-lowering-*.f64N/A

                                      \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}\right)} \cdot \sin th \]
                                    2. sqrt-lowering-sqrt.f64N/A

                                      \[\leadsto \left(ky \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}}\right) \cdot \sin th \]
                                    3. /-lowering-/.f64N/A

                                      \[\leadsto \left(ky \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}}\right) \cdot \sin th \]
                                    4. +-commutativeN/A

                                      \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}}\right) \cdot \sin th \]
                                    5. metadata-evalN/A

                                      \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}}\right) \cdot \sin th \]
                                    6. distribute-lft-neg-inN/A

                                      \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}}\right) \cdot \sin th \]
                                    7. accelerator-lowering-fma.f64N/A

                                      \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}}\right) \cdot \sin th \]
                                    8. cos-negN/A

                                      \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                    9. cos-lowering-cos.f64N/A

                                      \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                    10. *-commutativeN/A

                                      \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                    11. *-lowering-*.f6476.6

                                      \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}}\right) \cdot \sin th \]
                                  7. Simplified76.6%

                                    \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)} \cdot \sin th \]

                                  if 2e-176 < (/.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

                                  1. Initial program 99.7%

                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in ky around 0

                                    \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                  4. Step-by-step derivation
                                    1. sin-lowering-sin.f6469.1

                                      \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                  5. Simplified69.1%

                                    \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]

                                  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)))))

                                  1. Initial program 95.2%

                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in kx around 0

                                    \[\leadsto \color{blue}{\sin th} \]
                                  4. Step-by-step derivation
                                    1. sin-lowering-sin.f6470.7

                                      \[\leadsto \color{blue}{\sin th} \]
                                  5. Simplified70.7%

                                    \[\leadsto \color{blue}{\sin th} \]
                                7. Recombined 4 regimes into one program.
                                8. Final simplification58.3%

                                  \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.05:\\ \;\;\;\;th \cdot \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                9. Add Preprocessing

                                Alternative 11: 53.7% accurate, 0.3× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.05:\\ \;\;\;\;th \cdot \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\ \mathbf{elif}\;t\_1 \leq 0.0001:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                (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 -0.05)
                                     (*
                                      th
                                      (* (sqrt (/ 1.0 (- 1.0 (cos (* ky -2.0))))) (* (sin ky) (sqrt 2.0))))
                                     (if (<= t_1 2e-176)
                                       (* (sin th) (* ky (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5)))))
                                       (if (<= t_1 0.0001) (* (sin th) (/ ky (sin kx))) (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 <= -0.05) {
                                		tmp = th * (sqrt((1.0 / (1.0 - cos((ky * -2.0))))) * (sin(ky) * sqrt(2.0)));
                                	} else if (t_1 <= 2e-176) {
                                		tmp = sin(th) * (ky * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5))));
                                	} else if (t_1 <= 0.0001) {
                                		tmp = sin(th) * (ky / sin(kx));
                                	} else {
                                		tmp = 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 <= -0.05)
                                		tmp = Float64(th * Float64(sqrt(Float64(1.0 / Float64(1.0 - cos(Float64(ky * -2.0))))) * Float64(sin(ky) * sqrt(2.0))));
                                	elseif (t_1 <= 2e-176)
                                		tmp = Float64(sin(th) * Float64(ky * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5)))));
                                	elseif (t_1 <= 0.0001)
                                		tmp = Float64(sin(th) * Float64(ky / sin(kx)));
                                	else
                                		tmp = sin(th);
                                	end
                                	return 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, -0.05], N[(th * N[(N[Sqrt[N[(1.0 / N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-176], N[(N[Sin[th], $MachinePrecision] * N[(ky * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0001], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $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 -0.05:\\
                                \;\;\;\;th \cdot \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)\\
                                
                                \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\
                                \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\
                                
                                \mathbf{elif}\;t\_1 \leq 0.0001:\\
                                \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\sin th\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 4 regimes
                                2. 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.050000000000000003

                                  1. Initial program 88.3%

                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                  2. Add Preprocessing
                                  3. Step-by-step derivation
                                    1. +-commutativeN/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                    2. unpow2N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                    3. unpow2N/A

                                      \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                                    4. accelerator-lowering-hypot.f64N/A

                                      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                    5. sin-lowering-sin.f64N/A

                                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                                    6. sin-lowering-sin.f6499.8

                                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                                  4. Applied egg-rr99.8%

                                    \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                  5. Taylor expanded in th around 0

                                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                                  6. Step-by-step derivation
                                    1. Simplified45.8%

                                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                                    2. Step-by-step derivation
                                      1. div-invN/A

                                        \[\leadsto \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}\right)} \cdot th \]
                                      2. *-commutativeN/A

                                        \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \cdot \sin ky\right)} \cdot th \]
                                      3. *-lowering-*.f64N/A

                                        \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \cdot \sin ky\right)} \cdot th \]
                                    3. Applied egg-rr36.2%

                                      \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \sin ky\right)} \cdot th \]
                                    4. Taylor expanded in kx around 0

                                      \[\leadsto \color{blue}{\left(\left(\sin ky \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \left(2 \cdot ky\right)}}\right)} \cdot th \]
                                    5. Step-by-step derivation
                                      1. *-commutativeN/A

                                        \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{1 - \cos \left(2 \cdot ky\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)} \cdot th \]
                                      2. *-lowering-*.f64N/A

                                        \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{1 - \cos \left(2 \cdot ky\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)} \cdot th \]
                                      3. sqrt-lowering-sqrt.f64N/A

                                        \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot ky\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                      4. /-lowering-/.f64N/A

                                        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{1 - \cos \left(2 \cdot ky\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                      5. metadata-evalN/A

                                        \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                      6. distribute-lft-neg-inN/A

                                        \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                      7. --lowering--.f64N/A

                                        \[\leadsto \left(\sqrt{\frac{1}{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                      8. cos-negN/A

                                        \[\leadsto \left(\sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot ky\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                      9. cos-lowering-cos.f64N/A

                                        \[\leadsto \left(\sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot ky\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                      10. *-commutativeN/A

                                        \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \color{blue}{\left(ky \cdot -2\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                      11. *-lowering-*.f64N/A

                                        \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \color{blue}{\left(ky \cdot -2\right)}}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot th \]
                                      12. *-lowering-*.f64N/A

                                        \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \color{blue}{\left(\sin ky \cdot \sqrt{2}\right)}\right) \cdot th \]
                                      13. sin-lowering-sin.f64N/A

                                        \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\color{blue}{\sin ky} \cdot \sqrt{2}\right)\right) \cdot th \]
                                      14. sqrt-lowering-sqrt.f6424.1

                                        \[\leadsto \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\sin ky \cdot \color{blue}{\sqrt{2}}\right)\right) \cdot th \]
                                    6. Simplified24.1%

                                      \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)} \cdot th \]

                                    if -0.050000000000000003 < (/.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))))) < 2e-176

                                    1. Initial program 99.8%

                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                    2. Add Preprocessing
                                    3. Step-by-step derivation
                                      1. sqrt-lowering-sqrt.f64N/A

                                        \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                                      2. +-commutativeN/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                      3. unpow2N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                      4. sin-multN/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                      5. div-invN/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                      6. metadata-evalN/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                      7. accelerator-lowering-fma.f64N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                                      8. count-2N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                      9. +-inversesN/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                      10. cos-0N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                      11. --lowering--.f64N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                      12. count-2N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                      13. cos-lowering-cos.f64N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                      14. +-lowering-+.f64N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                      15. unpow2N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                                      16. sqr-sin-aN/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                      17. cancel-sign-sub-invN/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                      18. +-lowering-+.f64N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                      19. *-lowering-*.f64N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                      20. metadata-evalN/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                                      21. count-2N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                      22. cos-lowering-cos.f64N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                                      23. +-lowering-+.f6481.3

                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                    4. Applied egg-rr81.3%

                                      \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                                    5. Taylor expanded in ky around 0

                                      \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}\right)} \cdot \sin th \]
                                    6. Step-by-step derivation
                                      1. *-lowering-*.f64N/A

                                        \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}\right)} \cdot \sin th \]
                                      2. sqrt-lowering-sqrt.f64N/A

                                        \[\leadsto \left(ky \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}}\right) \cdot \sin th \]
                                      3. /-lowering-/.f64N/A

                                        \[\leadsto \left(ky \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}}\right) \cdot \sin th \]
                                      4. +-commutativeN/A

                                        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}}\right) \cdot \sin th \]
                                      5. metadata-evalN/A

                                        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}}\right) \cdot \sin th \]
                                      6. distribute-lft-neg-inN/A

                                        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}}\right) \cdot \sin th \]
                                      7. accelerator-lowering-fma.f64N/A

                                        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}}\right) \cdot \sin th \]
                                      8. cos-negN/A

                                        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                      9. cos-lowering-cos.f64N/A

                                        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                      10. *-commutativeN/A

                                        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                      11. *-lowering-*.f6476.6

                                        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}}\right) \cdot \sin th \]
                                    7. Simplified76.6%

                                      \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)} \cdot \sin th \]

                                    if 2e-176 < (/.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.00000000000000005e-4

                                    1. Initial program 99.7%

                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in ky around 0

                                      \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                    4. Step-by-step derivation
                                      1. /-lowering-/.f64N/A

                                        \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                      2. sin-lowering-sin.f6473.7

                                        \[\leadsto \frac{ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                    5. Simplified73.7%

                                      \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]

                                    if 1.00000000000000005e-4 < (/.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. Initial program 95.3%

                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in kx around 0

                                      \[\leadsto \color{blue}{\sin th} \]
                                    4. Step-by-step derivation
                                      1. sin-lowering-sin.f6469.4

                                        \[\leadsto \color{blue}{\sin th} \]
                                    5. Simplified69.4%

                                      \[\leadsto \color{blue}{\sin th} \]
                                  7. Recombined 4 regimes into one program.
                                  8. Final simplification58.3%

                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.05:\\ \;\;\;\;th \cdot \left(\sqrt{\frac{1}{1 - \cos \left(ky \cdot -2\right)}} \cdot \left(\sin ky \cdot \sqrt{2}\right)\right)\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                  9. Add Preprocessing

                                  Alternative 12: 53.7% accurate, 0.3× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.05:\\ \;\;\;\;th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\ \mathbf{elif}\;t\_1 \leq 0.0001:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                  (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 -0.05)
                                       (* th (* (sin ky) (/ 1.0 (sqrt (* 0.5 (- 1.0 (cos (* ky -2.0))))))))
                                       (if (<= t_1 2e-176)
                                         (* (sin th) (* ky (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5)))))
                                         (if (<= t_1 0.0001) (* (sin th) (/ ky (sin kx))) (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 <= -0.05) {
                                  		tmp = th * (sin(ky) * (1.0 / sqrt((0.5 * (1.0 - cos((ky * -2.0)))))));
                                  	} else if (t_1 <= 2e-176) {
                                  		tmp = sin(th) * (ky * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5))));
                                  	} else if (t_1 <= 0.0001) {
                                  		tmp = sin(th) * (ky / sin(kx));
                                  	} else {
                                  		tmp = 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 <= -0.05)
                                  		tmp = Float64(th * Float64(sin(ky) * Float64(1.0 / sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(ky * -2.0))))))));
                                  	elseif (t_1 <= 2e-176)
                                  		tmp = Float64(sin(th) * Float64(ky * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5)))));
                                  	elseif (t_1 <= 0.0001)
                                  		tmp = Float64(sin(th) * Float64(ky / sin(kx)));
                                  	else
                                  		tmp = sin(th);
                                  	end
                                  	return 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, -0.05], N[(th * N[(N[Sin[ky], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(0.5 * N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-176], N[(N[Sin[th], $MachinePrecision] * N[(ky * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0001], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $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 -0.05:\\
                                  \;\;\;\;th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}\right)\\
                                  
                                  \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-176}:\\
                                  \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\
                                  
                                  \mathbf{elif}\;t\_1 \leq 0.0001:\\
                                  \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;\sin th\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 4 regimes
                                  2. 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.050000000000000003

                                    1. Initial program 88.3%

                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                    2. Add Preprocessing
                                    3. Step-by-step derivation
                                      1. +-commutativeN/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                      2. unpow2N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                      3. unpow2N/A

                                        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                                      4. accelerator-lowering-hypot.f64N/A

                                        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                      5. sin-lowering-sin.f64N/A

                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                                      6. sin-lowering-sin.f6499.8

                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                                    4. Applied egg-rr99.8%

                                      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                    5. Taylor expanded in th around 0

                                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                                    6. Step-by-step derivation
                                      1. Simplified45.8%

                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                                      2. Step-by-step derivation
                                        1. div-invN/A

                                          \[\leadsto \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}\right)} \cdot th \]
                                        2. *-commutativeN/A

                                          \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \cdot \sin ky\right)} \cdot th \]
                                        3. *-lowering-*.f64N/A

                                          \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}} \cdot \sin ky\right)} \cdot th \]
                                      3. Applied egg-rr36.2%

                                        \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \sin ky\right)} \cdot th \]
                                      4. Taylor expanded in kx around 0

                                        \[\leadsto \left(\frac{1}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin ky\right) \cdot th \]
                                      5. Step-by-step derivation
                                        1. *-lowering-*.f64N/A

                                          \[\leadsto \left(\frac{1}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin ky\right) \cdot th \]
                                        2. metadata-evalN/A

                                          \[\leadsto \left(\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right)}} \cdot \sin ky\right) \cdot th \]
                                        3. distribute-lft-neg-inN/A

                                          \[\leadsto \left(\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right)}} \cdot \sin ky\right) \cdot th \]
                                        4. --lowering--.f64N/A

                                          \[\leadsto \left(\frac{1}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)}}} \cdot \sin ky\right) \cdot th \]
                                        5. cos-negN/A

                                          \[\leadsto \left(\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \color{blue}{\cos \left(-2 \cdot ky\right)}\right)}} \cdot \sin ky\right) \cdot th \]
                                        6. cos-lowering-cos.f64N/A

                                          \[\leadsto \left(\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \color{blue}{\cos \left(-2 \cdot ky\right)}\right)}} \cdot \sin ky\right) \cdot th \]
                                        7. *-commutativeN/A

                                          \[\leadsto \left(\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \color{blue}{\left(ky \cdot -2\right)}\right)}} \cdot \sin ky\right) \cdot th \]
                                        8. *-lowering-*.f6424.0

                                          \[\leadsto \left(\frac{1}{\sqrt{0.5 \cdot \left(1 - \cos \color{blue}{\left(ky \cdot -2\right)}\right)}} \cdot \sin ky\right) \cdot th \]
                                      6. Simplified24.0%

                                        \[\leadsto \left(\frac{1}{\sqrt{\color{blue}{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}} \cdot \sin ky\right) \cdot th \]

                                      if -0.050000000000000003 < (/.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))))) < 2e-176

                                      1. Initial program 99.8%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Step-by-step derivation
                                        1. sqrt-lowering-sqrt.f64N/A

                                          \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                                        2. +-commutativeN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                        3. unpow2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                        4. sin-multN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                        5. div-invN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                        6. metadata-evalN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                        7. accelerator-lowering-fma.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                                        8. count-2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        9. +-inversesN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        10. cos-0N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        11. --lowering--.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        12. count-2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        13. cos-lowering-cos.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        14. +-lowering-+.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        15. unpow2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                                        16. sqr-sin-aN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        17. cancel-sign-sub-invN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        18. +-lowering-+.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        19. *-lowering-*.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        20. metadata-evalN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                                        21. count-2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                        22. cos-lowering-cos.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                                        23. +-lowering-+.f6481.3

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                      4. Applied egg-rr81.3%

                                        \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                                      5. Taylor expanded in ky around 0

                                        \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}\right)} \cdot \sin th \]
                                      6. Step-by-step derivation
                                        1. *-lowering-*.f64N/A

                                          \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}\right)} \cdot \sin th \]
                                        2. sqrt-lowering-sqrt.f64N/A

                                          \[\leadsto \left(ky \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}}\right) \cdot \sin th \]
                                        3. /-lowering-/.f64N/A

                                          \[\leadsto \left(ky \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}}\right) \cdot \sin th \]
                                        4. +-commutativeN/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}}\right) \cdot \sin th \]
                                        5. metadata-evalN/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}}\right) \cdot \sin th \]
                                        6. distribute-lft-neg-inN/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}}\right) \cdot \sin th \]
                                        7. accelerator-lowering-fma.f64N/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}}\right) \cdot \sin th \]
                                        8. cos-negN/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                        9. cos-lowering-cos.f64N/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                        10. *-commutativeN/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                        11. *-lowering-*.f6476.6

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}}\right) \cdot \sin th \]
                                      7. Simplified76.6%

                                        \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)} \cdot \sin th \]

                                      if 2e-176 < (/.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.00000000000000005e-4

                                      1. Initial program 99.7%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in ky around 0

                                        \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                      4. Step-by-step derivation
                                        1. /-lowering-/.f64N/A

                                          \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                        2. sin-lowering-sin.f6473.7

                                          \[\leadsto \frac{ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                      5. Simplified73.7%

                                        \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]

                                      if 1.00000000000000005e-4 < (/.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. Initial program 95.3%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in kx around 0

                                        \[\leadsto \color{blue}{\sin th} \]
                                      4. Step-by-step derivation
                                        1. sin-lowering-sin.f6469.4

                                          \[\leadsto \color{blue}{\sin th} \]
                                      5. Simplified69.4%

                                        \[\leadsto \color{blue}{\sin th} \]
                                    7. Recombined 4 regimes into one program.
                                    8. Final simplification58.3%

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.05:\\ \;\;\;\;th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}\right)\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                    9. Add Preprocessing

                                    Alternative 13: 46.4% accurate, 0.5× speedup?

                                    \[\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^{-176}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\ \mathbf{elif}\;t\_1 \leq 0.0001:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                    (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-176)
                                         (* (sin th) (* ky (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5)))))
                                         (if (<= t_1 0.0001) (* (sin th) (/ ky (sin kx))) (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-176) {
                                    		tmp = sin(th) * (ky * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5))));
                                    	} else if (t_1 <= 0.0001) {
                                    		tmp = sin(th) * (ky / sin(kx));
                                    	} else {
                                    		tmp = 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-176)
                                    		tmp = Float64(sin(th) * Float64(ky * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5)))));
                                    	elseif (t_1 <= 0.0001)
                                    		tmp = Float64(sin(th) * Float64(ky / sin(kx)));
                                    	else
                                    		tmp = sin(th);
                                    	end
                                    	return 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-176], N[(N[Sin[th], $MachinePrecision] * N[(ky * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0001], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $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^{-176}:\\
                                    \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\
                                    
                                    \mathbf{elif}\;t\_1 \leq 0.0001:\\
                                    \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\sin th\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 3 regimes
                                    2. 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))))) < 2e-176

                                      1. Initial program 93.8%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Step-by-step derivation
                                        1. sqrt-lowering-sqrt.f64N/A

                                          \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                                        2. +-commutativeN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                        3. unpow2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                        4. sin-multN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                        5. div-invN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                        6. metadata-evalN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                        7. accelerator-lowering-fma.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                                        8. count-2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        9. +-inversesN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        10. cos-0N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        11. --lowering--.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        12. count-2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        13. cos-lowering-cos.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        14. +-lowering-+.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        15. unpow2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                                        16. sqr-sin-aN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        17. cancel-sign-sub-invN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        18. +-lowering-+.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        19. *-lowering-*.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        20. metadata-evalN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                                        21. count-2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                        22. cos-lowering-cos.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                                        23. +-lowering-+.f6478.4

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                      4. Applied egg-rr78.4%

                                        \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                                      5. Taylor expanded in ky around 0

                                        \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}\right)} \cdot \sin th \]
                                      6. Step-by-step derivation
                                        1. *-lowering-*.f64N/A

                                          \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}\right)} \cdot \sin th \]
                                        2. sqrt-lowering-sqrt.f64N/A

                                          \[\leadsto \left(ky \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}}\right) \cdot \sin th \]
                                        3. /-lowering-/.f64N/A

                                          \[\leadsto \left(ky \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}}\right) \cdot \sin th \]
                                        4. +-commutativeN/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}}\right) \cdot \sin th \]
                                        5. metadata-evalN/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}}\right) \cdot \sin th \]
                                        6. distribute-lft-neg-inN/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}}\right) \cdot \sin th \]
                                        7. accelerator-lowering-fma.f64N/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}}\right) \cdot \sin th \]
                                        8. cos-negN/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                        9. cos-lowering-cos.f64N/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                        10. *-commutativeN/A

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}}\right) \cdot \sin th \]
                                        11. *-lowering-*.f6438.4

                                          \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}}\right) \cdot \sin th \]
                                      7. Simplified38.4%

                                        \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)} \cdot \sin th \]

                                      if 2e-176 < (/.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.00000000000000005e-4

                                      1. Initial program 99.7%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in ky around 0

                                        \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                      4. Step-by-step derivation
                                        1. /-lowering-/.f64N/A

                                          \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                        2. sin-lowering-sin.f6473.7

                                          \[\leadsto \frac{ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                      5. Simplified73.7%

                                        \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]

                                      if 1.00000000000000005e-4 < (/.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. Initial program 95.3%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in kx around 0

                                        \[\leadsto \color{blue}{\sin th} \]
                                      4. Step-by-step derivation
                                        1. sin-lowering-sin.f6469.4

                                          \[\leadsto \color{blue}{\sin th} \]
                                      5. Simplified69.4%

                                        \[\leadsto \color{blue}{\sin th} \]
                                    3. Recombined 3 regimes into one program.
                                    4. Final simplification52.1%

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                    5. Add Preprocessing

                                    Alternative 14: 46.4% accurate, 0.5× speedup?

                                    \[\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^{-176}:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}} \cdot \left(ky \cdot \sin th\right)\\ \mathbf{elif}\;t\_1 \leq 0.0001:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                    (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-176)
                                         (* (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5))) (* ky (sin th)))
                                         (if (<= t_1 0.0001) (* (sin th) (/ ky (sin kx))) (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-176) {
                                    		tmp = sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5))) * (ky * sin(th));
                                    	} else if (t_1 <= 0.0001) {
                                    		tmp = sin(th) * (ky / sin(kx));
                                    	} else {
                                    		tmp = 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-176)
                                    		tmp = Float64(sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5))) * Float64(ky * sin(th)));
                                    	elseif (t_1 <= 0.0001)
                                    		tmp = Float64(sin(th) * Float64(ky / sin(kx)));
                                    	else
                                    		tmp = sin(th);
                                    	end
                                    	return 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-176], N[(N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0001], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $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^{-176}:\\
                                    \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}} \cdot \left(ky \cdot \sin th\right)\\
                                    
                                    \mathbf{elif}\;t\_1 \leq 0.0001:\\
                                    \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\sin th\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 3 regimes
                                    2. 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))))) < 2e-176

                                      1. Initial program 93.8%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Step-by-step derivation
                                        1. sqrt-lowering-sqrt.f64N/A

                                          \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                                        2. +-commutativeN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                        3. unpow2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                        4. sin-multN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                        5. div-invN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                        6. metadata-evalN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                        7. accelerator-lowering-fma.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                                        8. count-2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        9. +-inversesN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        10. cos-0N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        11. --lowering--.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        12. count-2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        13. cos-lowering-cos.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        14. +-lowering-+.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                        15. unpow2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                                        16. sqr-sin-aN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        17. cancel-sign-sub-invN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        18. +-lowering-+.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        19. *-lowering-*.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                        20. metadata-evalN/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                                        21. count-2N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                        22. cos-lowering-cos.f64N/A

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                                        23. +-lowering-+.f6478.4

                                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                      4. Applied egg-rr78.4%

                                        \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                                      5. Taylor expanded in ky around 0

                                        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
                                      6. Step-by-step derivation
                                        1. *-lowering-*.f64N/A

                                          \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
                                        2. *-lowering-*.f64N/A

                                          \[\leadsto \color{blue}{\left(ky \cdot \sin th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
                                        3. sin-lowering-sin.f64N/A

                                          \[\leadsto \left(ky \cdot \color{blue}{\sin th}\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
                                        4. sqrt-lowering-sqrt.f64N/A

                                          \[\leadsto \left(ky \cdot \sin th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
                                        5. /-lowering-/.f64N/A

                                          \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
                                        6. +-commutativeN/A

                                          \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \]
                                        7. metadata-evalN/A

                                          \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \]
                                        8. distribute-lft-neg-inN/A

                                          \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \]
                                        9. accelerator-lowering-fma.f64N/A

                                          \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \]
                                        10. cos-negN/A

                                          \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
                                        11. cos-lowering-cos.f64N/A

                                          \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
                                        12. *-commutativeN/A

                                          \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \]
                                        13. *-lowering-*.f6438.2

                                          \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \]
                                      7. Simplified38.2%

                                        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \]

                                      if 2e-176 < (/.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.00000000000000005e-4

                                      1. Initial program 99.7%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in ky around 0

                                        \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                      4. Step-by-step derivation
                                        1. /-lowering-/.f64N/A

                                          \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                        2. sin-lowering-sin.f6473.7

                                          \[\leadsto \frac{ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                      5. Simplified73.7%

                                        \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]

                                      if 1.00000000000000005e-4 < (/.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. Initial program 95.3%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in kx around 0

                                        \[\leadsto \color{blue}{\sin th} \]
                                      4. Step-by-step derivation
                                        1. sin-lowering-sin.f6469.4

                                          \[\leadsto \color{blue}{\sin th} \]
                                      5. Simplified69.4%

                                        \[\leadsto \color{blue}{\sin th} \]
                                    3. Recombined 3 regimes into one program.
                                    4. Final simplification52.0%

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}} \cdot \left(ky \cdot \sin th\right)\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                    5. Add Preprocessing

                                    Alternative 15: 44.3% accurate, 0.8× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                    (FPCore (kx ky th)
                                     :precision binary64
                                     (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.0001)
                                       (* (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.0001) {
                                    		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.0001d0) 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.0001) {
                                    		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.0001:
                                    		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.0001)
                                    		tmp = Float64(sin(th) * Float64(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.0001)
                                    		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.0001], N[(N[Sin[th], $MachinePrecision] * N[(ky / 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.0001:\\
                                    \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\sin th\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. 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.00000000000000005e-4

                                      1. Initial program 94.6%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in ky around 0

                                        \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                      4. Step-by-step derivation
                                        1. /-lowering-/.f64N/A

                                          \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                        2. sin-lowering-sin.f6439.2

                                          \[\leadsto \frac{ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                      5. Simplified39.2%

                                        \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]

                                      if 1.00000000000000005e-4 < (/.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. Initial program 95.3%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in kx around 0

                                        \[\leadsto \color{blue}{\sin th} \]
                                      4. Step-by-step derivation
                                        1. sin-lowering-sin.f6469.4

                                          \[\leadsto \color{blue}{\sin th} \]
                                      5. Simplified69.4%

                                        \[\leadsto \color{blue}{\sin th} \]
                                    3. Recombined 2 regimes into one program.
                                    4. Final simplification49.4%

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                    5. Add Preprocessing

                                    Alternative 16: 35.9% accurate, 0.8× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.02:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                    (FPCore (kx ky th)
                                     :precision binary64
                                     (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.02)
                                       (* (sin ky) (/ (sin th) 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.02) {
                                    		tmp = sin(ky) * (sin(th) / 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.02d0) then
                                            tmp = sin(ky) * (sin(th) / 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.02) {
                                    		tmp = Math.sin(ky) * (Math.sin(th) / 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.02:
                                    		tmp = math.sin(ky) * (math.sin(th) / 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.02)
                                    		tmp = Float64(sin(ky) * Float64(sin(th) / 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.02)
                                    		tmp = sin(ky) * (sin(th) / 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.02], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / 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.02:\\
                                    \;\;\;\;\sin ky \cdot \frac{\sin th}{kx}\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\sin th\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. 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.0200000000000000004

                                      1. Initial program 94.6%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Step-by-step derivation
                                        1. associate-*l/N/A

                                          \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                        2. frac-2negN/A

                                          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\sin ky \cdot \sin th\right)}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
                                        3. div-invN/A

                                          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin ky \cdot \sin th\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
                                        4. *-lowering-*.f64N/A

                                          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin ky \cdot \sin th\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
                                        5. *-commutativeN/A

                                          \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\sin th \cdot \sin ky}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        6. distribute-rgt-neg-inN/A

                                          \[\leadsto \color{blue}{\left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        7. *-lowering-*.f64N/A

                                          \[\leadsto \color{blue}{\left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        8. sin-lowering-sin.f64N/A

                                          \[\leadsto \left(\color{blue}{\sin th} \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        9. neg-lowering-neg.f64N/A

                                          \[\leadsto \left(\sin th \cdot \color{blue}{\left(\mathsf{neg}\left(\sin ky\right)\right)}\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        10. sin-lowering-sin.f64N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\color{blue}{\sin ky}\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        11. neg-mul-1N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{1}{\color{blue}{-1 \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                        12. associate-/r*N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \color{blue}{\frac{\frac{1}{-1}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                        13. metadata-evalN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{\color{blue}{-1}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \]
                                        14. /-lowering-/.f64N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \color{blue}{\frac{-1}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                        15. sqrt-lowering-sqrt.f64N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                        16. +-commutativeN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
                                      4. Applied egg-rr74.6%

                                        \[\leadsto \color{blue}{\left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \]
                                      5. Taylor expanded in ky around 0

                                        \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
                                      6. Step-by-step derivation
                                        1. +-commutativeN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \]
                                        2. metadata-evalN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \]
                                        3. distribute-lft-neg-inN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \]
                                        4. accelerator-lowering-fma.f64N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \]
                                        5. cos-negN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
                                        6. cos-lowering-cos.f64N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
                                        7. *-commutativeN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \]
                                        8. *-lowering-*.f6443.3

                                          \[\leadsto \left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \]
                                      7. Simplified43.3%

                                        \[\leadsto \left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \]
                                      8. Taylor expanded in kx around 0

                                        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{kx}} \]
                                      9. Step-by-step derivation
                                        1. associate-/l*N/A

                                          \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{kx}} \]
                                        2. *-lowering-*.f64N/A

                                          \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{kx}} \]
                                        3. sin-lowering-sin.f64N/A

                                          \[\leadsto \color{blue}{\sin ky} \cdot \frac{\sin th}{kx} \]
                                        4. /-lowering-/.f64N/A

                                          \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{kx}} \]
                                        5. sin-lowering-sin.f6424.0

                                          \[\leadsto \sin ky \cdot \frac{\color{blue}{\sin th}}{kx} \]
                                      10. Simplified24.0%

                                        \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{kx}} \]

                                      if 0.0200000000000000004 < (/.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. Initial program 95.3%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in kx around 0

                                        \[\leadsto \color{blue}{\sin th} \]
                                      4. Step-by-step derivation
                                        1. sin-lowering-sin.f6469.4

                                          \[\leadsto \color{blue}{\sin th} \]
                                      5. Simplified69.4%

                                        \[\leadsto \color{blue}{\sin th} \]
                                    3. Recombined 2 regimes into one program.
                                    4. Add Preprocessing

                                    Alternative 17: 34.9% accurate, 0.9× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;\left(\sin th \cdot \left(ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.16666666666666666, -1\right)\right)\right) \cdot \frac{-1}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                    (FPCore (kx ky th)
                                     :precision binary64
                                     (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.0001)
                                       (* (* (sin th) (* ky (fma (* ky ky) 0.16666666666666666 -1.0))) (/ -1.0 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.0001) {
                                    		tmp = (sin(th) * (ky * fma((ky * ky), 0.16666666666666666, -1.0))) * (-1.0 / kx);
                                    	} 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)))) <= 0.0001)
                                    		tmp = Float64(Float64(sin(th) * Float64(ky * fma(Float64(ky * ky), 0.16666666666666666, -1.0))) * Float64(-1.0 / kx));
                                    	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], 0.0001], N[(N[(N[Sin[th], $MachinePrecision] * N[(ky * N[(N[(ky * ky), $MachinePrecision] * 0.16666666666666666 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / 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.0001:\\
                                    \;\;\;\;\left(\sin th \cdot \left(ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.16666666666666666, -1\right)\right)\right) \cdot \frac{-1}{kx}\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\sin th\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. 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.00000000000000005e-4

                                      1. Initial program 94.6%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Step-by-step derivation
                                        1. associate-*l/N/A

                                          \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                        2. frac-2negN/A

                                          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\sin ky \cdot \sin th\right)}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
                                        3. div-invN/A

                                          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin ky \cdot \sin th\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
                                        4. *-lowering-*.f64N/A

                                          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin ky \cdot \sin th\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
                                        5. *-commutativeN/A

                                          \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\sin th \cdot \sin ky}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        6. distribute-rgt-neg-inN/A

                                          \[\leadsto \color{blue}{\left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        7. *-lowering-*.f64N/A

                                          \[\leadsto \color{blue}{\left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        8. sin-lowering-sin.f64N/A

                                          \[\leadsto \left(\color{blue}{\sin th} \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        9. neg-lowering-neg.f64N/A

                                          \[\leadsto \left(\sin th \cdot \color{blue}{\left(\mathsf{neg}\left(\sin ky\right)\right)}\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        10. sin-lowering-sin.f64N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\color{blue}{\sin ky}\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                        11. neg-mul-1N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{1}{\color{blue}{-1 \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                        12. associate-/r*N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \color{blue}{\frac{\frac{1}{-1}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                        13. metadata-evalN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{\color{blue}{-1}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \]
                                        14. /-lowering-/.f64N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \color{blue}{\frac{-1}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                        15. sqrt-lowering-sqrt.f64N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                        16. +-commutativeN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
                                      4. Applied egg-rr74.6%

                                        \[\leadsto \color{blue}{\left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \]
                                      5. Taylor expanded in ky around 0

                                        \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
                                      6. Step-by-step derivation
                                        1. +-commutativeN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \]
                                        2. metadata-evalN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \]
                                        3. distribute-lft-neg-inN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \]
                                        4. accelerator-lowering-fma.f64N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \]
                                        5. cos-negN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
                                        6. cos-lowering-cos.f64N/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
                                        7. *-commutativeN/A

                                          \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \]
                                        8. *-lowering-*.f6443.3

                                          \[\leadsto \left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \]
                                      7. Simplified43.3%

                                        \[\leadsto \left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \]
                                      8. Taylor expanded in kx around 0

                                        \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\color{blue}{kx}} \]
                                      9. Step-by-step derivation
                                        1. Simplified23.5%

                                          \[\leadsto \left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\color{blue}{kx}} \]
                                        2. Taylor expanded in ky around 0

                                          \[\leadsto \left(\sin th \cdot \color{blue}{\left(ky \cdot \left(\frac{1}{6} \cdot {ky}^{2} - 1\right)\right)}\right) \cdot \frac{-1}{kx} \]
                                        3. Step-by-step derivation
                                          1. *-lowering-*.f64N/A

                                            \[\leadsto \left(\sin th \cdot \color{blue}{\left(ky \cdot \left(\frac{1}{6} \cdot {ky}^{2} - 1\right)\right)}\right) \cdot \frac{-1}{kx} \]
                                          2. sub-negN/A

                                            \[\leadsto \left(\sin th \cdot \left(ky \cdot \color{blue}{\left(\frac{1}{6} \cdot {ky}^{2} + \left(\mathsf{neg}\left(1\right)\right)\right)}\right)\right) \cdot \frac{-1}{kx} \]
                                          3. *-commutativeN/A

                                            \[\leadsto \left(\sin th \cdot \left(ky \cdot \left(\color{blue}{{ky}^{2} \cdot \frac{1}{6}} + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right) \cdot \frac{-1}{kx} \]
                                          4. metadata-evalN/A

                                            \[\leadsto \left(\sin th \cdot \left(ky \cdot \left({ky}^{2} \cdot \frac{1}{6} + \color{blue}{-1}\right)\right)\right) \cdot \frac{-1}{kx} \]
                                          5. accelerator-lowering-fma.f64N/A

                                            \[\leadsto \left(\sin th \cdot \left(ky \cdot \color{blue}{\mathsf{fma}\left({ky}^{2}, \frac{1}{6}, -1\right)}\right)\right) \cdot \frac{-1}{kx} \]
                                          6. unpow2N/A

                                            \[\leadsto \left(\sin th \cdot \left(ky \cdot \mathsf{fma}\left(\color{blue}{ky \cdot ky}, \frac{1}{6}, -1\right)\right)\right) \cdot \frac{-1}{kx} \]
                                          7. *-lowering-*.f6423.1

                                            \[\leadsto \left(\sin th \cdot \left(ky \cdot \mathsf{fma}\left(\color{blue}{ky \cdot ky}, 0.16666666666666666, -1\right)\right)\right) \cdot \frac{-1}{kx} \]
                                        4. Simplified23.1%

                                          \[\leadsto \left(\sin th \cdot \color{blue}{\left(ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.16666666666666666, -1\right)\right)}\right) \cdot \frac{-1}{kx} \]

                                        if 1.00000000000000005e-4 < (/.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. Initial program 95.3%

                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in kx around 0

                                          \[\leadsto \color{blue}{\sin th} \]
                                        4. Step-by-step derivation
                                          1. sin-lowering-sin.f6469.4

                                            \[\leadsto \color{blue}{\sin th} \]
                                        5. Simplified69.4%

                                          \[\leadsto \color{blue}{\sin th} \]
                                      10. Recombined 2 regimes into one program.
                                      11. Add Preprocessing

                                      Alternative 18: 15.4% accurate, 1.0× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-299}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \end{array} \]
                                      (FPCore (kx ky th)
                                       :precision binary64
                                       (if (<=
                                            (*
                                             (sin th)
                                             (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
                                            1e-299)
                                         (* -0.16666666666666666 (* th (* th th)))
                                         th))
                                      double code(double kx, double ky, double th) {
                                      	double tmp;
                                      	if ((sin(th) * (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0))))) <= 1e-299) {
                                      		tmp = -0.16666666666666666 * (th * (th * th));
                                      	} else {
                                      		tmp = 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(th) * (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0))))) <= 1d-299) then
                                              tmp = (-0.16666666666666666d0) * (th * (th * th))
                                          else
                                              tmp = th
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double kx, double ky, double th) {
                                      	double tmp;
                                      	if ((Math.sin(th) * (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0))))) <= 1e-299) {
                                      		tmp = -0.16666666666666666 * (th * (th * th));
                                      	} else {
                                      		tmp = th;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(kx, ky, th):
                                      	tmp = 0
                                      	if (math.sin(th) * (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))))) <= 1e-299:
                                      		tmp = -0.16666666666666666 * (th * (th * th))
                                      	else:
                                      		tmp = th
                                      	return tmp
                                      
                                      function code(kx, ky, th)
                                      	tmp = 0.0
                                      	if (Float64(sin(th) * Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))) <= 1e-299)
                                      		tmp = Float64(-0.16666666666666666 * Float64(th * Float64(th * th)));
                                      	else
                                      		tmp = th;
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(kx, ky, th)
                                      	tmp = 0.0;
                                      	if ((sin(th) * (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))) <= 1e-299)
                                      		tmp = -0.16666666666666666 * (th * (th * th));
                                      	else
                                      		tmp = th;
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[th], $MachinePrecision] * 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]), $MachinePrecision], 1e-299], N[(-0.16666666666666666 * N[(th * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], th]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-299}:\\
                                      \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;th\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. 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.99999999999999992e-300

                                        1. Initial program 94.7%

                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in kx around 0

                                          \[\leadsto \color{blue}{\sin th} \]
                                        4. Step-by-step derivation
                                          1. sin-lowering-sin.f6422.9

                                            \[\leadsto \color{blue}{\sin th} \]
                                        5. Simplified22.9%

                                          \[\leadsto \color{blue}{\sin th} \]
                                        6. Taylor expanded in th around 0

                                          \[\leadsto \color{blue}{th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)} \]
                                        7. Step-by-step derivation
                                          1. +-commutativeN/A

                                            \[\leadsto th \cdot \color{blue}{\left(\frac{-1}{6} \cdot {th}^{2} + 1\right)} \]
                                          2. distribute-lft-inN/A

                                            \[\leadsto \color{blue}{th \cdot \left(\frac{-1}{6} \cdot {th}^{2}\right) + th \cdot 1} \]
                                          3. *-rgt-identityN/A

                                            \[\leadsto th \cdot \left(\frac{-1}{6} \cdot {th}^{2}\right) + \color{blue}{th} \]
                                          4. accelerator-lowering-fma.f64N/A

                                            \[\leadsto \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
                                          5. *-lowering-*.f64N/A

                                            \[\leadsto \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
                                          6. unpow2N/A

                                            \[\leadsto \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
                                          7. *-lowering-*.f6414.3

                                            \[\leadsto \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
                                        8. Simplified14.3%

                                          \[\leadsto \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]
                                        9. Taylor expanded in th around inf

                                          \[\leadsto \color{blue}{\frac{-1}{6} \cdot {th}^{3}} \]
                                        10. Step-by-step derivation
                                          1. *-lowering-*.f64N/A

                                            \[\leadsto \color{blue}{\frac{-1}{6} \cdot {th}^{3}} \]
                                          2. cube-multN/A

                                            \[\leadsto \frac{-1}{6} \cdot \color{blue}{\left(th \cdot \left(th \cdot th\right)\right)} \]
                                          3. unpow2N/A

                                            \[\leadsto \frac{-1}{6} \cdot \left(th \cdot \color{blue}{{th}^{2}}\right) \]
                                          4. *-lowering-*.f64N/A

                                            \[\leadsto \frac{-1}{6} \cdot \color{blue}{\left(th \cdot {th}^{2}\right)} \]
                                          5. unpow2N/A

                                            \[\leadsto \frac{-1}{6} \cdot \left(th \cdot \color{blue}{\left(th \cdot th\right)}\right) \]
                                          6. *-lowering-*.f6417.2

                                            \[\leadsto -0.16666666666666666 \cdot \left(th \cdot \color{blue}{\left(th \cdot th\right)}\right) \]
                                        11. Simplified17.2%

                                          \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)} \]

                                        if 9.99999999999999992e-300 < (*.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))

                                        1. Initial program 95.0%

                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in kx around 0

                                          \[\leadsto \color{blue}{\sin th} \]
                                        4. Step-by-step derivation
                                          1. sin-lowering-sin.f6430.7

                                            \[\leadsto \color{blue}{\sin th} \]
                                        5. Simplified30.7%

                                          \[\leadsto \color{blue}{\sin th} \]
                                        6. Taylor expanded in th around 0

                                          \[\leadsto \color{blue}{th} \]
                                        7. Step-by-step derivation
                                          1. Simplified17.5%

                                            \[\leadsto \color{blue}{th} \]
                                        8. Recombined 2 regimes into one program.
                                        9. Final simplification17.3%

                                          \[\leadsto \begin{array}{l} \mathbf{if}\;\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-299}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \]
                                        10. Add Preprocessing

                                        Alternative 19: 35.2% accurate, 1.0× speedup?

                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;\frac{ky \cdot \sin th}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                        (FPCore (kx ky th)
                                         :precision binary64
                                         (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.0001)
                                           (/ (* ky (sin th)) 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.0001) {
                                        		tmp = (ky * sin(th)) / 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.0001d0) then
                                                tmp = (ky * sin(th)) / 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.0001) {
                                        		tmp = (ky * Math.sin(th)) / 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.0001:
                                        		tmp = (ky * math.sin(th)) / 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.0001)
                                        		tmp = Float64(Float64(ky * sin(th)) / 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.0001)
                                        		tmp = (ky * sin(th)) / 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.0001], N[(N[(ky * N[Sin[th], $MachinePrecision]), $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 0.0001:\\
                                        \;\;\;\;\frac{ky \cdot \sin th}{kx}\\
                                        
                                        \mathbf{else}:\\
                                        \;\;\;\;\sin th\\
                                        
                                        
                                        \end{array}
                                        \end{array}
                                        
                                        Derivation
                                        1. Split input into 2 regimes
                                        2. 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.00000000000000005e-4

                                          1. Initial program 94.6%

                                            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                          2. Add Preprocessing
                                          3. Step-by-step derivation
                                            1. associate-*l/N/A

                                              \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                            2. frac-2negN/A

                                              \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\sin ky \cdot \sin th\right)}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
                                            3. div-invN/A

                                              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin ky \cdot \sin th\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
                                            4. *-lowering-*.f64N/A

                                              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin ky \cdot \sin th\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
                                            5. *-commutativeN/A

                                              \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\sin th \cdot \sin ky}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                            6. distribute-rgt-neg-inN/A

                                              \[\leadsto \color{blue}{\left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                            7. *-lowering-*.f64N/A

                                              \[\leadsto \color{blue}{\left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                            8. sin-lowering-sin.f64N/A

                                              \[\leadsto \left(\color{blue}{\sin th} \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                            9. neg-lowering-neg.f64N/A

                                              \[\leadsto \left(\sin th \cdot \color{blue}{\left(\mathsf{neg}\left(\sin ky\right)\right)}\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                            10. sin-lowering-sin.f64N/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\color{blue}{\sin ky}\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
                                            11. neg-mul-1N/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{1}{\color{blue}{-1 \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                            12. associate-/r*N/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \color{blue}{\frac{\frac{1}{-1}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                            13. metadata-evalN/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{\color{blue}{-1}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \]
                                            14. /-lowering-/.f64N/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \color{blue}{\frac{-1}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                            15. sqrt-lowering-sqrt.f64N/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                            16. +-commutativeN/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
                                          4. Applied egg-rr74.6%

                                            \[\leadsto \color{blue}{\left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \]
                                          5. Taylor expanded in ky around 0

                                            \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
                                          6. Step-by-step derivation
                                            1. +-commutativeN/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \]
                                            2. metadata-evalN/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \]
                                            3. distribute-lft-neg-inN/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \]
                                            4. accelerator-lowering-fma.f64N/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \]
                                            5. cos-negN/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
                                            6. cos-lowering-cos.f64N/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
                                            7. *-commutativeN/A

                                              \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \]
                                            8. *-lowering-*.f6443.3

                                              \[\leadsto \left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \]
                                          7. Simplified43.3%

                                            \[\leadsto \left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \]
                                          8. Taylor expanded in kx around 0

                                            \[\leadsto \left(\sin th \cdot \left(\mathsf{neg}\left(\sin ky\right)\right)\right) \cdot \frac{-1}{\color{blue}{kx}} \]
                                          9. Step-by-step derivation
                                            1. Simplified23.5%

                                              \[\leadsto \left(\sin th \cdot \left(-\sin ky\right)\right) \cdot \frac{-1}{\color{blue}{kx}} \]
                                            2. Taylor expanded in ky around 0

                                              \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{kx}} \]
                                            3. Step-by-step derivation
                                              1. /-lowering-/.f64N/A

                                                \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{kx}} \]
                                              2. *-lowering-*.f64N/A

                                                \[\leadsto \frac{\color{blue}{ky \cdot \sin th}}{kx} \]
                                              3. sin-lowering-sin.f6423.1

                                                \[\leadsto \frac{ky \cdot \color{blue}{\sin th}}{kx} \]
                                            4. Simplified23.1%

                                              \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{kx}} \]

                                            if 1.00000000000000005e-4 < (/.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. Initial program 95.3%

                                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in kx around 0

                                              \[\leadsto \color{blue}{\sin th} \]
                                            4. Step-by-step derivation
                                              1. sin-lowering-sin.f6469.4

                                                \[\leadsto \color{blue}{\sin th} \]
                                            5. Simplified69.4%

                                              \[\leadsto \color{blue}{\sin th} \]
                                          10. Recombined 2 regimes into one program.
                                          11. Add Preprocessing

                                          Alternative 20: 35.6% accurate, 1.0× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                          (FPCore (kx ky th)
                                           :precision binary64
                                           (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.0001)
                                             (* 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.0001) {
                                          		tmp = 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.0001d0) then
                                                  tmp = 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.0001) {
                                          		tmp = 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.0001:
                                          		tmp = 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.0001)
                                          		tmp = Float64(th * Float64(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.0001)
                                          		tmp = 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.0001], N[(th * N[(ky / 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.0001:\\
                                          \;\;\;\;th \cdot \frac{ky}{\sin kx}\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\sin th\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. 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.00000000000000005e-4

                                            1. Initial program 94.6%

                                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                            2. Add Preprocessing
                                            3. Step-by-step derivation
                                              1. +-commutativeN/A

                                                \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                              2. unpow2N/A

                                                \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                              3. unpow2N/A

                                                \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                                              4. accelerator-lowering-hypot.f64N/A

                                                \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                              5. sin-lowering-sin.f64N/A

                                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                                              6. sin-lowering-sin.f6499.8

                                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                                            4. Applied egg-rr99.8%

                                              \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                            5. Taylor expanded in th around 0

                                              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                                            6. Step-by-step derivation
                                              1. Simplified49.8%

                                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                                              2. Taylor expanded in ky around 0

                                                \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot th \]
                                              3. Step-by-step derivation
                                                1. /-lowering-/.f64N/A

                                                  \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot th \]
                                                2. sin-lowering-sin.f6422.4

                                                  \[\leadsto \frac{ky}{\color{blue}{\sin kx}} \cdot th \]
                                              4. Simplified22.4%

                                                \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot th \]

                                              if 1.00000000000000005e-4 < (/.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. Initial program 95.3%

                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                              2. Add Preprocessing
                                              3. Taylor expanded in kx around 0

                                                \[\leadsto \color{blue}{\sin th} \]
                                              4. Step-by-step derivation
                                                1. sin-lowering-sin.f6469.4

                                                  \[\leadsto \color{blue}{\sin th} \]
                                              5. Simplified69.4%

                                                \[\leadsto \color{blue}{\sin th} \]
                                            7. Recombined 2 regimes into one program.
                                            8. Final simplification38.4%

                                              \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                            9. Add Preprocessing

                                            Alternative 21: 35.6% accurate, 1.0× speedup?

                                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.0001:\\ \;\;\;\;ky \cdot \frac{th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                            (FPCore (kx ky th)
                                             :precision binary64
                                             (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.0001)
                                               (* ky (/ 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.0001) {
                                            		tmp = ky * (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.0001d0) then
                                                    tmp = ky * (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.0001) {
                                            		tmp = ky * (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.0001:
                                            		tmp = ky * (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.0001)
                                            		tmp = Float64(ky * Float64(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.0001)
                                            		tmp = ky * (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.0001], N[(ky * N[(th / 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.0001:\\
                                            \;\;\;\;ky \cdot \frac{th}{\sin kx}\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;\sin th\\
                                            
                                            
                                            \end{array}
                                            \end{array}
                                            
                                            Derivation
                                            1. Split input into 2 regimes
                                            2. 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.00000000000000005e-4

                                              1. Initial program 94.6%

                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                              2. Add Preprocessing
                                              3. Step-by-step derivation
                                                1. +-commutativeN/A

                                                  \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                                2. unpow2N/A

                                                  \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                                3. unpow2N/A

                                                  \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                                                4. accelerator-lowering-hypot.f64N/A

                                                  \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                                5. sin-lowering-sin.f64N/A

                                                  \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                                                6. sin-lowering-sin.f6499.8

                                                  \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                                              4. Applied egg-rr99.8%

                                                \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                              5. Taylor expanded in th around 0

                                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                                              6. Step-by-step derivation
                                                1. Simplified49.8%

                                                  \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \color{blue}{th} \]
                                                2. Taylor expanded in ky around 0

                                                  \[\leadsto \color{blue}{\frac{ky \cdot th}{\sin kx}} \]
                                                3. Step-by-step derivation
                                                  1. associate-/l*N/A

                                                    \[\leadsto \color{blue}{ky \cdot \frac{th}{\sin kx}} \]
                                                  2. *-lowering-*.f64N/A

                                                    \[\leadsto \color{blue}{ky \cdot \frac{th}{\sin kx}} \]
                                                  3. /-lowering-/.f64N/A

                                                    \[\leadsto ky \cdot \color{blue}{\frac{th}{\sin kx}} \]
                                                  4. sin-lowering-sin.f6422.3

                                                    \[\leadsto ky \cdot \frac{th}{\color{blue}{\sin kx}} \]
                                                4. Simplified22.3%

                                                  \[\leadsto \color{blue}{ky \cdot \frac{th}{\sin kx}} \]

                                                if 1.00000000000000005e-4 < (/.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. Initial program 95.3%

                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in kx around 0

                                                  \[\leadsto \color{blue}{\sin th} \]
                                                4. Step-by-step derivation
                                                  1. sin-lowering-sin.f6469.4

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                5. Simplified69.4%

                                                  \[\leadsto \color{blue}{\sin th} \]
                                              7. Recombined 2 regimes into one program.
                                              8. Add Preprocessing

                                              Alternative 22: 30.8% accurate, 1.0× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 4 \cdot 10^{-47}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                              (FPCore (kx ky th)
                                               :precision binary64
                                               (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 4e-47)
                                                 (* -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)))) <= 4e-47) {
                                              		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)))) <= 4d-47) 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)))) <= 4e-47) {
                                              		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)))) <= 4e-47:
                                              		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)))) <= 4e-47)
                                              		tmp = Float64(-0.16666666666666666 * Float64(th * Float64(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)))) <= 4e-47)
                                              		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], 4e-47], N[(-0.16666666666666666 * N[(th * N[(th * th), $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 4 \cdot 10^{-47}:\\
                                              \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\sin th\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 2 regimes
                                              2. 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))))) < 3.9999999999999999e-47

                                                1. Initial program 94.5%

                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in kx around 0

                                                  \[\leadsto \color{blue}{\sin th} \]
                                                4. Step-by-step derivation
                                                  1. sin-lowering-sin.f643.6

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                5. Simplified3.6%

                                                  \[\leadsto \color{blue}{\sin th} \]
                                                6. Taylor expanded in th around 0

                                                  \[\leadsto \color{blue}{th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)} \]
                                                7. Step-by-step derivation
                                                  1. +-commutativeN/A

                                                    \[\leadsto th \cdot \color{blue}{\left(\frac{-1}{6} \cdot {th}^{2} + 1\right)} \]
                                                  2. distribute-lft-inN/A

                                                    \[\leadsto \color{blue}{th \cdot \left(\frac{-1}{6} \cdot {th}^{2}\right) + th \cdot 1} \]
                                                  3. *-rgt-identityN/A

                                                    \[\leadsto th \cdot \left(\frac{-1}{6} \cdot {th}^{2}\right) + \color{blue}{th} \]
                                                  4. accelerator-lowering-fma.f64N/A

                                                    \[\leadsto \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
                                                  5. *-lowering-*.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
                                                  6. unpow2N/A

                                                    \[\leadsto \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
                                                  7. *-lowering-*.f643.6

                                                    \[\leadsto \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
                                                8. Simplified3.6%

                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]
                                                9. Taylor expanded in th around inf

                                                  \[\leadsto \color{blue}{\frac{-1}{6} \cdot {th}^{3}} \]
                                                10. Step-by-step derivation
                                                  1. *-lowering-*.f64N/A

                                                    \[\leadsto \color{blue}{\frac{-1}{6} \cdot {th}^{3}} \]
                                                  2. cube-multN/A

                                                    \[\leadsto \frac{-1}{6} \cdot \color{blue}{\left(th \cdot \left(th \cdot th\right)\right)} \]
                                                  3. unpow2N/A

                                                    \[\leadsto \frac{-1}{6} \cdot \left(th \cdot \color{blue}{{th}^{2}}\right) \]
                                                  4. *-lowering-*.f64N/A

                                                    \[\leadsto \frac{-1}{6} \cdot \color{blue}{\left(th \cdot {th}^{2}\right)} \]
                                                  5. unpow2N/A

                                                    \[\leadsto \frac{-1}{6} \cdot \left(th \cdot \color{blue}{\left(th \cdot th\right)}\right) \]
                                                  6. *-lowering-*.f6416.2

                                                    \[\leadsto -0.16666666666666666 \cdot \left(th \cdot \color{blue}{\left(th \cdot th\right)}\right) \]
                                                11. Simplified16.2%

                                                  \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)} \]

                                                if 3.9999999999999999e-47 < (/.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. Initial program 95.5%

                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in kx around 0

                                                  \[\leadsto \color{blue}{\sin th} \]
                                                4. Step-by-step derivation
                                                  1. sin-lowering-sin.f6466.1

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                5. Simplified66.1%

                                                  \[\leadsto \color{blue}{\sin th} \]
                                              3. Recombined 2 regimes into one program.
                                              4. Add Preprocessing

                                              Alternative 23: 75.1% accurate, 1.4× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 5.8 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \end{array} \end{array} \]
                                              (FPCore (kx ky th)
                                               :precision binary64
                                               (if (<= ky 5.8e-5)
                                                 (* (sin th) (/ (sin ky) (hypot ky (sin kx))))
                                                 (*
                                                  (sin ky)
                                                  (/
                                                   (sin th)
                                                   (sqrt
                                                    (fma (- 1.0 (cos (+ ky ky))) 0.5 (+ 0.5 (* -0.5 (cos (+ kx kx))))))))))
                                              double code(double kx, double ky, double th) {
                                              	double tmp;
                                              	if (ky <= 5.8e-5) {
                                              		tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
                                              	} else {
                                              		tmp = sin(ky) * (sin(th) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, (0.5 + (-0.5 * cos((kx + kx)))))));
                                              	}
                                              	return tmp;
                                              }
                                              
                                              function code(kx, ky, th)
                                              	tmp = 0.0
                                              	if (ky <= 5.8e-5)
                                              		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx))));
                                              	else
                                              		tmp = Float64(sin(ky) * Float64(sin(th) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx))))))));
                                              	end
                                              	return tmp
                                              end
                                              
                                              code[kx_, ky_, th_] := If[LessEqual[ky, 5.8e-5], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              \mathbf{if}\;ky \leq 5.8 \cdot 10^{-5}:\\
                                              \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 2 regimes
                                              2. if ky < 5.8e-5

                                                1. Initial program 93.6%

                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                2. Add Preprocessing
                                                3. Step-by-step derivation
                                                  1. +-commutativeN/A

                                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                                  2. unpow2N/A

                                                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                                  3. unpow2N/A

                                                    \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                                                  4. accelerator-lowering-hypot.f64N/A

                                                    \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                                  5. sin-lowering-sin.f64N/A

                                                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                                                  6. sin-lowering-sin.f6499.8

                                                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                                                4. Applied egg-rr99.8%

                                                  \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                                5. Taylor expanded in ky around 0

                                                  \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \cdot \sin th \]
                                                6. Step-by-step derivation
                                                  1. Simplified67.3%

                                                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \cdot \sin th \]

                                                  if 5.8e-5 < ky

                                                  1. Initial program 99.7%

                                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                  2. Add Preprocessing
                                                  3. Step-by-step derivation
                                                    1. associate-*l/N/A

                                                      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                                    2. associate-/l*N/A

                                                      \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                                    3. *-commutativeN/A

                                                      \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                                                    4. *-lowering-*.f64N/A

                                                      \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                                                  4. Applied egg-rr99.4%

                                                    \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \sin ky} \]
                                                7. Recombined 2 regimes into one program.
                                                8. Final simplification73.8%

                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 5.8 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \end{array} \]
                                                9. Add Preprocessing

                                                Alternative 24: 75.2% accurate, 1.4× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 5.8 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \end{array} \end{array} \]
                                                (FPCore (kx ky th)
                                                 :precision binary64
                                                 (if (<= ky 5.8e-5)
                                                   (* (sin th) (/ (sin ky) (hypot ky (sin kx))))
                                                   (*
                                                    (sin th)
                                                    (/
                                                     (sin ky)
                                                     (sqrt
                                                      (fma (- 1.0 (cos (+ ky ky))) 0.5 (+ 0.5 (* -0.5 (cos (+ kx kx))))))))))
                                                double code(double kx, double ky, double th) {
                                                	double tmp;
                                                	if (ky <= 5.8e-5) {
                                                		tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
                                                	} else {
                                                		tmp = sin(th) * (sin(ky) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, (0.5 + (-0.5 * cos((kx + kx)))))));
                                                	}
                                                	return tmp;
                                                }
                                                
                                                function code(kx, ky, th)
                                                	tmp = 0.0
                                                	if (ky <= 5.8e-5)
                                                		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx))));
                                                	else
                                                		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx))))))));
                                                	end
                                                	return tmp
                                                end
                                                
                                                code[kx_, ky_, th_] := If[LessEqual[ky, 5.8e-5], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;ky \leq 5.8 \cdot 10^{-5}:\\
                                                \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if ky < 5.8e-5

                                                  1. Initial program 93.6%

                                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                  2. Add Preprocessing
                                                  3. Step-by-step derivation
                                                    1. +-commutativeN/A

                                                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                                    2. unpow2N/A

                                                      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                                    3. unpow2N/A

                                                      \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                                                    4. accelerator-lowering-hypot.f64N/A

                                                      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                                    5. sin-lowering-sin.f64N/A

                                                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\sin ky}, \sin kx\right)} \cdot \sin th \]
                                                    6. sin-lowering-sin.f6499.8

                                                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)} \cdot \sin th \]
                                                  4. Applied egg-rr99.8%

                                                    \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                                  5. Taylor expanded in ky around 0

                                                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \cdot \sin th \]
                                                  6. Step-by-step derivation
                                                    1. Simplified67.3%

                                                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \cdot \sin th \]

                                                    if 5.8e-5 < ky

                                                    1. Initial program 99.7%

                                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                    2. Add Preprocessing
                                                    3. Step-by-step derivation
                                                      1. sqrt-lowering-sqrt.f64N/A

                                                        \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                                                      2. +-commutativeN/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                                      3. unpow2N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                                      4. sin-multN/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                                      5. div-invN/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                                      6. metadata-evalN/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                                      7. accelerator-lowering-fma.f64N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
                                                      8. count-2N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                                      9. +-inversesN/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \color{blue}{0} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                                      10. cos-0N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                                      11. --lowering--.f64N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                                      12. count-2N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                                      13. cos-lowering-cos.f64N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                                      14. +-lowering-+.f64N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                                      15. unpow2N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\sin kx \cdot \sin kx}\right)}} \cdot \sin th \]
                                                      16. sqr-sin-aN/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                                      17. cancel-sign-sub-invN/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                                      18. +-lowering-+.f64N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                                      19. *-lowering-*.f64N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot kx\right)}\right)}} \cdot \sin th \]
                                                      20. metadata-evalN/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2}} \cdot \cos \left(2 \cdot kx\right)\right)}} \cdot \sin th \]
                                                      21. count-2N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                                      22. cos-lowering-cos.f64N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(kx + kx\right)}\right)}} \cdot \sin th \]
                                                      23. +-lowering-+.f6499.3

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \color{blue}{\left(kx + kx\right)}\right)}} \cdot \sin th \]
                                                    4. Applied egg-rr99.3%

                                                      \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
                                                  7. Recombined 2 regimes into one program.
                                                  8. Final simplification73.8%

                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 5.8 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\\ \end{array} \]
                                                  9. Add Preprocessing

                                                  Alternative 25: 13.6% accurate, 632.0× speedup?

                                                  \[\begin{array}{l} \\ th \end{array} \]
                                                  (FPCore (kx ky th) :precision binary64 th)
                                                  double code(double kx, double ky, double th) {
                                                  	return th;
                                                  }
                                                  
                                                  real(8) function code(kx, ky, th)
                                                      real(8), intent (in) :: kx
                                                      real(8), intent (in) :: ky
                                                      real(8), intent (in) :: th
                                                      code = th
                                                  end function
                                                  
                                                  public static double code(double kx, double ky, double th) {
                                                  	return th;
                                                  }
                                                  
                                                  def code(kx, ky, th):
                                                  	return th
                                                  
                                                  function code(kx, ky, th)
                                                  	return th
                                                  end
                                                  
                                                  function tmp = code(kx, ky, th)
                                                  	tmp = th;
                                                  end
                                                  
                                                  code[kx_, ky_, th_] := th
                                                  
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  th
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Initial program 94.8%

                                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in kx around 0

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                  4. Step-by-step derivation
                                                    1. sin-lowering-sin.f6426.1

                                                      \[\leadsto \color{blue}{\sin th} \]
                                                  5. Simplified26.1%

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                  6. Taylor expanded in th around 0

                                                    \[\leadsto \color{blue}{th} \]
                                                  7. Step-by-step derivation
                                                    1. Simplified15.5%

                                                      \[\leadsto \color{blue}{th} \]
                                                    2. Add Preprocessing

                                                    Reproduce

                                                    ?
                                                    herbie shell --seed 2024198 
                                                    (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)))