Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.0% → 99.7%
Time: 15.5s
Alternatives: 26
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 26 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.0% 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 92.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.6

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

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

Alternative 2: 78.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := {\sin kx}^{2}\\ \mathbf{if}\;t\_1 \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, kx \cdot kx, -0.16666666666666666\right), 1\right)\right)}\\ \mathbf{elif}\;t\_1 \leq 0.12:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}{\sin ky}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (pow (sin kx) 2.0)))
   (if (<= t_1 2e-5)
     (*
      (sin th)
      (/
       (sin ky)
       (hypot
        (sin ky)
        (*
         kx
         (fma
          (* kx kx)
          (fma 0.008333333333333333 (* kx kx) -0.16666666666666666)
          1.0)))))
     (if (<= t_1 0.12)
       (* (/ (sin ky) (hypot (sin ky) (sin kx))) th)
       (/ (sin th) (/ (sqrt (fma -0.5 (cos (* kx -2.0)) 0.5)) (sin ky)))))))
double code(double kx, double ky, double th) {
	double t_1 = pow(sin(kx), 2.0);
	double tmp;
	if (t_1 <= 2e-5) {
		tmp = sin(th) * (sin(ky) / hypot(sin(ky), (kx * fma((kx * kx), fma(0.008333333333333333, (kx * kx), -0.16666666666666666), 1.0))));
	} else if (t_1 <= 0.12) {
		tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
	} else {
		tmp = sin(th) / (sqrt(fma(-0.5, cos((kx * -2.0)), 0.5)) / sin(ky));
	}
	return tmp;
}
function code(kx, ky, th)
	t_1 = sin(kx) ^ 2.0
	tmp = 0.0
	if (t_1 <= 2e-5)
		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), Float64(kx * fma(Float64(kx * kx), fma(0.008333333333333333, Float64(kx * kx), -0.16666666666666666), 1.0)))));
	elseif (t_1 <= 0.12)
		tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th);
	else
		tmp = Float64(sin(th) / Float64(sqrt(fma(-0.5, cos(Float64(kx * -2.0)), 0.5)) / sin(ky)));
	end
	return tmp
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$1, 2e-5], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(kx * N[(N[(kx * kx), $MachinePrecision] * N[(0.008333333333333333 * N[(kx * kx), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.12], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := {\sin kx}^{2}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, kx \cdot kx, -0.16666666666666666\right), 1\right)\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}{\sin ky}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 2.00000000000000016e-5

    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. +-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 kx around 0

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

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + {kx}^{2} \cdot \left(\frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}\right)\right)}\right)} \cdot \sin th \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}, 1\right)}\right)} \cdot \sin th \]
      4. unpow2N/A

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

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}, 1\right)\right)} \cdot \sin th \]
      6. sub-negN/A

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\frac{1}{120} \cdot {kx}^{2} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, 1\right)\right)} \cdot \sin th \]
      7. metadata-evalN/A

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

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\mathsf{fma}\left(\frac{1}{120}, {kx}^{2}, \frac{-1}{6}\right)}, 1\right)\right)} \cdot \sin th \]
      9. unpow2N/A

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

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, \color{blue}{kx \cdot kx}, -0.16666666666666666\right), 1\right)\right)} \cdot \sin th \]
    7. Simplified99.8%

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

    if 2.00000000000000016e-5 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 0.12

    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. Simplified67.7%

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

      if 0.12 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

      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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
        2. clear-numN/A

          \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
        3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}}{\sin ky}} \]
    7. Recombined 3 regimes into one program.
    8. Final simplification80.8%

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

    Alternative 3: 78.7% accurate, 0.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := {\sin kx}^{2}\\ \mathbf{if}\;t\_1 \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right)\right)}\\ \mathbf{elif}\;t\_1 \leq 0.12:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}{\sin ky}}\\ \end{array} \end{array} \]
    (FPCore (kx ky th)
     :precision binary64
     (let* ((t_1 (pow (sin kx) 2.0)))
       (if (<= t_1 2e-5)
         (*
          (sin th)
          (/
           (sin ky)
           (hypot (sin ky) (* kx (fma -0.16666666666666666 (* kx kx) 1.0)))))
         (if (<= t_1 0.12)
           (* (/ (sin ky) (hypot (sin ky) (sin kx))) th)
           (/ (sin th) (/ (sqrt (fma -0.5 (cos (* kx -2.0)) 0.5)) (sin ky)))))))
    double code(double kx, double ky, double th) {
    	double t_1 = pow(sin(kx), 2.0);
    	double tmp;
    	if (t_1 <= 2e-5) {
    		tmp = sin(th) * (sin(ky) / hypot(sin(ky), (kx * fma(-0.16666666666666666, (kx * kx), 1.0))));
    	} else if (t_1 <= 0.12) {
    		tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
    	} else {
    		tmp = sin(th) / (sqrt(fma(-0.5, cos((kx * -2.0)), 0.5)) / sin(ky));
    	}
    	return tmp;
    }
    
    function code(kx, ky, th)
    	t_1 = sin(kx) ^ 2.0
    	tmp = 0.0
    	if (t_1 <= 2e-5)
    		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), Float64(kx * fma(-0.16666666666666666, Float64(kx * kx), 1.0)))));
    	elseif (t_1 <= 0.12)
    		tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th);
    	else
    		tmp = Float64(sin(th) / Float64(sqrt(fma(-0.5, cos(Float64(kx * -2.0)), 0.5)) / sin(ky)));
    	end
    	return tmp
    end
    
    code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$1, 2e-5], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(kx * N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.12], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := {\sin kx}^{2}\\
    \mathbf{if}\;t\_1 \leq 2 \cdot 10^{-5}:\\
    \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right)\right)}\\
    
    \mathbf{elif}\;t\_1 \leq 0.12:\\
    \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}{\sin ky}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 2.00000000000000016e-5

      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. +-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 kx around 0

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

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

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

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

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

          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)\right)} \cdot \sin th \]
      7. Simplified99.8%

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

      if 2.00000000000000016e-5 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 0.12

      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. Simplified67.7%

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

        if 0.12 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

        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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
          2. clear-numN/A

            \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
          3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}}{\sin ky}} \]
      7. Recombined 3 regimes into one program.
      8. Final simplification80.8%

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

      Alternative 4: 78.6% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_1 := {\sin kx}^{2}\\ \mathbf{if}\;t\_1 \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;t\_1 \leq 0.12:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}{\sin ky}}\\ \end{array} \end{array} \]
      (FPCore (kx ky th)
       :precision binary64
       (let* ((t_1 (pow (sin kx) 2.0)))
         (if (<= t_1 2e-5)
           (* (sin th) (/ (sin ky) (hypot (sin ky) kx)))
           (if (<= t_1 0.12)
             (* (/ (sin ky) (hypot (sin ky) (sin kx))) th)
             (/ (sin th) (/ (sqrt (fma -0.5 (cos (* kx -2.0)) 0.5)) (sin ky)))))))
      double code(double kx, double ky, double th) {
      	double t_1 = pow(sin(kx), 2.0);
      	double tmp;
      	if (t_1 <= 2e-5) {
      		tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
      	} else if (t_1 <= 0.12) {
      		tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
      	} else {
      		tmp = sin(th) / (sqrt(fma(-0.5, cos((kx * -2.0)), 0.5)) / sin(ky));
      	}
      	return tmp;
      }
      
      function code(kx, ky, th)
      	t_1 = sin(kx) ^ 2.0
      	tmp = 0.0
      	if (t_1 <= 2e-5)
      		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx)));
      	elseif (t_1 <= 0.12)
      		tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th);
      	else
      		tmp = Float64(sin(th) / Float64(sqrt(fma(-0.5, cos(Float64(kx * -2.0)), 0.5)) / sin(ky)));
      	end
      	return tmp
      end
      
      code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$1, 2e-5], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.12], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_1 := {\sin kx}^{2}\\
      \mathbf{if}\;t\_1 \leq 2 \cdot 10^{-5}:\\
      \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
      
      \mathbf{elif}\;t\_1 \leq 0.12:\\
      \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}{\sin ky}}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 2.00000000000000016e-5

        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. +-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 kx around 0

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

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

          if 2.00000000000000016e-5 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 0.12

          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. Simplified67.7%

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

            if 0.12 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

            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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
              2. clear-numN/A

                \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}}{\sin ky}} \]
          7. Recombined 3 regimes into one program.
          8. Final simplification80.6%

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

          Alternative 5: 48.8% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-164}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \frac{1}{\sin kx}\right)\\ \mathbf{elif}\;\sin ky \leq 10^{-54}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, kx \cdot kx\right)}}{\sin ky}}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-23}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
          (FPCore (kx ky th)
           :precision binary64
           (if (<= (sin ky) -0.02)
             (* (* (sin ky) th) (sqrt (/ 2.0 (- 1.0 (cos (* ky -2.0))))))
             (if (<= (sin ky) 5e-164)
               (* (sin th) (* ky (/ 1.0 (sin kx))))
               (if (<= (sin ky) 1e-54)
                 (/
                  (sin th)
                  (/
                   (sqrt
                    (fma
                     (*
                      (* ky ky)
                      (fma
                       (* ky ky)
                       (fma
                        (* ky ky)
                        (fma (* ky ky) -0.006349206349206349 0.08888888888888889)
                        -0.6666666666666666)
                       2.0))
                     0.5
                     (* kx kx)))
                   (sin ky)))
                 (if (<= (sin ky) 2e-23)
                   (* (* ky (sin th)) (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5))))
                   (sin th))))))
          double code(double kx, double ky, double th) {
          	double tmp;
          	if (sin(ky) <= -0.02) {
          		tmp = (sin(ky) * th) * sqrt((2.0 / (1.0 - cos((ky * -2.0)))));
          	} else if (sin(ky) <= 5e-164) {
          		tmp = sin(th) * (ky * (1.0 / sin(kx)));
          	} else if (sin(ky) <= 1e-54) {
          		tmp = sin(th) / (sqrt(fma(((ky * ky) * fma((ky * ky), fma((ky * ky), fma((ky * ky), -0.006349206349206349, 0.08888888888888889), -0.6666666666666666), 2.0)), 0.5, (kx * kx))) / sin(ky));
          	} else if (sin(ky) <= 2e-23) {
          		tmp = (ky * sin(th)) * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5)));
          	} else {
          		tmp = sin(th);
          	}
          	return tmp;
          }
          
          function code(kx, ky, th)
          	tmp = 0.0
          	if (sin(ky) <= -0.02)
          		tmp = Float64(Float64(sin(ky) * th) * sqrt(Float64(2.0 / Float64(1.0 - cos(Float64(ky * -2.0))))));
          	elseif (sin(ky) <= 5e-164)
          		tmp = Float64(sin(th) * Float64(ky * Float64(1.0 / sin(kx))));
          	elseif (sin(ky) <= 1e-54)
          		tmp = Float64(sin(th) / Float64(sqrt(fma(Float64(Float64(ky * ky) * fma(Float64(ky * ky), fma(Float64(ky * ky), fma(Float64(ky * ky), -0.006349206349206349, 0.08888888888888889), -0.6666666666666666), 2.0)), 0.5, Float64(kx * kx))) / sin(ky)));
          	elseif (sin(ky) <= 2e-23)
          		tmp = Float64(Float64(ky * sin(th)) * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
          	else
          		tmp = sin(th);
          	end
          	return tmp
          end
          
          code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-164], N[(N[Sin[th], $MachinePrecision] * N[(ky * N[(1.0 / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-54], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * -0.006349206349206349 + 0.08888888888888889), $MachinePrecision] + -0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-23], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\sin ky \leq -0.02:\\
          \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\
          
          \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-164}:\\
          \;\;\;\;\sin th \cdot \left(ky \cdot \frac{1}{\sin kx}\right)\\
          
          \mathbf{elif}\;\sin ky \leq 10^{-54}:\\
          \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, kx \cdot kx\right)}}{\sin ky}}\\
          
          \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-23}:\\
          \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\
          
          \mathbf{else}:\\
          \;\;\;\;\sin th\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 5 regimes
          2. if (sin.f64 ky) < -0.0200000000000000004

            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. *-commutativeN/A

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

                \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -0.0200000000000000004 < (sin.f64 ky) < 4.99999999999999962e-164

            1. Initial program 82.9%

              \[\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}{\left(ky \cdot \left(-1 \cdot \left({ky}^{2} \cdot \left(\frac{1}{6} \cdot \frac{1}{\sin kx} + \frac{1}{2} \cdot \frac{1}{{\sin kx}^{3}}\right)\right) + \frac{1}{\sin kx}\right)\right)} \cdot \sin th \]
            4. Step-by-step derivation
              1. *-lowering-*.f64N/A

                \[\leadsto \color{blue}{\left(ky \cdot \left(-1 \cdot \left({ky}^{2} \cdot \left(\frac{1}{6} \cdot \frac{1}{\sin kx} + \frac{1}{2} \cdot \frac{1}{{\sin kx}^{3}}\right)\right) + \frac{1}{\sin kx}\right)\right)} \cdot \sin th \]
              2. mul-1-negN/A

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

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

                \[\leadsto \left(ky \cdot \color{blue}{\mathsf{fma}\left({ky}^{2}, \mathsf{neg}\left(\left(\frac{1}{6} \cdot \frac{1}{\sin kx} + \frac{1}{2} \cdot \frac{1}{{\sin kx}^{3}}\right)\right), \frac{1}{\sin kx}\right)}\right) \cdot \sin th \]
            5. Simplified40.6%

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

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

                \[\leadsto \left(ky \cdot \color{blue}{\frac{1}{\sin kx}}\right) \cdot \sin th \]
              2. sin-lowering-sin.f6443.5

                \[\leadsto \left(ky \cdot \frac{1}{\color{blue}{\sin kx}}\right) \cdot \sin th \]
            8. Simplified43.5%

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

            if 4.99999999999999962e-164 < (sin.f64 ky) < 1e-54

            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. *-commutativeN/A

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

                \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(\color{blue}{ky \cdot ky}, \frac{-2}{315}, \frac{4}{45}\right), \frac{-2}{3}\right), 2\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}}{\sin ky}} \]
              17. *-lowering-*.f6494.0

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

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

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

                \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \frac{-2}{315}, \frac{4}{45}\right), \frac{-2}{3}\right), 2\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}}{\sin ky}} \]
              2. *-lowering-*.f6453.4

                \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, \color{blue}{kx \cdot kx}\right)}}{\sin ky}} \]
            10. Simplified53.4%

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

            if 1e-54 < (sin.f64 ky) < 1.99999999999999992e-23

            1. Initial program 98.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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
              2. clear-numN/A

                \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              3. un-div-invN/A

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

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

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

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

              \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{\sin ky}}} \]
            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-*.f6449.3

                \[\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. Simplified49.3%

              \[\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 1.99999999999999992e-23 < (sin.f64 ky)

            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.f6459.6

                \[\leadsto \color{blue}{\sin th} \]
            5. Simplified59.6%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-164}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \frac{1}{\sin kx}\right)\\ \mathbf{elif}\;\sin ky \leq 10^{-54}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, kx \cdot kx\right)}}{\sin ky}}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-23}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
          5. Add Preprocessing

          Alternative 6: 99.3% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, kx \cdot kx, -0.16666666666666666\right), 1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \left(\sin ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\right)\\ \end{array} \end{array} \]
          (FPCore (kx ky th)
           :precision binary64
           (if (<= (pow (sin kx) 2.0) 2e-5)
             (*
              (sin th)
              (/
               (sin ky)
               (hypot
                (sin ky)
                (*
                 kx
                 (fma
                  (* kx kx)
                  (fma 0.008333333333333333 (* kx kx) -0.16666666666666666)
                  1.0)))))
             (*
              (sin th)
              (*
               (sin ky)
               (sqrt
                (/
                 1.0
                 (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 (pow(sin(kx), 2.0) <= 2e-5) {
          		tmp = sin(th) * (sin(ky) / hypot(sin(ky), (kx * fma((kx * kx), fma(0.008333333333333333, (kx * kx), -0.16666666666666666), 1.0))));
          	} else {
          		tmp = sin(th) * (sin(ky) * sqrt((1.0 / 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 ((sin(kx) ^ 2.0) <= 2e-5)
          		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), Float64(kx * fma(Float64(kx * kx), fma(0.008333333333333333, Float64(kx * kx), -0.16666666666666666), 1.0)))));
          	else
          		tmp = Float64(sin(th) * Float64(sin(ky) * sqrt(Float64(1.0 / 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[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 2e-5], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(kx * N[(N[(kx * kx), $MachinePrecision] * N[(0.008333333333333333 * N[(kx * kx), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * N[Sqrt[N[(1.0 / 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]), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-5}:\\
          \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, kx \cdot kx, -0.16666666666666666\right), 1\right)\right)}\\
          
          \mathbf{else}:\\
          \;\;\;\;\sin th \cdot \left(\sin ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 2.00000000000000016e-5

            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. +-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 kx around 0

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + {kx}^{2} \cdot \left(\frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}\right)\right)}\right)} \cdot \sin th \]
              2. +-commutativeN/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}, 1\right)}\right)} \cdot \sin th \]
              4. unpow2N/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}, 1\right)\right)} \cdot \sin th \]
              6. sub-negN/A

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\frac{1}{120} \cdot {kx}^{2} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, 1\right)\right)} \cdot \sin th \]
              7. metadata-evalN/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\mathsf{fma}\left(\frac{1}{120}, {kx}^{2}, \frac{-1}{6}\right)}, 1\right)\right)} \cdot \sin th \]
              9. unpow2N/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, \color{blue}{kx \cdot kx}, -0.16666666666666666\right), 1\right)\right)} \cdot \sin th \]
            7. Simplified99.8%

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

            if 2.00000000000000016e-5 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

            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. clear-numN/A

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

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

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

              \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{\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 \sin th \]
          3. Recombined 2 regimes into one program.
          4. Final simplification99.6%

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

          Alternative 7: 99.3% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, kx \cdot kx, -0.16666666666666666\right), 1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky \cdot \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 (<= (pow (sin kx) 2.0) 2e-5)
             (*
              (sin th)
              (/
               (sin ky)
               (hypot
                (sin ky)
                (*
                 kx
                 (fma
                  (* kx kx)
                  (fma 0.008333333333333333 (* kx kx) -0.16666666666666666)
                  1.0)))))
             (/
              (* (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 (pow(sin(kx), 2.0) <= 2e-5) {
          		tmp = sin(th) * (sin(ky) / hypot(sin(ky), (kx * fma((kx * kx), fma(0.008333333333333333, (kx * kx), -0.16666666666666666), 1.0))));
          	} 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 ((sin(kx) ^ 2.0) <= 2e-5)
          		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), Float64(kx * fma(Float64(kx * kx), fma(0.008333333333333333, Float64(kx * kx), -0.16666666666666666), 1.0)))));
          	else
          		tmp = Float64(Float64(sin(ky) * 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[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 2e-5], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(kx * N[(N[(kx * kx), $MachinePrecision] * N[(0.008333333333333333 * N[(kx * kx), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $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]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-5}:\\
          \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, kx \cdot kx, -0.16666666666666666\right), 1\right)\right)}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\sin ky \cdot \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 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 2.00000000000000016e-5

            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. +-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 kx around 0

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + {kx}^{2} \cdot \left(\frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}\right)\right)}\right)} \cdot \sin th \]
              2. +-commutativeN/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}, 1\right)}\right)} \cdot \sin th \]
              4. unpow2N/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}, 1\right)\right)} \cdot \sin th \]
              6. sub-negN/A

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\frac{1}{120} \cdot {kx}^{2} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, 1\right)\right)} \cdot \sin th \]
              7. metadata-evalN/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\mathsf{fma}\left(\frac{1}{120}, {kx}^{2}, \frac{-1}{6}\right)}, 1\right)\right)} \cdot \sin th \]
              9. unpow2N/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, \color{blue}{kx \cdot kx}, -0.16666666666666666\right), 1\right)\right)} \cdot \sin th \]
            7. Simplified99.8%

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

            if 2.00000000000000016e-5 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

            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. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{\sin ky \cdot \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)}}} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification99.5%

            \[\leadsto \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, kx \cdot kx, -0.16666666666666666\right), 1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky \cdot \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} \]
          5. Add Preprocessing

          Alternative 8: 99.3% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, kx \cdot kx, -0.16666666666666666\right), 1\right)\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 (<= (pow (sin kx) 2.0) 2e-5)
             (*
              (sin th)
              (/
               (sin ky)
               (hypot
                (sin ky)
                (*
                 kx
                 (fma
                  (* kx kx)
                  (fma 0.008333333333333333 (* kx kx) -0.16666666666666666)
                  1.0)))))
             (*
              (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 (pow(sin(kx), 2.0) <= 2e-5) {
          		tmp = sin(th) * (sin(ky) / hypot(sin(ky), (kx * fma((kx * kx), fma(0.008333333333333333, (kx * kx), -0.16666666666666666), 1.0))));
          	} 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 ((sin(kx) ^ 2.0) <= 2e-5)
          		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), Float64(kx * fma(Float64(kx * kx), fma(0.008333333333333333, Float64(kx * kx), -0.16666666666666666), 1.0)))));
          	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[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 2e-5], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(kx * N[(N[(kx * kx), $MachinePrecision] * N[(0.008333333333333333 * N[(kx * kx), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $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}\;{\sin kx}^{2} \leq 2 \cdot 10^{-5}:\\
          \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, kx \cdot kx, -0.16666666666666666\right), 1\right)\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 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 2.00000000000000016e-5

            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. +-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 kx around 0

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + {kx}^{2} \cdot \left(\frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}\right)\right)}\right)} \cdot \sin th \]
              2. +-commutativeN/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}, 1\right)}\right)} \cdot \sin th \]
              4. unpow2N/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{1}{120} \cdot {kx}^{2} - \frac{1}{6}, 1\right)\right)} \cdot \sin th \]
              6. sub-negN/A

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\frac{1}{120} \cdot {kx}^{2} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, 1\right)\right)} \cdot \sin th \]
              7. metadata-evalN/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\mathsf{fma}\left(\frac{1}{120}, {kx}^{2}, \frac{-1}{6}\right)}, 1\right)\right)} \cdot \sin th \]
              9. unpow2N/A

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, \color{blue}{kx \cdot kx}, -0.16666666666666666\right), 1\right)\right)} \cdot \sin th \]
            7. Simplified99.8%

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

            if 2.00000000000000016e-5 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

            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. 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.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-rr99.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 \]
          3. Recombined 2 regimes into one program.
          4. Final simplification99.5%

            \[\leadsto \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(0.008333333333333333, kx \cdot kx, -0.16666666666666666\right), 1\right)\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} \]
          5. Add Preprocessing

          Alternative 9: 52.4% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-170}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{elif}\;\sin ky \leq 10^{-7}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
          (FPCore (kx ky th)
           :precision binary64
           (if (<= (sin ky) -0.02)
             (* (* (sin ky) th) (sqrt (/ 2.0 (- 1.0 (cos (* ky -2.0))))))
             (if (<= (sin ky) 2e-170)
               (* (sin th) (/ (sin ky) (sin kx)))
               (if (<= (sin ky) 1e-7)
                 (/
                  (sin th)
                  (/
                   (sqrt
                    (fma
                     (*
                      (* ky ky)
                      (fma
                       (* ky ky)
                       (fma
                        (* ky ky)
                        (fma (* ky ky) -0.006349206349206349 0.08888888888888889)
                        -0.6666666666666666)
                       2.0))
                     0.5
                     (+ 0.5 (* -0.5 (cos (+ kx kx))))))
                   (* ky (fma (* ky ky) -0.16666666666666666 1.0))))
                 (sin th)))))
          double code(double kx, double ky, double th) {
          	double tmp;
          	if (sin(ky) <= -0.02) {
          		tmp = (sin(ky) * th) * sqrt((2.0 / (1.0 - cos((ky * -2.0)))));
          	} else if (sin(ky) <= 2e-170) {
          		tmp = sin(th) * (sin(ky) / sin(kx));
          	} else if (sin(ky) <= 1e-7) {
          		tmp = sin(th) / (sqrt(fma(((ky * ky) * fma((ky * ky), fma((ky * ky), fma((ky * ky), -0.006349206349206349, 0.08888888888888889), -0.6666666666666666), 2.0)), 0.5, (0.5 + (-0.5 * cos((kx + kx)))))) / (ky * fma((ky * ky), -0.16666666666666666, 1.0)));
          	} else {
          		tmp = sin(th);
          	}
          	return tmp;
          }
          
          function code(kx, ky, th)
          	tmp = 0.0
          	if (sin(ky) <= -0.02)
          		tmp = Float64(Float64(sin(ky) * th) * sqrt(Float64(2.0 / Float64(1.0 - cos(Float64(ky * -2.0))))));
          	elseif (sin(ky) <= 2e-170)
          		tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx)));
          	elseif (sin(ky) <= 1e-7)
          		tmp = Float64(sin(th) / Float64(sqrt(fma(Float64(Float64(ky * ky) * fma(Float64(ky * ky), fma(Float64(ky * ky), fma(Float64(ky * ky), -0.006349206349206349, 0.08888888888888889), -0.6666666666666666), 2.0)), 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx)))))) / Float64(ky * fma(Float64(ky * ky), -0.16666666666666666, 1.0))));
          	else
          		tmp = sin(th);
          	end
          	return tmp
          end
          
          code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-170], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-7], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * -0.006349206349206349 + 0.08888888888888889), $MachinePrecision] + -0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(ky * N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\sin ky \leq -0.02:\\
          \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\
          
          \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-170}:\\
          \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
          
          \mathbf{elif}\;\sin ky \leq 10^{-7}:\\
          \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right)}}\\
          
          \mathbf{else}:\\
          \;\;\;\;\sin th\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 4 regimes
          2. if (sin.f64 ky) < -0.0200000000000000004

            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. *-commutativeN/A

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

                \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -0.0200000000000000004 < (sin.f64 ky) < 1.99999999999999997e-170

            1. Initial program 82.9%

              \[\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.f6443.6

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

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

            if 1.99999999999999997e-170 < (sin.f64 ky) < 9.9999999999999995e-8

            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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
              2. clear-numN/A

                \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{\sin ky}} \]
            7. Simplified93.4%

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

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

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

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

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

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

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

                \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.16666666666666666, 1\right)}} \]
            10. Simplified93.4%

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

            if 9.9999999999999995e-8 < (sin.f64 ky)

            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.f6458.4

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

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

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

          Alternative 10: 52.4% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-170}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{elif}\;\sin ky \leq 10^{-7}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
          (FPCore (kx ky th)
           :precision binary64
           (if (<= (sin ky) -0.02)
             (* (* (sin ky) th) (sqrt (/ 2.0 (- 1.0 (cos (* ky -2.0))))))
             (if (<= (sin ky) 2e-170)
               (* (sin th) (/ ky (sin kx)))
               (if (<= (sin ky) 1e-7)
                 (/
                  (sin th)
                  (/
                   (sqrt
                    (fma
                     (*
                      (* ky ky)
                      (fma
                       (* ky ky)
                       (fma
                        (* ky ky)
                        (fma (* ky ky) -0.006349206349206349 0.08888888888888889)
                        -0.6666666666666666)
                       2.0))
                     0.5
                     (+ 0.5 (* -0.5 (cos (+ kx kx))))))
                   (* ky (fma (* ky ky) -0.16666666666666666 1.0))))
                 (sin th)))))
          double code(double kx, double ky, double th) {
          	double tmp;
          	if (sin(ky) <= -0.02) {
          		tmp = (sin(ky) * th) * sqrt((2.0 / (1.0 - cos((ky * -2.0)))));
          	} else if (sin(ky) <= 2e-170) {
          		tmp = sin(th) * (ky / sin(kx));
          	} else if (sin(ky) <= 1e-7) {
          		tmp = sin(th) / (sqrt(fma(((ky * ky) * fma((ky * ky), fma((ky * ky), fma((ky * ky), -0.006349206349206349, 0.08888888888888889), -0.6666666666666666), 2.0)), 0.5, (0.5 + (-0.5 * cos((kx + kx)))))) / (ky * fma((ky * ky), -0.16666666666666666, 1.0)));
          	} else {
          		tmp = sin(th);
          	}
          	return tmp;
          }
          
          function code(kx, ky, th)
          	tmp = 0.0
          	if (sin(ky) <= -0.02)
          		tmp = Float64(Float64(sin(ky) * th) * sqrt(Float64(2.0 / Float64(1.0 - cos(Float64(ky * -2.0))))));
          	elseif (sin(ky) <= 2e-170)
          		tmp = Float64(sin(th) * Float64(ky / sin(kx)));
          	elseif (sin(ky) <= 1e-7)
          		tmp = Float64(sin(th) / Float64(sqrt(fma(Float64(Float64(ky * ky) * fma(Float64(ky * ky), fma(Float64(ky * ky), fma(Float64(ky * ky), -0.006349206349206349, 0.08888888888888889), -0.6666666666666666), 2.0)), 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx)))))) / Float64(ky * fma(Float64(ky * ky), -0.16666666666666666, 1.0))));
          	else
          		tmp = sin(th);
          	end
          	return tmp
          end
          
          code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-170], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-7], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * -0.006349206349206349 + 0.08888888888888889), $MachinePrecision] + -0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(ky * N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\sin ky \leq -0.02:\\
          \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\
          
          \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-170}:\\
          \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
          
          \mathbf{elif}\;\sin ky \leq 10^{-7}:\\
          \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right)}}\\
          
          \mathbf{else}:\\
          \;\;\;\;\sin th\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 4 regimes
          2. if (sin.f64 ky) < -0.0200000000000000004

            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. *-commutativeN/A

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

                \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -0.0200000000000000004 < (sin.f64 ky) < 1.99999999999999997e-170

            1. Initial program 82.9%

              \[\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.f6443.5

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

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

            if 1.99999999999999997e-170 < (sin.f64 ky) < 9.9999999999999995e-8

            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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
              2. clear-numN/A

                \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{\sin ky}} \]
            7. Simplified93.4%

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

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

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

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

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

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

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

                \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.16666666666666666, 1\right)}} \]
            10. Simplified93.4%

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

            if 9.9999999999999995e-8 < (sin.f64 ky)

            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.f6458.4

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

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

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

          Alternative 11: 52.4% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-170}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{elif}\;\sin ky \leq 10^{-7}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
          (FPCore (kx ky th)
           :precision binary64
           (if (<= (sin ky) -0.02)
             (* (* (sin ky) th) (sqrt (/ 2.0 (- 1.0 (cos (* ky -2.0))))))
             (if (<= (sin ky) 2e-170)
               (* (sin th) (/ ky (sin kx)))
               (if (<= (sin ky) 1e-7)
                 (/
                  (sin th)
                  (/
                   (sqrt
                    (fma
                     (*
                      (* ky ky)
                      (fma
                       (* ky ky)
                       (fma
                        (* ky ky)
                        (fma (* ky ky) -0.006349206349206349 0.08888888888888889)
                        -0.6666666666666666)
                       2.0))
                     0.5
                     (+ 0.5 (* -0.5 (cos (+ kx kx))))))
                   ky))
                 (sin th)))))
          double code(double kx, double ky, double th) {
          	double tmp;
          	if (sin(ky) <= -0.02) {
          		tmp = (sin(ky) * th) * sqrt((2.0 / (1.0 - cos((ky * -2.0)))));
          	} else if (sin(ky) <= 2e-170) {
          		tmp = sin(th) * (ky / sin(kx));
          	} else if (sin(ky) <= 1e-7) {
          		tmp = sin(th) / (sqrt(fma(((ky * ky) * fma((ky * ky), fma((ky * ky), fma((ky * ky), -0.006349206349206349, 0.08888888888888889), -0.6666666666666666), 2.0)), 0.5, (0.5 + (-0.5 * cos((kx + kx)))))) / ky);
          	} else {
          		tmp = sin(th);
          	}
          	return tmp;
          }
          
          function code(kx, ky, th)
          	tmp = 0.0
          	if (sin(ky) <= -0.02)
          		tmp = Float64(Float64(sin(ky) * th) * sqrt(Float64(2.0 / Float64(1.0 - cos(Float64(ky * -2.0))))));
          	elseif (sin(ky) <= 2e-170)
          		tmp = Float64(sin(th) * Float64(ky / sin(kx)));
          	elseif (sin(ky) <= 1e-7)
          		tmp = Float64(sin(th) / Float64(sqrt(fma(Float64(Float64(ky * ky) * fma(Float64(ky * ky), fma(Float64(ky * ky), fma(Float64(ky * ky), -0.006349206349206349, 0.08888888888888889), -0.6666666666666666), 2.0)), 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx)))))) / ky));
          	else
          		tmp = sin(th);
          	end
          	return tmp
          end
          
          code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-170], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-7], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * -0.006349206349206349 + 0.08888888888888889), $MachinePrecision] + -0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\sin ky \leq -0.02:\\
          \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\
          
          \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-170}:\\
          \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
          
          \mathbf{elif}\;\sin ky \leq 10^{-7}:\\
          \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky}}\\
          
          \mathbf{else}:\\
          \;\;\;\;\sin th\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 4 regimes
          2. if (sin.f64 ky) < -0.0200000000000000004

            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. *-commutativeN/A

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

                \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -0.0200000000000000004 < (sin.f64 ky) < 1.99999999999999997e-170

            1. Initial program 82.9%

              \[\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.f6443.5

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

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

            if 1.99999999999999997e-170 < (sin.f64 ky) < 9.9999999999999995e-8

            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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
              2. clear-numN/A

                \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{\sin ky}} \]
            7. Simplified93.4%

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

              \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \frac{-2}{315}, \frac{4}{45}\right), \frac{-2}{3}\right), 2\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}}{\color{blue}{ky}}} \]
            9. Step-by-step derivation
              1. Simplified93.4%

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

              if 9.9999999999999995e-8 < (sin.f64 ky)

              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.f6458.4

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

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-170}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{elif}\;\sin ky \leq 10^{-7}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
            12. Add Preprocessing

            Alternative 12: 46.3% accurate, 1.5× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-184}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
            (FPCore (kx ky th)
             :precision binary64
             (if (<= (sin ky) -0.02)
               (* (* (sin ky) th) (sqrt (/ 2.0 (- 1.0 (cos (* ky -2.0))))))
               (if (<= (sin ky) 5e-184) (* (sin th) (/ ky (sin kx))) (sin th))))
            double code(double kx, double ky, double th) {
            	double tmp;
            	if (sin(ky) <= -0.02) {
            		tmp = (sin(ky) * th) * sqrt((2.0 / (1.0 - cos((ky * -2.0)))));
            	} else if (sin(ky) <= 5e-184) {
            		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) <= (-0.02d0)) then
                    tmp = (sin(ky) * th) * sqrt((2.0d0 / (1.0d0 - cos((ky * (-2.0d0))))))
                else if (sin(ky) <= 5d-184) 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) <= -0.02) {
            		tmp = (Math.sin(ky) * th) * Math.sqrt((2.0 / (1.0 - Math.cos((ky * -2.0)))));
            	} else if (Math.sin(ky) <= 5e-184) {
            		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) <= -0.02:
            		tmp = (math.sin(ky) * th) * math.sqrt((2.0 / (1.0 - math.cos((ky * -2.0)))))
            	elif math.sin(ky) <= 5e-184:
            		tmp = math.sin(th) * (ky / math.sin(kx))
            	else:
            		tmp = math.sin(th)
            	return tmp
            
            function code(kx, ky, th)
            	tmp = 0.0
            	if (sin(ky) <= -0.02)
            		tmp = Float64(Float64(sin(ky) * th) * sqrt(Float64(2.0 / Float64(1.0 - cos(Float64(ky * -2.0))))));
            	elseif (sin(ky) <= 5e-184)
            		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) <= -0.02)
            		tmp = (sin(ky) * th) * sqrt((2.0 / (1.0 - cos((ky * -2.0)))));
            	elseif (sin(ky) <= 5e-184)
            		tmp = sin(th) * (ky / sin(kx));
            	else
            		tmp = sin(th);
            	end
            	tmp_2 = tmp;
            end
            
            code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-184], 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}\;\sin ky \leq -0.02:\\
            \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\
            
            \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-184}:\\
            \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
            
            \mathbf{else}:\\
            \;\;\;\;\sin th\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if (sin.f64 ky) < -0.0200000000000000004

              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. *-commutativeN/A

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

                  \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if -0.0200000000000000004 < (sin.f64 ky) < 5.00000000000000003e-184

              1. Initial program 84.1%

                \[\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.f6444.1

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

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

              if 5.00000000000000003e-184 < (sin.f64 ky)

              1. Initial program 97.4%

                \[\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.f6455.1

                  \[\leadsto \color{blue}{\sin th} \]
              5. Simplified55.1%

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(ky \cdot -2\right)}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-184}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
            5. Add Preprocessing

            Alternative 13: 69.2% accurate, 1.5× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 1.12:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}{\sin ky}}\\ \end{array} \end{array} \]
            (FPCore (kx ky th)
             :precision binary64
             (if (<= kx 1.12)
               (* (sin th) (/ (sin ky) (hypot (sin ky) kx)))
               (/ (sin th) (/ (sqrt (fma -0.5 (cos (* kx -2.0)) 0.5)) (sin ky)))))
            double code(double kx, double ky, double th) {
            	double tmp;
            	if (kx <= 1.12) {
            		tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
            	} else {
            		tmp = sin(th) / (sqrt(fma(-0.5, cos((kx * -2.0)), 0.5)) / sin(ky));
            	}
            	return tmp;
            }
            
            function code(kx, ky, th)
            	tmp = 0.0
            	if (kx <= 1.12)
            		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx)));
            	else
            		tmp = Float64(sin(th) / Float64(sqrt(fma(-0.5, cos(Float64(kx * -2.0)), 0.5)) / sin(ky)));
            	end
            	return tmp
            end
            
            code[kx_, ky_, th_] := If[LessEqual[kx, 1.12], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;kx \leq 1.12:\\
            \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}{\sin ky}}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if kx < 1.1200000000000001

              1. Initial program 90.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.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 kx around 0

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

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

                if 1.1200000000000001 < kx

                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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                  2. clear-numN/A

                    \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                  3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}}{\sin ky}} \]
              7. Recombined 2 regimes into one program.
              8. Final simplification68.7%

                \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 1.12:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}{\sin ky}}\\ \end{array} \]
              9. Add Preprocessing

              Alternative 14: 65.2% accurate, 1.5× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 0.4:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}{\sin ky}}\\ \end{array} \end{array} \]
              (FPCore (kx ky th)
               :precision binary64
               (if (<= ky 0.4)
                 (* (sin th) (/ (sin ky) (hypot ky (sin kx))))
                 (/ (sin th) (/ (sqrt (* 0.5 (- 1.0 (cos (* ky -2.0))))) (sin ky)))))
              double code(double kx, double ky, double th) {
              	double tmp;
              	if (ky <= 0.4) {
              		tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
              	} else {
              		tmp = sin(th) / (sqrt((0.5 * (1.0 - cos((ky * -2.0))))) / sin(ky));
              	}
              	return tmp;
              }
              
              public static double code(double kx, double ky, double th) {
              	double tmp;
              	if (ky <= 0.4) {
              		tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(ky, Math.sin(kx)));
              	} else {
              		tmp = Math.sin(th) / (Math.sqrt((0.5 * (1.0 - Math.cos((ky * -2.0))))) / Math.sin(ky));
              	}
              	return tmp;
              }
              
              def code(kx, ky, th):
              	tmp = 0
              	if ky <= 0.4:
              		tmp = math.sin(th) * (math.sin(ky) / math.hypot(ky, math.sin(kx)))
              	else:
              		tmp = math.sin(th) / (math.sqrt((0.5 * (1.0 - math.cos((ky * -2.0))))) / math.sin(ky))
              	return tmp
              
              function code(kx, ky, th)
              	tmp = 0.0
              	if (ky <= 0.4)
              		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx))));
              	else
              		tmp = Float64(sin(th) / Float64(sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(ky * -2.0))))) / sin(ky)));
              	end
              	return tmp
              end
              
              function tmp_2 = code(kx, ky, th)
              	tmp = 0.0;
              	if (ky <= 0.4)
              		tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
              	else
              		tmp = sin(th) / (sqrt((0.5 * (1.0 - cos((ky * -2.0))))) / sin(ky));
              	end
              	tmp_2 = tmp;
              end
              
              code[kx_, ky_, th_] := If[LessEqual[ky, 0.4], 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[Sqrt[N[(0.5 * N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;ky \leq 0.4:\\
              \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{\sin th}{\frac{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}{\sin ky}}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if ky < 0.40000000000000002

                1. Initial program 90.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.6

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

                  \[\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. Simplified68.0%

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

                  if 0.40000000000000002 < ky

                  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. *-commutativeN/A

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

                      \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                    3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}}{\sin ky}} \]
                7. Recombined 2 regimes into one program.
                8. Final simplification63.8%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 0.4:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}{\sin ky}}\\ \end{array} \]
                9. Add Preprocessing

                Alternative 15: 45.2% accurate, 1.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 1.92 \cdot 10^{-168}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{elif}\;ky \leq 0.44:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}{\sin ky}}\\ \end{array} \end{array} \]
                (FPCore (kx ky th)
                 :precision binary64
                 (if (<= ky 1.92e-168)
                   (* (sin th) (/ ky (sin kx)))
                   (if (<= ky 0.44)
                     (/
                      (sin th)
                      (/
                       (sqrt
                        (fma
                         (*
                          (* ky ky)
                          (fma
                           (* ky ky)
                           (fma
                            (* ky ky)
                            (fma (* ky ky) -0.006349206349206349 0.08888888888888889)
                            -0.6666666666666666)
                           2.0))
                         0.5
                         (+ 0.5 (* -0.5 (cos (+ kx kx))))))
                       (*
                        ky
                        (fma
                         (* ky ky)
                         (fma
                          (* ky ky)
                          (fma (* ky ky) -0.0001984126984126984 0.008333333333333333)
                          -0.16666666666666666)
                         1.0))))
                     (/ (sin th) (/ (sqrt (* 0.5 (- 1.0 (cos (* ky -2.0))))) (sin ky))))))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (ky <= 1.92e-168) {
                		tmp = sin(th) * (ky / sin(kx));
                	} else if (ky <= 0.44) {
                		tmp = sin(th) / (sqrt(fma(((ky * ky) * fma((ky * ky), fma((ky * ky), fma((ky * ky), -0.006349206349206349, 0.08888888888888889), -0.6666666666666666), 2.0)), 0.5, (0.5 + (-0.5 * cos((kx + kx)))))) / (ky * fma((ky * ky), fma((ky * ky), fma((ky * ky), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666), 1.0)));
                	} else {
                		tmp = sin(th) / (sqrt((0.5 * (1.0 - cos((ky * -2.0))))) / sin(ky));
                	}
                	return tmp;
                }
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (ky <= 1.92e-168)
                		tmp = Float64(sin(th) * Float64(ky / sin(kx)));
                	elseif (ky <= 0.44)
                		tmp = Float64(sin(th) / Float64(sqrt(fma(Float64(Float64(ky * ky) * fma(Float64(ky * ky), fma(Float64(ky * ky), fma(Float64(ky * ky), -0.006349206349206349, 0.08888888888888889), -0.6666666666666666), 2.0)), 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(kx + kx)))))) / Float64(ky * fma(Float64(ky * ky), fma(Float64(ky * ky), fma(Float64(ky * ky), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666), 1.0))));
                	else
                		tmp = Float64(sin(th) / Float64(sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(ky * -2.0))))) / sin(ky)));
                	end
                	return tmp
                end
                
                code[kx_, ky_, th_] := If[LessEqual[ky, 1.92e-168], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 0.44], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * -0.006349206349206349 + 0.08888888888888889), $MachinePrecision] + -0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(ky * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * N[(N[(ky * ky), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(0.5 * N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;ky \leq 1.92 \cdot 10^{-168}:\\
                \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
                
                \mathbf{elif}\;ky \leq 0.44:\\
                \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}}\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{\sin th}{\frac{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}{\sin ky}}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if ky < 1.92000000000000009e-168

                  1. Initial program 89.2%

                    \[\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.f6428.1

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

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

                  if 1.92000000000000009e-168 < ky < 0.440000000000000002

                  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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                    2. clear-numN/A

                      \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                    3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{\sin ky}} \]
                  7. Simplified93.4%

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

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

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

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

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

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

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

                      \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \frac{-2}{315}, \frac{4}{45}\right), \frac{-2}{3}\right), 2\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(ky \cdot ky, \color{blue}{{ky}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {ky}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, 1\right)}} \]
                    7. metadata-evalN/A

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

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

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

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

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

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

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

                      \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \frac{-2}{315}, \frac{4}{45}\right), \frac{-2}{3}\right), 2\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(\color{blue}{ky \cdot ky}, \frac{-1}{5040}, \frac{1}{120}\right), \frac{-1}{6}\right), 1\right)}} \]
                    15. *-lowering-*.f6493.4

                      \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}} \]
                  10. Simplified93.4%

                    \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{\color{blue}{ky \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}}} \]

                  if 0.440000000000000002 < ky

                  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. *-commutativeN/A

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

                      \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                    3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}}{\sin ky}} \]
                3. Recombined 3 regimes into one program.
                4. Final simplification39.3%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 1.92 \cdot 10^{-168}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{elif}\;ky \leq 0.44:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{ky \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}{\sin ky}}\\ \end{array} \]
                5. Add Preprocessing

                Alternative 16: 34.3% accurate, 2.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-184}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                (FPCore (kx ky th)
                 :precision binary64
                 (if (<= (sin ky) 5e-184) (* (sin ky) (/ (sin th) kx)) (sin th)))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (sin(ky) <= 5e-184) {
                		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) <= 5d-184) 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) <= 5e-184) {
                		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) <= 5e-184:
                		tmp = math.sin(ky) * (math.sin(th) / kx)
                	else:
                		tmp = math.sin(th)
                	return tmp
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (sin(ky) <= 5e-184)
                		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) <= 5e-184)
                		tmp = sin(ky) * (sin(th) / kx);
                	else
                		tmp = sin(th);
                	end
                	tmp_2 = tmp;
                end
                
                code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-184], 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}\;\sin ky \leq 5 \cdot 10^{-184}:\\
                \;\;\;\;\sin ky \cdot \frac{\sin th}{kx}\\
                
                \mathbf{else}:\\
                \;\;\;\;\sin th\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (sin.f64 ky) < 5.00000000000000003e-184

                  1. Initial program 90.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.6

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

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

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

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

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

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

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

                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)\right)} \cdot \sin th \]
                  7. Simplified60.4%

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

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

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

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

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

                      \[\leadsto \frac{\sin ky}{kx \cdot \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{kx \cdot kx}, 1\right)} \cdot \sin th \]
                    5. *-lowering-*.f6418.3

                      \[\leadsto \frac{\sin ky}{kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)} \cdot \sin th \]
                  10. Simplified18.3%

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

                    \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{kx}} \]
                  12. 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.f6418.4

                      \[\leadsto \sin ky \cdot \frac{\color{blue}{\sin th}}{kx} \]
                  13. Simplified18.4%

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

                  if 5.00000000000000003e-184 < (sin.f64 ky)

                  1. Initial program 97.4%

                    \[\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.f6455.1

                      \[\leadsto \color{blue}{\sin th} \]
                  5. Simplified55.1%

                    \[\leadsto \color{blue}{\sin th} \]
                3. Recombined 2 regimes into one program.
                4. Add Preprocessing

                Alternative 17: 35.0% accurate, 2.4× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 2.2 \cdot 10^{-45}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;kx \leq 1.12:\\ \;\;\;\;\frac{\left(\sin ky \cdot \sin th\right) \cdot \mathsf{fma}\left(0.16666666666666666, kx \cdot kx, 1\right)}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \left(\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(ky \cdot \sqrt{2}\right)\right)\\ \end{array} \end{array} \]
                (FPCore (kx ky th)
                 :precision binary64
                 (if (<= kx 2.2e-45)
                   (sin th)
                   (if (<= kx 1.12)
                     (/ (* (* (sin ky) (sin th)) (fma 0.16666666666666666 (* kx kx) 1.0)) kx)
                     (*
                      (sin th)
                      (* (sqrt (/ 1.0 (- 1.0 (cos (* kx -2.0))))) (* ky (sqrt 2.0)))))))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (kx <= 2.2e-45) {
                		tmp = sin(th);
                	} else if (kx <= 1.12) {
                		tmp = ((sin(ky) * sin(th)) * fma(0.16666666666666666, (kx * kx), 1.0)) / kx;
                	} else {
                		tmp = sin(th) * (sqrt((1.0 / (1.0 - cos((kx * -2.0))))) * (ky * sqrt(2.0)));
                	}
                	return tmp;
                }
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (kx <= 2.2e-45)
                		tmp = sin(th);
                	elseif (kx <= 1.12)
                		tmp = Float64(Float64(Float64(sin(ky) * sin(th)) * fma(0.16666666666666666, Float64(kx * kx), 1.0)) / kx);
                	else
                		tmp = Float64(sin(th) * Float64(sqrt(Float64(1.0 / Float64(1.0 - cos(Float64(kx * -2.0))))) * Float64(ky * sqrt(2.0))));
                	end
                	return tmp
                end
                
                code[kx_, ky_, th_] := If[LessEqual[kx, 2.2e-45], N[Sin[th], $MachinePrecision], If[LessEqual[kx, 1.12], N[(N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / kx), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sqrt[N[(1.0 / N[(1.0 - N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(ky * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;kx \leq 2.2 \cdot 10^{-45}:\\
                \;\;\;\;\sin th\\
                
                \mathbf{elif}\;kx \leq 1.12:\\
                \;\;\;\;\frac{\left(\sin ky \cdot \sin th\right) \cdot \mathsf{fma}\left(0.16666666666666666, kx \cdot kx, 1\right)}{kx}\\
                
                \mathbf{else}:\\
                \;\;\;\;\sin th \cdot \left(\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(ky \cdot \sqrt{2}\right)\right)\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if kx < 2.19999999999999993e-45

                  1. Initial program 90.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.f6426.3

                      \[\leadsto \color{blue}{\sin th} \]
                  5. Simplified26.3%

                    \[\leadsto \color{blue}{\sin th} \]

                  if 2.19999999999999993e-45 < kx < 1.1200000000000001

                  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.3

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

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

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

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

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

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

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

                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)\right)} \cdot \sin th \]
                  7. Simplified85.4%

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

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

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

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

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

                      \[\leadsto \frac{\sin ky}{kx \cdot \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{kx \cdot kx}, 1\right)} \cdot \sin th \]
                    5. *-lowering-*.f6451.9

                      \[\leadsto \frac{\sin ky}{kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)} \cdot \sin th \]
                  10. Simplified51.9%

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

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

                      \[\leadsto \color{blue}{\frac{\frac{1}{6} \cdot \left({kx}^{2} \cdot \left(\sin ky \cdot \sin th\right)\right) + \sin ky \cdot \sin th}{kx}} \]
                    2. associate-*r*N/A

                      \[\leadsto \frac{\color{blue}{\left(\frac{1}{6} \cdot {kx}^{2}\right) \cdot \left(\sin ky \cdot \sin th\right)} + \sin ky \cdot \sin th}{kx} \]
                    3. distribute-lft1-inN/A

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{\mathsf{fma}\left(0.16666666666666666, kx \cdot kx, 1\right) \cdot \left(\sin th \cdot \color{blue}{\sin ky}\right)}{kx} \]
                  13. Simplified52.1%

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

                  if 1.1200000000000001 < kx

                  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. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(ky \cdot \sqrt{2}\right)\right)} \cdot \sin th \]
                3. Recombined 3 regimes into one program.
                4. Final simplification33.1%

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

                Alternative 18: 35.1% accurate, 2.5× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 2.25 \cdot 10^{-45}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;kx \leq 1.12:\\ \;\;\;\;\frac{\left(\sin ky \cdot \sin th\right) \cdot \mathsf{fma}\left(0.16666666666666666, kx \cdot kx, 1\right)}{kx}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\cos \left(kx \cdot -2\right), -0.5, 0.5\right)}}{ky}}\\ \end{array} \end{array} \]
                (FPCore (kx ky th)
                 :precision binary64
                 (if (<= kx 2.25e-45)
                   (sin th)
                   (if (<= kx 1.12)
                     (/ (* (* (sin ky) (sin th)) (fma 0.16666666666666666 (* kx kx) 1.0)) kx)
                     (/ (sin th) (/ (sqrt (fma (cos (* kx -2.0)) -0.5 0.5)) ky)))))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (kx <= 2.25e-45) {
                		tmp = sin(th);
                	} else if (kx <= 1.12) {
                		tmp = ((sin(ky) * sin(th)) * fma(0.16666666666666666, (kx * kx), 1.0)) / kx;
                	} else {
                		tmp = sin(th) / (sqrt(fma(cos((kx * -2.0)), -0.5, 0.5)) / ky);
                	}
                	return tmp;
                }
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (kx <= 2.25e-45)
                		tmp = sin(th);
                	elseif (kx <= 1.12)
                		tmp = Float64(Float64(Float64(sin(ky) * sin(th)) * fma(0.16666666666666666, Float64(kx * kx), 1.0)) / kx);
                	else
                		tmp = Float64(sin(th) / Float64(sqrt(fma(cos(Float64(kx * -2.0)), -0.5, 0.5)) / ky));
                	end
                	return tmp
                end
                
                code[kx_, ky_, th_] := If[LessEqual[kx, 2.25e-45], N[Sin[th], $MachinePrecision], If[LessEqual[kx, 1.12], N[(N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / kx), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[(N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;kx \leq 2.25 \cdot 10^{-45}:\\
                \;\;\;\;\sin th\\
                
                \mathbf{elif}\;kx \leq 1.12:\\
                \;\;\;\;\frac{\left(\sin ky \cdot \sin th\right) \cdot \mathsf{fma}\left(0.16666666666666666, kx \cdot kx, 1\right)}{kx}\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\cos \left(kx \cdot -2\right), -0.5, 0.5\right)}}{ky}}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if kx < 2.2499999999999999e-45

                  1. Initial program 90.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.f6426.3

                      \[\leadsto \color{blue}{\sin th} \]
                  5. Simplified26.3%

                    \[\leadsto \color{blue}{\sin th} \]

                  if 2.2499999999999999e-45 < kx < 1.1200000000000001

                  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.3

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

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

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

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

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

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

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

                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)\right)} \cdot \sin th \]
                  7. Simplified85.4%

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

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

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

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

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

                      \[\leadsto \frac{\sin ky}{kx \cdot \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{kx \cdot kx}, 1\right)} \cdot \sin th \]
                    5. *-lowering-*.f6451.9

                      \[\leadsto \frac{\sin ky}{kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)} \cdot \sin th \]
                  10. Simplified51.9%

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

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

                      \[\leadsto \color{blue}{\frac{\frac{1}{6} \cdot \left({kx}^{2} \cdot \left(\sin ky \cdot \sin th\right)\right) + \sin ky \cdot \sin th}{kx}} \]
                    2. associate-*r*N/A

                      \[\leadsto \frac{\color{blue}{\left(\frac{1}{6} \cdot {kx}^{2}\right) \cdot \left(\sin ky \cdot \sin th\right)} + \sin ky \cdot \sin th}{kx} \]
                    3. distribute-lft1-inN/A

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{\mathsf{fma}\left(0.16666666666666666, kx \cdot kx, 1\right) \cdot \left(\sin th \cdot \color{blue}{\sin ky}\right)}{kx} \]
                  13. Simplified52.1%

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

                  if 1.1200000000000001 < kx

                  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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                    2. clear-numN/A

                      \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                    3. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(\left(ky \cdot ky\right) \cdot \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(ky \cdot ky, \mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.006349206349206349, 0.08888888888888889\right), -0.6666666666666666\right), 2\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{\sin ky}} \]
                  7. Simplified50.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(\cos \left(kx \cdot -2\right), -0.5, 0.5\right)}}{ky}}} \]
                3. Recombined 3 regimes into one program.
                4. Final simplification33.1%

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

                Alternative 19: 35.1% accurate, 2.5× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 2 \cdot 10^{-45}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;kx \leq 1.12:\\ \;\;\;\;\frac{\left(\sin ky \cdot \sin th\right) \cdot \mathsf{fma}\left(0.16666666666666666, kx \cdot kx, 1\right)}{kx}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \end{array} \]
                (FPCore (kx ky th)
                 :precision binary64
                 (if (<= kx 2e-45)
                   (sin th)
                   (if (<= kx 1.12)
                     (/ (* (* (sin ky) (sin th)) (fma 0.16666666666666666 (* kx kx) 1.0)) kx)
                     (* (* ky (sin th)) (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5)))))))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (kx <= 2e-45) {
                		tmp = sin(th);
                	} else if (kx <= 1.12) {
                		tmp = ((sin(ky) * sin(th)) * fma(0.16666666666666666, (kx * kx), 1.0)) / kx;
                	} else {
                		tmp = (ky * sin(th)) * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5)));
                	}
                	return tmp;
                }
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (kx <= 2e-45)
                		tmp = sin(th);
                	elseif (kx <= 1.12)
                		tmp = Float64(Float64(Float64(sin(ky) * sin(th)) * fma(0.16666666666666666, Float64(kx * kx), 1.0)) / kx);
                	else
                		tmp = Float64(Float64(ky * sin(th)) * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
                	end
                	return tmp
                end
                
                code[kx_, ky_, th_] := If[LessEqual[kx, 2e-45], N[Sin[th], $MachinePrecision], If[LessEqual[kx, 1.12], N[(N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / kx), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;kx \leq 2 \cdot 10^{-45}:\\
                \;\;\;\;\sin th\\
                
                \mathbf{elif}\;kx \leq 1.12:\\
                \;\;\;\;\frac{\left(\sin ky \cdot \sin th\right) \cdot \mathsf{fma}\left(0.16666666666666666, kx \cdot kx, 1\right)}{kx}\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if kx < 1.99999999999999997e-45

                  1. Initial program 90.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.f6426.3

                      \[\leadsto \color{blue}{\sin th} \]
                  5. Simplified26.3%

                    \[\leadsto \color{blue}{\sin th} \]

                  if 1.99999999999999997e-45 < kx < 1.1200000000000001

                  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.3

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

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

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

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

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

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

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

                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)\right)} \cdot \sin th \]
                  7. Simplified85.4%

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

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

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

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

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

                      \[\leadsto \frac{\sin ky}{kx \cdot \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{kx \cdot kx}, 1\right)} \cdot \sin th \]
                    5. *-lowering-*.f6451.9

                      \[\leadsto \frac{\sin ky}{kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)} \cdot \sin th \]
                  10. Simplified51.9%

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

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

                      \[\leadsto \color{blue}{\frac{\frac{1}{6} \cdot \left({kx}^{2} \cdot \left(\sin ky \cdot \sin th\right)\right) + \sin ky \cdot \sin th}{kx}} \]
                    2. associate-*r*N/A

                      \[\leadsto \frac{\color{blue}{\left(\frac{1}{6} \cdot {kx}^{2}\right) \cdot \left(\sin ky \cdot \sin th\right)} + \sin ky \cdot \sin th}{kx} \]
                    3. distribute-lft1-inN/A

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{\mathsf{fma}\left(0.16666666666666666, kx \cdot kx, 1\right) \cdot \left(\sin th \cdot \color{blue}{\sin ky}\right)}{kx} \]
                  13. Simplified52.1%

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

                  if 1.1200000000000001 < kx

                  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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                    2. clear-numN/A

                      \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                    3. un-div-invN/A

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

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

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

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

                    \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}{\sin ky}}} \]
                  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-*.f6451.4

                      \[\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. Simplified51.4%

                    \[\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)}}} \]
                3. Recombined 3 regimes into one program.
                4. Final simplification33.1%

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

                Alternative 20: 34.1% accurate, 2.6× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-184}:\\ \;\;\;\;\sin th \cdot \frac{ky}{kx \cdot \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                (FPCore (kx ky th)
                 :precision binary64
                 (if (<= (sin ky) 5e-184)
                   (* (sin th) (/ ky (* kx (fma -0.16666666666666666 (* kx kx) 1.0))))
                   (sin th)))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (sin(ky) <= 5e-184) {
                		tmp = sin(th) * (ky / (kx * fma(-0.16666666666666666, (kx * kx), 1.0)));
                	} else {
                		tmp = sin(th);
                	}
                	return tmp;
                }
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (sin(ky) <= 5e-184)
                		tmp = Float64(sin(th) * Float64(ky / Float64(kx * fma(-0.16666666666666666, Float64(kx * kx), 1.0))));
                	else
                		tmp = sin(th);
                	end
                	return tmp
                end
                
                code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-184], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[(kx * N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-184}:\\
                \;\;\;\;\sin th \cdot \frac{ky}{kx \cdot \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right)}\\
                
                \mathbf{else}:\\
                \;\;\;\;\sin th\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (sin.f64 ky) < 5.00000000000000003e-184

                  1. Initial program 90.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.6

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

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

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

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

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

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

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

                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)\right)} \cdot \sin th \]
                  7. Simplified60.4%

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

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

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

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

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

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

                      \[\leadsto \frac{ky}{kx \cdot \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{kx \cdot kx}, 1\right)} \cdot \sin th \]
                    6. *-lowering-*.f6418.0

                      \[\leadsto \frac{ky}{kx \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right)} \cdot \sin th \]
                  10. Simplified18.0%

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

                  if 5.00000000000000003e-184 < (sin.f64 ky)

                  1. Initial program 97.4%

                    \[\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.f6455.1

                      \[\leadsto \color{blue}{\sin th} \]
                  5. Simplified55.1%

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

                  \[\leadsto \begin{array}{l} \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-184}:\\ \;\;\;\;\sin th \cdot \frac{ky}{kx \cdot \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                5. Add Preprocessing

                Alternative 21: 32.1% accurate, 2.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 1.05 \cdot 10^{-183}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                (FPCore (kx ky th)
                 :precision binary64
                 (if (<= ky 1.05e-183) (* (sin th) (/ ky (sin kx))) (sin th)))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (ky <= 1.05e-183) {
                		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 (ky <= 1.05d-183) 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 (ky <= 1.05e-183) {
                		tmp = Math.sin(th) * (ky / Math.sin(kx));
                	} else {
                		tmp = Math.sin(th);
                	}
                	return tmp;
                }
                
                def code(kx, ky, th):
                	tmp = 0
                	if ky <= 1.05e-183:
                		tmp = math.sin(th) * (ky / math.sin(kx))
                	else:
                		tmp = math.sin(th)
                	return tmp
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (ky <= 1.05e-183)
                		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 (ky <= 1.05e-183)
                		tmp = sin(th) * (ky / sin(kx));
                	else
                		tmp = sin(th);
                	end
                	tmp_2 = tmp;
                end
                
                code[kx_, ky_, th_] := If[LessEqual[ky, 1.05e-183], 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}\;ky \leq 1.05 \cdot 10^{-183}:\\
                \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
                
                \mathbf{else}:\\
                \;\;\;\;\sin th\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if ky < 1.0500000000000001e-183

                  1. Initial program 90.1%

                    \[\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.f6428.1

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

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

                  if 1.0500000000000001e-183 < ky

                  1. Initial program 97.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.f6432.3

                      \[\leadsto \color{blue}{\sin th} \]
                  5. Simplified32.3%

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

                  \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 1.05 \cdot 10^{-183}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                5. Add Preprocessing

                Alternative 22: 21.9% accurate, 4.6× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 8 \cdot 10^{-213}:\\ \;\;\;\;2 \cdot \frac{\sin th \cdot \left(ky \cdot ky\right)}{kx \cdot kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                (FPCore (kx ky th)
                 :precision binary64
                 (if (<= ky 8e-213) (* 2.0 (/ (* (sin th) (* ky ky)) (* kx kx))) (sin th)))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (ky <= 8e-213) {
                		tmp = 2.0 * ((sin(th) * (ky * ky)) / (kx * 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 (ky <= 8d-213) then
                        tmp = 2.0d0 * ((sin(th) * (ky * ky)) / (kx * kx))
                    else
                        tmp = sin(th)
                    end if
                    code = tmp
                end function
                
                public static double code(double kx, double ky, double th) {
                	double tmp;
                	if (ky <= 8e-213) {
                		tmp = 2.0 * ((Math.sin(th) * (ky * ky)) / (kx * kx));
                	} else {
                		tmp = Math.sin(th);
                	}
                	return tmp;
                }
                
                def code(kx, ky, th):
                	tmp = 0
                	if ky <= 8e-213:
                		tmp = 2.0 * ((math.sin(th) * (ky * ky)) / (kx * kx))
                	else:
                		tmp = math.sin(th)
                	return tmp
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (ky <= 8e-213)
                		tmp = Float64(2.0 * Float64(Float64(sin(th) * Float64(ky * ky)) / Float64(kx * kx)));
                	else
                		tmp = sin(th);
                	end
                	return tmp
                end
                
                function tmp_2 = code(kx, ky, th)
                	tmp = 0.0;
                	if (ky <= 8e-213)
                		tmp = 2.0 * ((sin(th) * (ky * ky)) / (kx * kx));
                	else
                		tmp = sin(th);
                	end
                	tmp_2 = tmp;
                end
                
                code[kx_, ky_, th_] := If[LessEqual[ky, 8e-213], N[(2.0 * N[(N[(N[Sin[th], $MachinePrecision] * N[(ky * ky), $MachinePrecision]), $MachinePrecision] / N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;ky \leq 8 \cdot 10^{-213}:\\
                \;\;\;\;2 \cdot \frac{\sin th \cdot \left(ky \cdot ky\right)}{kx \cdot kx}\\
                
                \mathbf{else}:\\
                \;\;\;\;\sin th\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if ky < 7.9999999999999996e-213

                  1. Initial program 90.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 \frac{\sin ky}{\color{blue}{\sin ky + \frac{1}{2} \cdot \frac{{kx}^{2}}{\sin ky}}} \cdot \sin th \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

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

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

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

                      \[\leadsto \frac{\sin ky}{\color{blue}{{kx}^{2} \cdot \frac{\frac{1}{2}}{\sin ky}} + \sin ky} \cdot \sin th \]
                    5. metadata-evalN/A

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

                      \[\leadsto \frac{\sin ky}{{kx}^{2} \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{1}{\sin ky}\right)} + \sin ky} \cdot \sin th \]
                    7. unpow2N/A

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

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

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

                      \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, \color{blue}{kx \cdot \left(\frac{1}{2} \cdot \frac{1}{\sin ky}\right)}, \sin ky\right)} \cdot \sin th \]
                    11. associate-*r/N/A

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

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

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

                      \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \frac{\frac{1}{2}}{\color{blue}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
                    15. sin-lowering-sin.f6422.1

                      \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \frac{0.5}{\sin ky}, \color{blue}{\sin ky}\right)} \cdot \sin th \]
                  5. Simplified22.1%

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

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

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

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

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

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

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

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

                      \[\leadsto 2 \cdot \frac{\sin th \cdot \color{blue}{\left(ky \cdot ky\right)}}{{kx}^{2}} \]
                    8. unpow2N/A

                      \[\leadsto 2 \cdot \frac{\sin th \cdot \left(ky \cdot ky\right)}{\color{blue}{kx \cdot kx}} \]
                    9. *-lowering-*.f6410.5

                      \[\leadsto 2 \cdot \frac{\sin th \cdot \left(ky \cdot ky\right)}{\color{blue}{kx \cdot kx}} \]
                  8. Simplified10.5%

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

                  if 7.9999999999999996e-213 < ky

                  1. Initial program 95.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.f6430.6

                      \[\leadsto \color{blue}{\sin th} \]
                  5. Simplified30.6%

                    \[\leadsto \color{blue}{\sin th} \]
                3. Recombined 2 regimes into one program.
                4. Add Preprocessing

                Alternative 23: 21.9% accurate, 5.9× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 7 \cdot 10^{-213}:\\ \;\;\;\;th \cdot \left(-0.16666666666666666 \cdot \left(th \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                (FPCore (kx ky th)
                 :precision binary64
                 (if (<= ky 7e-213) (* th (* -0.16666666666666666 (* th th))) (sin th)))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (ky <= 7e-213) {
                		tmp = th * (-0.16666666666666666 * (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 (ky <= 7d-213) then
                        tmp = th * ((-0.16666666666666666d0) * (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 (ky <= 7e-213) {
                		tmp = th * (-0.16666666666666666 * (th * th));
                	} else {
                		tmp = Math.sin(th);
                	}
                	return tmp;
                }
                
                def code(kx, ky, th):
                	tmp = 0
                	if ky <= 7e-213:
                		tmp = th * (-0.16666666666666666 * (th * th))
                	else:
                		tmp = math.sin(th)
                	return tmp
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (ky <= 7e-213)
                		tmp = Float64(th * Float64(-0.16666666666666666 * Float64(th * th)));
                	else
                		tmp = sin(th);
                	end
                	return tmp
                end
                
                function tmp_2 = code(kx, ky, th)
                	tmp = 0.0;
                	if (ky <= 7e-213)
                		tmp = th * (-0.16666666666666666 * (th * th));
                	else
                		tmp = sin(th);
                	end
                	tmp_2 = tmp;
                end
                
                code[kx_, ky_, th_] := If[LessEqual[ky, 7e-213], N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;ky \leq 7 \cdot 10^{-213}:\\
                \;\;\;\;th \cdot \left(-0.16666666666666666 \cdot \left(th \cdot th\right)\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;\sin th\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if ky < 7.00000000000000034e-213

                  1. Initial program 90.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.f6415.4

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

                    \[\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. *-lowering-*.f64N/A

                      \[\leadsto \color{blue}{th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)} \]
                    2. +-commutativeN/A

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

                      \[\leadsto th \cdot \color{blue}{\mathsf{fma}\left(\frac{-1}{6}, {th}^{2}, 1\right)} \]
                    4. unpow2N/A

                      \[\leadsto th \cdot \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{th \cdot th}, 1\right) \]
                    5. *-lowering-*.f6410.0

                      \[\leadsto th \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{th \cdot th}, 1\right) \]
                  8. Simplified10.0%

                    \[\leadsto \color{blue}{th \cdot \mathsf{fma}\left(-0.16666666666666666, th \cdot th, 1\right)} \]
                  9. Taylor expanded in th around inf

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

                      \[\leadsto th \cdot \color{blue}{\left(\frac{-1}{6} \cdot {th}^{2}\right)} \]
                    2. unpow2N/A

                      \[\leadsto th \cdot \left(\frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}\right) \]
                    3. *-lowering-*.f6411.4

                      \[\leadsto th \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}\right) \]
                  11. Simplified11.4%

                    \[\leadsto th \cdot \color{blue}{\left(-0.16666666666666666 \cdot \left(th \cdot th\right)\right)} \]

                  if 7.00000000000000034e-213 < ky

                  1. Initial program 95.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.f6430.6

                      \[\leadsto \color{blue}{\sin th} \]
                  5. Simplified30.6%

                    \[\leadsto \color{blue}{\sin th} \]
                3. Recombined 2 regimes into one program.
                4. Add Preprocessing

                Alternative 24: 15.6% accurate, 28.7× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 1.05 \cdot 10^{-183}:\\ \;\;\;\;th \cdot \left(-0.16666666666666666 \cdot \left(th \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \end{array} \]
                (FPCore (kx ky th)
                 :precision binary64
                 (if (<= ky 1.05e-183) (* th (* -0.16666666666666666 (* th th))) th))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (ky <= 1.05e-183) {
                		tmp = th * (-0.16666666666666666 * (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 (ky <= 1.05d-183) then
                        tmp = th * ((-0.16666666666666666d0) * (th * th))
                    else
                        tmp = th
                    end if
                    code = tmp
                end function
                
                public static double code(double kx, double ky, double th) {
                	double tmp;
                	if (ky <= 1.05e-183) {
                		tmp = th * (-0.16666666666666666 * (th * th));
                	} else {
                		tmp = th;
                	}
                	return tmp;
                }
                
                def code(kx, ky, th):
                	tmp = 0
                	if ky <= 1.05e-183:
                		tmp = th * (-0.16666666666666666 * (th * th))
                	else:
                		tmp = th
                	return tmp
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (ky <= 1.05e-183)
                		tmp = Float64(th * Float64(-0.16666666666666666 * Float64(th * th)));
                	else
                		tmp = th;
                	end
                	return tmp
                end
                
                function tmp_2 = code(kx, ky, th)
                	tmp = 0.0;
                	if (ky <= 1.05e-183)
                		tmp = th * (-0.16666666666666666 * (th * th));
                	else
                		tmp = th;
                	end
                	tmp_2 = tmp;
                end
                
                code[kx_, ky_, th_] := If[LessEqual[ky, 1.05e-183], N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], th]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;ky \leq 1.05 \cdot 10^{-183}:\\
                \;\;\;\;th \cdot \left(-0.16666666666666666 \cdot \left(th \cdot th\right)\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;th\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if ky < 1.0500000000000001e-183

                  1. Initial program 90.1%

                    \[\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.f6415.4

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

                    \[\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. *-lowering-*.f64N/A

                      \[\leadsto \color{blue}{th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)} \]
                    2. +-commutativeN/A

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

                      \[\leadsto th \cdot \color{blue}{\mathsf{fma}\left(\frac{-1}{6}, {th}^{2}, 1\right)} \]
                    4. unpow2N/A

                      \[\leadsto th \cdot \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{th \cdot th}, 1\right) \]
                    5. *-lowering-*.f649.7

                      \[\leadsto th \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{th \cdot th}, 1\right) \]
                  8. Simplified9.7%

                    \[\leadsto \color{blue}{th \cdot \mathsf{fma}\left(-0.16666666666666666, th \cdot th, 1\right)} \]
                  9. Taylor expanded in th around inf

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

                      \[\leadsto th \cdot \color{blue}{\left(\frac{-1}{6} \cdot {th}^{2}\right)} \]
                    2. unpow2N/A

                      \[\leadsto th \cdot \left(\frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}\right) \]
                    3. *-lowering-*.f6412.1

                      \[\leadsto th \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}\right) \]
                  11. Simplified12.1%

                    \[\leadsto th \cdot \color{blue}{\left(-0.16666666666666666 \cdot \left(th \cdot th\right)\right)} \]

                  if 1.0500000000000001e-183 < ky

                  1. Initial program 97.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.f6432.3

                      \[\leadsto \color{blue}{\sin th} \]
                  5. Simplified32.3%

                    \[\leadsto \color{blue}{\sin th} \]
                  6. Taylor expanded in th around 0

                    \[\leadsto \color{blue}{th} \]
                  7. Step-by-step derivation
                    1. Simplified16.3%

                      \[\leadsto \color{blue}{th} \]
                  8. Recombined 2 regimes into one program.
                  9. Add Preprocessing

                  Alternative 25: 15.6% accurate, 28.7× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 4.2 \cdot 10^{-184}:\\ \;\;\;\;-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 (<= ky 4.2e-184) (* -0.16666666666666666 (* th (* th th))) th))
                  double code(double kx, double ky, double th) {
                  	double tmp;
                  	if (ky <= 4.2e-184) {
                  		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 (ky <= 4.2d-184) 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 (ky <= 4.2e-184) {
                  		tmp = -0.16666666666666666 * (th * (th * th));
                  	} else {
                  		tmp = th;
                  	}
                  	return tmp;
                  }
                  
                  def code(kx, ky, th):
                  	tmp = 0
                  	if ky <= 4.2e-184:
                  		tmp = -0.16666666666666666 * (th * (th * th))
                  	else:
                  		tmp = th
                  	return tmp
                  
                  function code(kx, ky, th)
                  	tmp = 0.0
                  	if (ky <= 4.2e-184)
                  		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 (ky <= 4.2e-184)
                  		tmp = -0.16666666666666666 * (th * (th * th));
                  	else
                  		tmp = th;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[kx_, ky_, th_] := If[LessEqual[ky, 4.2e-184], N[(-0.16666666666666666 * N[(th * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], th]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;ky \leq 4.2 \cdot 10^{-184}:\\
                  \;\;\;\;-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 ky < 4.1999999999999998e-184

                    1. Initial program 90.1%

                      \[\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.f6415.4

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

                      \[\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. *-lowering-*.f64N/A

                        \[\leadsto \color{blue}{th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)} \]
                      2. +-commutativeN/A

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

                        \[\leadsto th \cdot \color{blue}{\mathsf{fma}\left(\frac{-1}{6}, {th}^{2}, 1\right)} \]
                      4. unpow2N/A

                        \[\leadsto th \cdot \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{th \cdot th}, 1\right) \]
                      5. *-lowering-*.f649.7

                        \[\leadsto th \cdot \mathsf{fma}\left(-0.16666666666666666, \color{blue}{th \cdot th}, 1\right) \]
                    8. Simplified9.7%

                      \[\leadsto \color{blue}{th \cdot \mathsf{fma}\left(-0.16666666666666666, th \cdot th, 1\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-*.f6412.1

                        \[\leadsto -0.16666666666666666 \cdot \left(th \cdot \color{blue}{\left(th \cdot th\right)}\right) \]
                    11. Simplified12.1%

                      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)} \]

                    if 4.1999999999999998e-184 < ky

                    1. Initial program 97.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.f6432.3

                        \[\leadsto \color{blue}{\sin th} \]
                    5. Simplified32.3%

                      \[\leadsto \color{blue}{\sin th} \]
                    6. Taylor expanded in th around 0

                      \[\leadsto \color{blue}{th} \]
                    7. Step-by-step derivation
                      1. Simplified16.3%

                        \[\leadsto \color{blue}{th} \]
                    8. Recombined 2 regimes into one program.
                    9. Add Preprocessing

                    Alternative 26: 13.5% 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 92.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.f6421.2

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

                      \[\leadsto \color{blue}{\sin th} \]
                    6. Taylor expanded in th around 0

                      \[\leadsto \color{blue}{th} \]
                    7. Step-by-step derivation
                      1. Simplified12.0%

                        \[\leadsto \color{blue}{th} \]
                      2. Add Preprocessing

                      Reproduce

                      ?
                      herbie shell --seed 2024197 
                      (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)))