Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.1% → 99.7%
Time: 11.2s
Alternatives: 22
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 22 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.1% 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} \\ \sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (* (sin th) (/ (sin ky) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
	return sin(th) * (sin(ky) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
	return Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th):
	return math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th)
	return Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), sin(kx))))
end
function tmp = code(kx, ky, th)
	tmp = sin(th) * (sin(ky) / hypot(sin(ky), sin(kx)));
end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Derivation
  1. Initial program 94.4%

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
    8. lower-hypot.f6499.7

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

    \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
  5. Final simplification99.7%

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

Alternative 2: 79.2% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_2 := \cos \left(ky + ky\right)\\
t_3 := \frac{\sin ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
\mathbf{if}\;t\_1 \leq -0.945:\\
\;\;\;\;\left(\frac{1}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\

\mathbf{elif}\;t\_1 \leq -0.1:\\
\;\;\;\;\left(\sqrt{2} \cdot \sqrt{\frac{1}{\left(2 - t\_2\right) - \cos \left(2 \cdot kx\right)}}\right) \cdot \left(th \cdot \sin ky\right)\\

\mathbf{elif}\;t\_1 \leq 10^{-7}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, -0.0001984126984126984, 0.008333333333333333\right), th \cdot th, -0.16666666666666666\right), th \cdot th, 1\right) \cdot th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - t\_2, 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.944999999999999951

    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. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.944999999999999951 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

    1. Initial program 99.4%

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      7. 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 \]
      8. 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 \]
      9. 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 \]
      10. lower-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 \]
      11. 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 \]
      12. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      13. cos-sin-sumN/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 \]
      14. lower--.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 \]
      15. 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 \]
      16. lower-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 \]
      17. lower-+.f6499.3

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

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
      19. 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 \]
      20. lift-sin.f64N/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 \]
      21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sin ky \cdot th\right) \cdot \left(\sqrt{2} \cdot \color{blue}{\sqrt{\frac{1}{2 - \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)}}}\right) \]
    9. Step-by-step derivation
      1. Applied rewrites60.8%

        \[\leadsto \left(\sin ky \cdot th\right) \cdot \left(\sqrt{\frac{1}{\left(2 - \cos \left(ky \cdot 2\right)\right) - \cos \left(kx \cdot 2\right)}} \cdot \color{blue}{\sqrt{2}}\right) \]
      2. Step-by-step derivation
        1. Applied rewrites60.8%

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

        if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8 or 2 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

        1. Initial program 90.9%

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

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

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

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

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

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

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

            \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
          8. lower-hypot.f6499.7

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

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

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

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

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

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

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

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

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

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

        if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779

        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. lift-+.f64N/A

            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

            \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
          7. 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 \]
          8. 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 \]
          9. 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 \]
          10. lower-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 \]
          11. 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 \]
          12. cos-diffN/A

            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
          13. cos-sin-sumN/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 \]
          14. lower--.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 \]
          15. 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 \]
          16. lower-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 \]
          17. lower-+.f6499.1

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

            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
          19. 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 \]
          20. lift-sin.f64N/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 \]
          21. lift-sin.f64N/A

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

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

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

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

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

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

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

        if 0.99725809995349779 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2

        1. Initial program 100.0%

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

          \[\leadsto \color{blue}{\sin th} \]
        4. Step-by-step derivation
          1. lower-sin.f6498.5

            \[\leadsto \color{blue}{\sin th} \]
        5. Applied rewrites98.5%

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

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

      Alternative 3: 64.6% accurate, 0.3× speedup?

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

        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. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -0.944999999999999951 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

        1. Initial program 99.4%

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

            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

            \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
          7. 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 \]
          8. 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 \]
          9. 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 \]
          10. lower-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 \]
          11. 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 \]
          12. cos-diffN/A

            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
          13. cos-sin-sumN/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 \]
          14. lower--.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 \]
          15. 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 \]
          16. lower-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 \]
          17. lower-+.f6499.3

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

            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
          19. 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 \]
          20. lift-sin.f64N/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 \]
          21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\sin ky \cdot th\right) \cdot \left(\sqrt{2} \cdot \color{blue}{\sqrt{\frac{1}{2 - \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)}}}\right) \]
        9. Step-by-step derivation
          1. Applied rewrites60.8%

            \[\leadsto \left(\sin ky \cdot th\right) \cdot \left(\sqrt{\frac{1}{\left(2 - \cos \left(ky \cdot 2\right)\right) - \cos \left(kx \cdot 2\right)}} \cdot \color{blue}{\sqrt{2}}\right) \]
          2. Step-by-step derivation
            1. Applied rewrites60.8%

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

            if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999996e-24

            1. Initial program 99.7%

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

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

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

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

            if 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779

            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. lift-+.f64N/A

                \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
              7. 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 \]
              8. 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 \]
              9. 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 \]
              10. lower-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 \]
              11. 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 \]
              12. cos-diffN/A

                \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
              13. cos-sin-sumN/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 \]
              14. lower--.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 \]
              15. 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 \]
              16. lower-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 \]
              17. lower-+.f6499.1

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

                \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
              19. 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 \]
              20. lift-sin.f64N/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 \]
              21. lift-sin.f64N/A

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

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

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

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

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

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

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

            if 0.99725809995349779 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

            1. Initial program 82.5%

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

              \[\leadsto \color{blue}{\sin th} \]
            4. Step-by-step derivation
              1. lower-sin.f6491.5

                \[\leadsto \color{blue}{\sin th} \]
            5. Applied rewrites91.5%

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

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

          Alternative 4: 64.6% accurate, 0.3× speedup?

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

            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. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -0.944999999999999951 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

            1. Initial program 99.4%

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

                \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
              7. 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 \]
              8. 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 \]
              9. 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 \]
              10. lower-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 \]
              11. 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 \]
              12. cos-diffN/A

                \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
              13. cos-sin-sumN/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 \]
              14. lower--.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 \]
              15. 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 \]
              16. lower-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 \]
              17. lower-+.f6499.3

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

                \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
              19. 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 \]
              20. lift-sin.f64N/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 \]
              21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(\sin ky \cdot th\right) \cdot \left(\sqrt{2} \cdot \color{blue}{\sqrt{\frac{1}{2 - \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)}}}\right) \]
            9. Step-by-step derivation
              1. Applied rewrites60.8%

                \[\leadsto \left(\sin ky \cdot th\right) \cdot \left(\sqrt{\frac{1}{\left(2 - \cos \left(ky \cdot 2\right)\right) - \cos \left(kx \cdot 2\right)}} \cdot \color{blue}{\sqrt{2}}\right) \]
              2. Step-by-step derivation
                1. Applied rewrites60.8%

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

                if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999996e-24

                1. Initial program 99.7%

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

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

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

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

                if 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779

                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. lift-+.f64N/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                    \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                  7. 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 \]
                  8. 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 \]
                  9. 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 \]
                  10. lower-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 \]
                  11. 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 \]
                  12. cos-diffN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                  13. cos-sin-sumN/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 \]
                  14. lower--.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 \]
                  15. 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 \]
                  16. lower-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 \]
                  17. lower-+.f6499.1

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

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                  19. 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 \]
                  20. lift-sin.f64N/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 \]
                  21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if 0.99725809995349779 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                1. Initial program 82.5%

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

                  \[\leadsto \color{blue}{\sin th} \]
                4. Step-by-step derivation
                  1. lower-sin.f6491.5

                    \[\leadsto \color{blue}{\sin th} \]
                5. Applied rewrites91.5%

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

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

              Alternative 5: 64.6% accurate, 0.3× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\ t_2 := \cos \left(2 \cdot ky\right)\\ t_3 := \cos \left(2 \cdot kx\right)\\ \mathbf{if}\;t\_1 \leq -0.945:\\ \;\;\;\;\left(\frac{1}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\ \mathbf{elif}\;t\_1 \leq -0.1:\\ \;\;\;\;\left(\sqrt{2} \cdot \sqrt{\frac{1}{\left(2 - \cos \left(ky + ky\right)\right) - t\_3}}\right) \cdot \left(th \cdot \sin ky\right)\\ \mathbf{elif}\;t\_1 \leq 10^{-23}:\\ \;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\ \mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\ \;\;\;\;\left(\sqrt{\frac{1}{\left(\left(1 - t\_3\right) - \left(t\_2 - 1\right)\right) \cdot 0.5}} \cdot \left(-th\right)\right) \cdot \left(-\sin ky\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
              (FPCore (kx ky th)
               :precision binary64
               (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
                      (t_2 (cos (* 2.0 ky)))
                      (t_3 (cos (* 2.0 kx))))
                 (if (<= t_1 -0.945)
                   (* (* (/ 1.0 (sqrt (* (- 1.0 t_2) 0.5))) (sin ky)) (sin th))
                   (if (<= t_1 -0.1)
                     (*
                      (* (sqrt 2.0) (sqrt (/ 1.0 (- (- 2.0 (cos (+ ky ky))) t_3))))
                      (* th (sin ky)))
                     (if (<= t_1 1e-23)
                       (* (/ (sin ky) (sin kx)) (sin th))
                       (if (<= t_1 0.9972580999534978)
                         (*
                          (* (sqrt (/ 1.0 (* (- (- 1.0 t_3) (- t_2 1.0)) 0.5))) (- th))
                          (- (sin ky)))
                         (sin th)))))))
              double code(double kx, double ky, double th) {
              	double t_1 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
              	double t_2 = cos((2.0 * ky));
              	double t_3 = cos((2.0 * kx));
              	double tmp;
              	if (t_1 <= -0.945) {
              		tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th);
              	} else if (t_1 <= -0.1) {
              		tmp = (sqrt(2.0) * sqrt((1.0 / ((2.0 - cos((ky + ky))) - t_3)))) * (th * sin(ky));
              	} else if (t_1 <= 1e-23) {
              		tmp = (sin(ky) / sin(kx)) * sin(th);
              	} else if (t_1 <= 0.9972580999534978) {
              		tmp = (sqrt((1.0 / (((1.0 - t_3) - (t_2 - 1.0)) * 0.5))) * -th) * -sin(ky);
              	} else {
              		tmp = sin(th);
              	}
              	return tmp;
              }
              
              real(8) function code(kx, ky, th)
                  real(8), intent (in) :: kx
                  real(8), intent (in) :: ky
                  real(8), intent (in) :: th
                  real(8) :: t_1
                  real(8) :: t_2
                  real(8) :: t_3
                  real(8) :: tmp
                  t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
                  t_2 = cos((2.0d0 * ky))
                  t_3 = cos((2.0d0 * kx))
                  if (t_1 <= (-0.945d0)) then
                      tmp = ((1.0d0 / sqrt(((1.0d0 - t_2) * 0.5d0))) * sin(ky)) * sin(th)
                  else if (t_1 <= (-0.1d0)) then
                      tmp = (sqrt(2.0d0) * sqrt((1.0d0 / ((2.0d0 - cos((ky + ky))) - t_3)))) * (th * sin(ky))
                  else if (t_1 <= 1d-23) then
                      tmp = (sin(ky) / sin(kx)) * sin(th)
                  else if (t_1 <= 0.9972580999534978d0) then
                      tmp = (sqrt((1.0d0 / (((1.0d0 - t_3) - (t_2 - 1.0d0)) * 0.5d0))) * -th) * -sin(ky)
                  else
                      tmp = sin(th)
                  end if
                  code = tmp
              end function
              
              public static double code(double kx, double ky, double th) {
              	double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
              	double t_2 = Math.cos((2.0 * ky));
              	double t_3 = Math.cos((2.0 * kx));
              	double tmp;
              	if (t_1 <= -0.945) {
              		tmp = ((1.0 / Math.sqrt(((1.0 - t_2) * 0.5))) * Math.sin(ky)) * Math.sin(th);
              	} else if (t_1 <= -0.1) {
              		tmp = (Math.sqrt(2.0) * Math.sqrt((1.0 / ((2.0 - Math.cos((ky + ky))) - t_3)))) * (th * Math.sin(ky));
              	} else if (t_1 <= 1e-23) {
              		tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
              	} else if (t_1 <= 0.9972580999534978) {
              		tmp = (Math.sqrt((1.0 / (((1.0 - t_3) - (t_2 - 1.0)) * 0.5))) * -th) * -Math.sin(ky);
              	} else {
              		tmp = Math.sin(th);
              	}
              	return tmp;
              }
              
              def code(kx, ky, th):
              	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))
              	t_2 = math.cos((2.0 * ky))
              	t_3 = math.cos((2.0 * kx))
              	tmp = 0
              	if t_1 <= -0.945:
              		tmp = ((1.0 / math.sqrt(((1.0 - t_2) * 0.5))) * math.sin(ky)) * math.sin(th)
              	elif t_1 <= -0.1:
              		tmp = (math.sqrt(2.0) * math.sqrt((1.0 / ((2.0 - math.cos((ky + ky))) - t_3)))) * (th * math.sin(ky))
              	elif t_1 <= 1e-23:
              		tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th)
              	elif t_1 <= 0.9972580999534978:
              		tmp = (math.sqrt((1.0 / (((1.0 - t_3) - (t_2 - 1.0)) * 0.5))) * -th) * -math.sin(ky)
              	else:
              		tmp = math.sin(th)
              	return tmp
              
              function code(kx, ky, th)
              	t_1 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))))
              	t_2 = cos(Float64(2.0 * ky))
              	t_3 = cos(Float64(2.0 * kx))
              	tmp = 0.0
              	if (t_1 <= -0.945)
              		tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(Float64(1.0 - t_2) * 0.5))) * sin(ky)) * sin(th));
              	elseif (t_1 <= -0.1)
              		tmp = Float64(Float64(sqrt(2.0) * sqrt(Float64(1.0 / Float64(Float64(2.0 - cos(Float64(ky + ky))) - t_3)))) * Float64(th * sin(ky)));
              	elseif (t_1 <= 1e-23)
              		tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th));
              	elseif (t_1 <= 0.9972580999534978)
              		tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(Float64(Float64(1.0 - t_3) - Float64(t_2 - 1.0)) * 0.5))) * Float64(-th)) * Float64(-sin(ky)));
              	else
              		tmp = sin(th);
              	end
              	return tmp
              end
              
              function tmp_2 = code(kx, ky, th)
              	t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)));
              	t_2 = cos((2.0 * ky));
              	t_3 = cos((2.0 * kx));
              	tmp = 0.0;
              	if (t_1 <= -0.945)
              		tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th);
              	elseif (t_1 <= -0.1)
              		tmp = (sqrt(2.0) * sqrt((1.0 / ((2.0 - cos((ky + ky))) - t_3)))) * (th * sin(ky));
              	elseif (t_1 <= 1e-23)
              		tmp = (sin(ky) / sin(kx)) * sin(th);
              	elseif (t_1 <= 0.9972580999534978)
              		tmp = (sqrt((1.0 / (((1.0 - t_3) - (t_2 - 1.0)) * 0.5))) * -th) * -sin(ky);
              	else
              		tmp = sin(th);
              	end
              	tmp_2 = tmp;
              end
              
              code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.945], N[(N[(N[(1.0 / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.1], N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[N[(1.0 / N[(N[(2.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-23], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9972580999534978], N[(N[(N[Sqrt[N[(1.0 / N[(N[(N[(1.0 - t$95$3), $MachinePrecision] - N[(t$95$2 - 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-th)), $MachinePrecision] * (-N[Sin[ky], $MachinePrecision])), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
              t_2 := \cos \left(2 \cdot ky\right)\\
              t_3 := \cos \left(2 \cdot kx\right)\\
              \mathbf{if}\;t\_1 \leq -0.945:\\
              \;\;\;\;\left(\frac{1}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
              
              \mathbf{elif}\;t\_1 \leq -0.1:\\
              \;\;\;\;\left(\sqrt{2} \cdot \sqrt{\frac{1}{\left(2 - \cos \left(ky + ky\right)\right) - t\_3}}\right) \cdot \left(th \cdot \sin ky\right)\\
              
              \mathbf{elif}\;t\_1 \leq 10^{-23}:\\
              \;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
              
              \mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\
              \;\;\;\;\left(\sqrt{\frac{1}{\left(\left(1 - t\_3\right) - \left(t\_2 - 1\right)\right) \cdot 0.5}} \cdot \left(-th\right)\right) \cdot \left(-\sin ky\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\sin th\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 5 regimes
              2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.944999999999999951

                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. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if -0.944999999999999951 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

                1. Initial program 99.4%

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

                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                    \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                  7. 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 \]
                  8. 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 \]
                  9. 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 \]
                  10. lower-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 \]
                  11. 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 \]
                  12. cos-diffN/A

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                  13. cos-sin-sumN/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 \]
                  14. lower--.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 \]
                  15. 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 \]
                  16. lower-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 \]
                  17. lower-+.f6499.3

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

                    \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                  19. 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 \]
                  20. lift-sin.f64N/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 \]
                  21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \left(\sqrt{2} \cdot \color{blue}{\sqrt{\frac{1}{2 - \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)}}}\right) \]
                9. Step-by-step derivation
                  1. Applied rewrites60.8%

                    \[\leadsto \left(\sin ky \cdot th\right) \cdot \left(\sqrt{\frac{1}{\left(2 - \cos \left(ky \cdot 2\right)\right) - \cos \left(kx \cdot 2\right)}} \cdot \color{blue}{\sqrt{2}}\right) \]
                  2. Step-by-step derivation
                    1. Applied rewrites60.8%

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

                    if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999996e-24

                    1. Initial program 99.7%

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

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

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

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

                    if 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779

                    1. Initial program 99.5%

                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                    2. Add Preprocessing
                    3. Applied rewrites99.1%

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\mathsf{neg}\left(\sin ky\right)\right) \cdot \left(\left(\mathsf{neg}\left(th\right)\right) \cdot \sqrt{\frac{1}{\frac{1}{2} \cdot \color{blue}{\left(\left(1 - \cos \left(2 \cdot kx\right)\right) + \left(1 - \cos \left(2 \cdot ky\right)\right)\right)}}}\right) \]
                    6. Applied rewrites38.2%

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

                    if 0.99725809995349779 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                    1. Initial program 82.5%

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

                      \[\leadsto \color{blue}{\sin th} \]
                    4. Step-by-step derivation
                      1. lower-sin.f6491.5

                        \[\leadsto \color{blue}{\sin th} \]
                    5. Applied rewrites91.5%

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

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

                  Alternative 6: 64.6% accurate, 0.3× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\ t_2 := \cos \left(2 \cdot ky\right)\\ t_3 := \left(\sqrt{\frac{1}{\left(\left(1 - \cos \left(2 \cdot kx\right)\right) - \left(t\_2 - 1\right)\right) \cdot 0.5}} \cdot \left(-th\right)\right) \cdot \left(-\sin ky\right)\\ \mathbf{if}\;t\_1 \leq -0.945:\\ \;\;\;\;\left(\frac{1}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\ \mathbf{elif}\;t\_1 \leq -0.1:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_1 \leq 10^{-23}:\\ \;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\ \mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                  (FPCore (kx ky th)
                   :precision binary64
                   (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
                          (t_2 (cos (* 2.0 ky)))
                          (t_3
                           (*
                            (*
                             (sqrt (/ 1.0 (* (- (- 1.0 (cos (* 2.0 kx))) (- t_2 1.0)) 0.5)))
                             (- th))
                            (- (sin ky)))))
                     (if (<= t_1 -0.945)
                       (* (* (/ 1.0 (sqrt (* (- 1.0 t_2) 0.5))) (sin ky)) (sin th))
                       (if (<= t_1 -0.1)
                         t_3
                         (if (<= t_1 1e-23)
                           (* (/ (sin ky) (sin kx)) (sin th))
                           (if (<= t_1 0.9972580999534978) t_3 (sin th)))))))
                  double code(double kx, double ky, double th) {
                  	double t_1 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
                  	double t_2 = cos((2.0 * ky));
                  	double t_3 = (sqrt((1.0 / (((1.0 - cos((2.0 * kx))) - (t_2 - 1.0)) * 0.5))) * -th) * -sin(ky);
                  	double tmp;
                  	if (t_1 <= -0.945) {
                  		tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th);
                  	} else if (t_1 <= -0.1) {
                  		tmp = t_3;
                  	} else if (t_1 <= 1e-23) {
                  		tmp = (sin(ky) / sin(kx)) * sin(th);
                  	} else if (t_1 <= 0.9972580999534978) {
                  		tmp = t_3;
                  	} else {
                  		tmp = sin(th);
                  	}
                  	return tmp;
                  }
                  
                  real(8) function code(kx, ky, th)
                      real(8), intent (in) :: kx
                      real(8), intent (in) :: ky
                      real(8), intent (in) :: th
                      real(8) :: t_1
                      real(8) :: t_2
                      real(8) :: t_3
                      real(8) :: tmp
                      t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
                      t_2 = cos((2.0d0 * ky))
                      t_3 = (sqrt((1.0d0 / (((1.0d0 - cos((2.0d0 * kx))) - (t_2 - 1.0d0)) * 0.5d0))) * -th) * -sin(ky)
                      if (t_1 <= (-0.945d0)) then
                          tmp = ((1.0d0 / sqrt(((1.0d0 - t_2) * 0.5d0))) * sin(ky)) * sin(th)
                      else if (t_1 <= (-0.1d0)) then
                          tmp = t_3
                      else if (t_1 <= 1d-23) then
                          tmp = (sin(ky) / sin(kx)) * sin(th)
                      else if (t_1 <= 0.9972580999534978d0) then
                          tmp = t_3
                      else
                          tmp = sin(th)
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double kx, double ky, double th) {
                  	double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
                  	double t_2 = Math.cos((2.0 * ky));
                  	double t_3 = (Math.sqrt((1.0 / (((1.0 - Math.cos((2.0 * kx))) - (t_2 - 1.0)) * 0.5))) * -th) * -Math.sin(ky);
                  	double tmp;
                  	if (t_1 <= -0.945) {
                  		tmp = ((1.0 / Math.sqrt(((1.0 - t_2) * 0.5))) * Math.sin(ky)) * Math.sin(th);
                  	} else if (t_1 <= -0.1) {
                  		tmp = t_3;
                  	} else if (t_1 <= 1e-23) {
                  		tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
                  	} else if (t_1 <= 0.9972580999534978) {
                  		tmp = t_3;
                  	} else {
                  		tmp = Math.sin(th);
                  	}
                  	return tmp;
                  }
                  
                  def code(kx, ky, th):
                  	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))
                  	t_2 = math.cos((2.0 * ky))
                  	t_3 = (math.sqrt((1.0 / (((1.0 - math.cos((2.0 * kx))) - (t_2 - 1.0)) * 0.5))) * -th) * -math.sin(ky)
                  	tmp = 0
                  	if t_1 <= -0.945:
                  		tmp = ((1.0 / math.sqrt(((1.0 - t_2) * 0.5))) * math.sin(ky)) * math.sin(th)
                  	elif t_1 <= -0.1:
                  		tmp = t_3
                  	elif t_1 <= 1e-23:
                  		tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th)
                  	elif t_1 <= 0.9972580999534978:
                  		tmp = t_3
                  	else:
                  		tmp = math.sin(th)
                  	return tmp
                  
                  function code(kx, ky, th)
                  	t_1 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))))
                  	t_2 = cos(Float64(2.0 * ky))
                  	t_3 = Float64(Float64(sqrt(Float64(1.0 / Float64(Float64(Float64(1.0 - cos(Float64(2.0 * kx))) - Float64(t_2 - 1.0)) * 0.5))) * Float64(-th)) * Float64(-sin(ky)))
                  	tmp = 0.0
                  	if (t_1 <= -0.945)
                  		tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(Float64(1.0 - t_2) * 0.5))) * sin(ky)) * sin(th));
                  	elseif (t_1 <= -0.1)
                  		tmp = t_3;
                  	elseif (t_1 <= 1e-23)
                  		tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th));
                  	elseif (t_1 <= 0.9972580999534978)
                  		tmp = t_3;
                  	else
                  		tmp = sin(th);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(kx, ky, th)
                  	t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)));
                  	t_2 = cos((2.0 * ky));
                  	t_3 = (sqrt((1.0 / (((1.0 - cos((2.0 * kx))) - (t_2 - 1.0)) * 0.5))) * -th) * -sin(ky);
                  	tmp = 0.0;
                  	if (t_1 <= -0.945)
                  		tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th);
                  	elseif (t_1 <= -0.1)
                  		tmp = t_3;
                  	elseif (t_1 <= 1e-23)
                  		tmp = (sin(ky) / sin(kx)) * sin(th);
                  	elseif (t_1 <= 0.9972580999534978)
                  		tmp = t_3;
                  	else
                  		tmp = sin(th);
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Sqrt[N[(1.0 / N[(N[(N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 - 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-th)), $MachinePrecision] * (-N[Sin[ky], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[t$95$1, -0.945], N[(N[(N[(1.0 / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.1], t$95$3, If[LessEqual[t$95$1, 1e-23], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9972580999534978], t$95$3, N[Sin[th], $MachinePrecision]]]]]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
                  t_2 := \cos \left(2 \cdot ky\right)\\
                  t_3 := \left(\sqrt{\frac{1}{\left(\left(1 - \cos \left(2 \cdot kx\right)\right) - \left(t\_2 - 1\right)\right) \cdot 0.5}} \cdot \left(-th\right)\right) \cdot \left(-\sin ky\right)\\
                  \mathbf{if}\;t\_1 \leq -0.945:\\
                  \;\;\;\;\left(\frac{1}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
                  
                  \mathbf{elif}\;t\_1 \leq -0.1:\\
                  \;\;\;\;t\_3\\
                  
                  \mathbf{elif}\;t\_1 \leq 10^{-23}:\\
                  \;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
                  
                  \mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\
                  \;\;\;\;t\_3\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\sin th\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 4 regimes
                  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.944999999999999951

                    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. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if -0.944999999999999951 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001 or 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779

                    1. Initial program 99.4%

                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                    2. Add Preprocessing
                    3. Applied rewrites99.2%

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\mathsf{neg}\left(\sin ky\right)\right) \cdot \left(\left(\mathsf{neg}\left(th\right)\right) \cdot \sqrt{\frac{1}{\frac{1}{2} \cdot \color{blue}{\left(\left(1 - \cos \left(2 \cdot kx\right)\right) + \left(1 - \cos \left(2 \cdot ky\right)\right)\right)}}}\right) \]
                    6. Applied rewrites49.3%

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

                    if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999996e-24

                    1. Initial program 99.7%

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

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

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

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

                    if 0.99725809995349779 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                    1. Initial program 82.5%

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

                      \[\leadsto \color{blue}{\sin th} \]
                    4. Step-by-step derivation
                      1. lower-sin.f6491.5

                        \[\leadsto \color{blue}{\sin th} \]
                    5. Applied rewrites91.5%

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

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

                  Alternative 7: 64.6% accurate, 0.3× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_1 := \cos \left(2 \cdot kx\right)\\ t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\ t_3 := \cos \left(2 \cdot ky\right)\\ t_4 := 1 - t\_3\\ t_5 := th \cdot \sin ky\\ \mathbf{if}\;t\_2 \leq -0.945:\\ \;\;\;\;\left(\frac{1}{\sqrt{t\_4 \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\ \mathbf{elif}\;t\_2 \leq -0.1:\\ \;\;\;\;\sqrt{\frac{2}{1 - \left(t\_1 - t\_4\right)}} \cdot t\_5\\ \mathbf{elif}\;t\_2 \leq 10^{-23}:\\ \;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\ \mathbf{elif}\;t\_2 \leq 0.9972580999534978:\\ \;\;\;\;\sqrt{\frac{2}{\left(2 - t\_3\right) - t\_1}} \cdot t\_5\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                  (FPCore (kx ky th)
                   :precision binary64
                   (let* ((t_1 (cos (* 2.0 kx)))
                          (t_2 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
                          (t_3 (cos (* 2.0 ky)))
                          (t_4 (- 1.0 t_3))
                          (t_5 (* th (sin ky))))
                     (if (<= t_2 -0.945)
                       (* (* (/ 1.0 (sqrt (* t_4 0.5))) (sin ky)) (sin th))
                       (if (<= t_2 -0.1)
                         (* (sqrt (/ 2.0 (- 1.0 (- t_1 t_4)))) t_5)
                         (if (<= t_2 1e-23)
                           (* (/ (sin ky) (sin kx)) (sin th))
                           (if (<= t_2 0.9972580999534978)
                             (* (sqrt (/ 2.0 (- (- 2.0 t_3) t_1))) t_5)
                             (sin th)))))))
                  double code(double kx, double ky, double th) {
                  	double t_1 = cos((2.0 * kx));
                  	double t_2 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
                  	double t_3 = cos((2.0 * ky));
                  	double t_4 = 1.0 - t_3;
                  	double t_5 = th * sin(ky);
                  	double tmp;
                  	if (t_2 <= -0.945) {
                  		tmp = ((1.0 / sqrt((t_4 * 0.5))) * sin(ky)) * sin(th);
                  	} else if (t_2 <= -0.1) {
                  		tmp = sqrt((2.0 / (1.0 - (t_1 - t_4)))) * t_5;
                  	} else if (t_2 <= 1e-23) {
                  		tmp = (sin(ky) / sin(kx)) * sin(th);
                  	} else if (t_2 <= 0.9972580999534978) {
                  		tmp = sqrt((2.0 / ((2.0 - t_3) - t_1))) * t_5;
                  	} else {
                  		tmp = sin(th);
                  	}
                  	return tmp;
                  }
                  
                  real(8) function code(kx, ky, th)
                      real(8), intent (in) :: kx
                      real(8), intent (in) :: ky
                      real(8), intent (in) :: th
                      real(8) :: t_1
                      real(8) :: t_2
                      real(8) :: t_3
                      real(8) :: t_4
                      real(8) :: t_5
                      real(8) :: tmp
                      t_1 = cos((2.0d0 * kx))
                      t_2 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
                      t_3 = cos((2.0d0 * ky))
                      t_4 = 1.0d0 - t_3
                      t_5 = th * sin(ky)
                      if (t_2 <= (-0.945d0)) then
                          tmp = ((1.0d0 / sqrt((t_4 * 0.5d0))) * sin(ky)) * sin(th)
                      else if (t_2 <= (-0.1d0)) then
                          tmp = sqrt((2.0d0 / (1.0d0 - (t_1 - t_4)))) * t_5
                      else if (t_2 <= 1d-23) then
                          tmp = (sin(ky) / sin(kx)) * sin(th)
                      else if (t_2 <= 0.9972580999534978d0) then
                          tmp = sqrt((2.0d0 / ((2.0d0 - t_3) - t_1))) * t_5
                      else
                          tmp = sin(th)
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double kx, double ky, double th) {
                  	double t_1 = Math.cos((2.0 * kx));
                  	double t_2 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
                  	double t_3 = Math.cos((2.0 * ky));
                  	double t_4 = 1.0 - t_3;
                  	double t_5 = th * Math.sin(ky);
                  	double tmp;
                  	if (t_2 <= -0.945) {
                  		tmp = ((1.0 / Math.sqrt((t_4 * 0.5))) * Math.sin(ky)) * Math.sin(th);
                  	} else if (t_2 <= -0.1) {
                  		tmp = Math.sqrt((2.0 / (1.0 - (t_1 - t_4)))) * t_5;
                  	} else if (t_2 <= 1e-23) {
                  		tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
                  	} else if (t_2 <= 0.9972580999534978) {
                  		tmp = Math.sqrt((2.0 / ((2.0 - t_3) - t_1))) * t_5;
                  	} else {
                  		tmp = Math.sin(th);
                  	}
                  	return tmp;
                  }
                  
                  def code(kx, ky, th):
                  	t_1 = math.cos((2.0 * kx))
                  	t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))
                  	t_3 = math.cos((2.0 * ky))
                  	t_4 = 1.0 - t_3
                  	t_5 = th * math.sin(ky)
                  	tmp = 0
                  	if t_2 <= -0.945:
                  		tmp = ((1.0 / math.sqrt((t_4 * 0.5))) * math.sin(ky)) * math.sin(th)
                  	elif t_2 <= -0.1:
                  		tmp = math.sqrt((2.0 / (1.0 - (t_1 - t_4)))) * t_5
                  	elif t_2 <= 1e-23:
                  		tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th)
                  	elif t_2 <= 0.9972580999534978:
                  		tmp = math.sqrt((2.0 / ((2.0 - t_3) - t_1))) * t_5
                  	else:
                  		tmp = math.sin(th)
                  	return tmp
                  
                  function code(kx, ky, th)
                  	t_1 = cos(Float64(2.0 * kx))
                  	t_2 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))))
                  	t_3 = cos(Float64(2.0 * ky))
                  	t_4 = Float64(1.0 - t_3)
                  	t_5 = Float64(th * sin(ky))
                  	tmp = 0.0
                  	if (t_2 <= -0.945)
                  		tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(t_4 * 0.5))) * sin(ky)) * sin(th));
                  	elseif (t_2 <= -0.1)
                  		tmp = Float64(sqrt(Float64(2.0 / Float64(1.0 - Float64(t_1 - t_4)))) * t_5);
                  	elseif (t_2 <= 1e-23)
                  		tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th));
                  	elseif (t_2 <= 0.9972580999534978)
                  		tmp = Float64(sqrt(Float64(2.0 / Float64(Float64(2.0 - t_3) - t_1))) * t_5);
                  	else
                  		tmp = sin(th);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(kx, ky, th)
                  	t_1 = cos((2.0 * kx));
                  	t_2 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)));
                  	t_3 = cos((2.0 * ky));
                  	t_4 = 1.0 - t_3;
                  	t_5 = th * sin(ky);
                  	tmp = 0.0;
                  	if (t_2 <= -0.945)
                  		tmp = ((1.0 / sqrt((t_4 * 0.5))) * sin(ky)) * sin(th);
                  	elseif (t_2 <= -0.1)
                  		tmp = sqrt((2.0 / (1.0 - (t_1 - t_4)))) * t_5;
                  	elseif (t_2 <= 1e-23)
                  		tmp = (sin(ky) / sin(kx)) * sin(th);
                  	elseif (t_2 <= 0.9972580999534978)
                  		tmp = sqrt((2.0 / ((2.0 - t_3) - t_1))) * t_5;
                  	else
                  		tmp = sin(th);
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[kx_, ky_, th_] := Block[{t$95$1 = N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.945], N[(N[(N[(1.0 / N[Sqrt[N[(t$95$4 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.1], N[(N[Sqrt[N[(2.0 / N[(1.0 - N[(t$95$1 - t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$5), $MachinePrecision], If[LessEqual[t$95$2, 1e-23], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.9972580999534978], N[(N[Sqrt[N[(2.0 / N[(N[(2.0 - t$95$3), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$5), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_1 := \cos \left(2 \cdot kx\right)\\
                  t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
                  t_3 := \cos \left(2 \cdot ky\right)\\
                  t_4 := 1 - t\_3\\
                  t_5 := th \cdot \sin ky\\
                  \mathbf{if}\;t\_2 \leq -0.945:\\
                  \;\;\;\;\left(\frac{1}{\sqrt{t\_4 \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
                  
                  \mathbf{elif}\;t\_2 \leq -0.1:\\
                  \;\;\;\;\sqrt{\frac{2}{1 - \left(t\_1 - t\_4\right)}} \cdot t\_5\\
                  
                  \mathbf{elif}\;t\_2 \leq 10^{-23}:\\
                  \;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
                  
                  \mathbf{elif}\;t\_2 \leq 0.9972580999534978:\\
                  \;\;\;\;\sqrt{\frac{2}{\left(2 - t\_3\right) - t\_1}} \cdot t\_5\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\sin th\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 5 regimes
                  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.944999999999999951

                    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. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if -0.944999999999999951 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

                    1. Initial program 99.4%

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

                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                      7. 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 \]
                      8. 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 \]
                      9. 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 \]
                      10. lower-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 \]
                      11. 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 \]
                      12. cos-diffN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                      13. cos-sin-sumN/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 \]
                      14. lower--.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 \]
                      15. 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 \]
                      16. lower-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 \]
                      17. lower-+.f6499.3

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

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                      19. 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 \]
                      20. lift-sin.f64N/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 \]
                      21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999996e-24

                    1. Initial program 99.7%

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

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

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

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

                    if 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779

                    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. lift-+.f64N/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                      7. 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 \]
                      8. 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 \]
                      9. 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 \]
                      10. lower-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 \]
                      11. 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 \]
                      12. cos-diffN/A

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                      13. cos-sin-sumN/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 \]
                      14. lower--.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 \]
                      15. 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 \]
                      16. lower-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 \]
                      17. lower-+.f6499.1

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

                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                      19. 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 \]
                      20. lift-sin.f64N/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 \]
                      21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{2 - \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)}} \]
                    9. Step-by-step derivation
                      1. Applied rewrites38.0%

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

                      if 0.99725809995349779 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                      1. Initial program 82.5%

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

                        \[\leadsto \color{blue}{\sin th} \]
                      4. Step-by-step derivation
                        1. lower-sin.f6491.5

                          \[\leadsto \color{blue}{\sin th} \]
                      5. Applied rewrites91.5%

                        \[\leadsto \color{blue}{\sin th} \]
                    10. Recombined 5 regimes into one program.
                    11. Final simplification65.3%

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

                    Alternative 8: 64.6% accurate, 0.3× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\ t_2 := \cos \left(2 \cdot ky\right)\\ t_3 := \sqrt{\frac{2}{\left(2 - t\_2\right) - \cos \left(2 \cdot kx\right)}} \cdot \left(th \cdot \sin ky\right)\\ \mathbf{if}\;t\_1 \leq -0.945:\\ \;\;\;\;\left(\frac{1}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\ \mathbf{elif}\;t\_1 \leq -0.1:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_1 \leq 10^{-23}:\\ \;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\ \mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                    (FPCore (kx ky th)
                     :precision binary64
                     (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
                            (t_2 (cos (* 2.0 ky)))
                            (t_3
                             (* (sqrt (/ 2.0 (- (- 2.0 t_2) (cos (* 2.0 kx))))) (* th (sin ky)))))
                       (if (<= t_1 -0.945)
                         (* (* (/ 1.0 (sqrt (* (- 1.0 t_2) 0.5))) (sin ky)) (sin th))
                         (if (<= t_1 -0.1)
                           t_3
                           (if (<= t_1 1e-23)
                             (* (/ (sin ky) (sin kx)) (sin th))
                             (if (<= t_1 0.9972580999534978) t_3 (sin th)))))))
                    double code(double kx, double ky, double th) {
                    	double t_1 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
                    	double t_2 = cos((2.0 * ky));
                    	double t_3 = sqrt((2.0 / ((2.0 - t_2) - cos((2.0 * kx))))) * (th * sin(ky));
                    	double tmp;
                    	if (t_1 <= -0.945) {
                    		tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th);
                    	} else if (t_1 <= -0.1) {
                    		tmp = t_3;
                    	} else if (t_1 <= 1e-23) {
                    		tmp = (sin(ky) / sin(kx)) * sin(th);
                    	} else if (t_1 <= 0.9972580999534978) {
                    		tmp = t_3;
                    	} else {
                    		tmp = sin(th);
                    	}
                    	return tmp;
                    }
                    
                    real(8) function code(kx, ky, th)
                        real(8), intent (in) :: kx
                        real(8), intent (in) :: ky
                        real(8), intent (in) :: th
                        real(8) :: t_1
                        real(8) :: t_2
                        real(8) :: t_3
                        real(8) :: tmp
                        t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
                        t_2 = cos((2.0d0 * ky))
                        t_3 = sqrt((2.0d0 / ((2.0d0 - t_2) - cos((2.0d0 * kx))))) * (th * sin(ky))
                        if (t_1 <= (-0.945d0)) then
                            tmp = ((1.0d0 / sqrt(((1.0d0 - t_2) * 0.5d0))) * sin(ky)) * sin(th)
                        else if (t_1 <= (-0.1d0)) then
                            tmp = t_3
                        else if (t_1 <= 1d-23) then
                            tmp = (sin(ky) / sin(kx)) * sin(th)
                        else if (t_1 <= 0.9972580999534978d0) then
                            tmp = t_3
                        else
                            tmp = sin(th)
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double kx, double ky, double th) {
                    	double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
                    	double t_2 = Math.cos((2.0 * ky));
                    	double t_3 = Math.sqrt((2.0 / ((2.0 - t_2) - Math.cos((2.0 * kx))))) * (th * Math.sin(ky));
                    	double tmp;
                    	if (t_1 <= -0.945) {
                    		tmp = ((1.0 / Math.sqrt(((1.0 - t_2) * 0.5))) * Math.sin(ky)) * Math.sin(th);
                    	} else if (t_1 <= -0.1) {
                    		tmp = t_3;
                    	} else if (t_1 <= 1e-23) {
                    		tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
                    	} else if (t_1 <= 0.9972580999534978) {
                    		tmp = t_3;
                    	} else {
                    		tmp = Math.sin(th);
                    	}
                    	return tmp;
                    }
                    
                    def code(kx, ky, th):
                    	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))
                    	t_2 = math.cos((2.0 * ky))
                    	t_3 = math.sqrt((2.0 / ((2.0 - t_2) - math.cos((2.0 * kx))))) * (th * math.sin(ky))
                    	tmp = 0
                    	if t_1 <= -0.945:
                    		tmp = ((1.0 / math.sqrt(((1.0 - t_2) * 0.5))) * math.sin(ky)) * math.sin(th)
                    	elif t_1 <= -0.1:
                    		tmp = t_3
                    	elif t_1 <= 1e-23:
                    		tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th)
                    	elif t_1 <= 0.9972580999534978:
                    		tmp = t_3
                    	else:
                    		tmp = math.sin(th)
                    	return tmp
                    
                    function code(kx, ky, th)
                    	t_1 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))))
                    	t_2 = cos(Float64(2.0 * ky))
                    	t_3 = Float64(sqrt(Float64(2.0 / Float64(Float64(2.0 - t_2) - cos(Float64(2.0 * kx))))) * Float64(th * sin(ky)))
                    	tmp = 0.0
                    	if (t_1 <= -0.945)
                    		tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(Float64(1.0 - t_2) * 0.5))) * sin(ky)) * sin(th));
                    	elseif (t_1 <= -0.1)
                    		tmp = t_3;
                    	elseif (t_1 <= 1e-23)
                    		tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th));
                    	elseif (t_1 <= 0.9972580999534978)
                    		tmp = t_3;
                    	else
                    		tmp = sin(th);
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(kx, ky, th)
                    	t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)));
                    	t_2 = cos((2.0 * ky));
                    	t_3 = sqrt((2.0 / ((2.0 - t_2) - cos((2.0 * kx))))) * (th * sin(ky));
                    	tmp = 0.0;
                    	if (t_1 <= -0.945)
                    		tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th);
                    	elseif (t_1 <= -0.1)
                    		tmp = t_3;
                    	elseif (t_1 <= 1e-23)
                    		tmp = (sin(ky) / sin(kx)) * sin(th);
                    	elseif (t_1 <= 0.9972580999534978)
                    		tmp = t_3;
                    	else
                    		tmp = sin(th);
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(2.0 / N[(N[(2.0 - t$95$2), $MachinePrecision] - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.945], N[(N[(N[(1.0 / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.1], t$95$3, If[LessEqual[t$95$1, 1e-23], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9972580999534978], t$95$3, N[Sin[th], $MachinePrecision]]]]]]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
                    t_2 := \cos \left(2 \cdot ky\right)\\
                    t_3 := \sqrt{\frac{2}{\left(2 - t\_2\right) - \cos \left(2 \cdot kx\right)}} \cdot \left(th \cdot \sin ky\right)\\
                    \mathbf{if}\;t\_1 \leq -0.945:\\
                    \;\;\;\;\left(\frac{1}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
                    
                    \mathbf{elif}\;t\_1 \leq -0.1:\\
                    \;\;\;\;t\_3\\
                    
                    \mathbf{elif}\;t\_1 \leq 10^{-23}:\\
                    \;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
                    
                    \mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\
                    \;\;\;\;t\_3\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\sin th\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 4 regimes
                    2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.944999999999999951

                      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. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      if -0.944999999999999951 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001 or 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779

                      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. lift-+.f64N/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                          \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                        7. 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 \]
                        8. 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 \]
                        9. 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 \]
                        10. lower-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 \]
                        11. 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 \]
                        12. cos-diffN/A

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                        13. cos-sin-sumN/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 \]
                        14. lower--.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 \]
                        15. 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 \]
                        16. lower-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 \]
                        17. lower-+.f6499.2

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

                          \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                        19. 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 \]
                        20. lift-sin.f64N/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 \]
                        21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{2 - \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)}} \]
                      9. Step-by-step derivation
                        1. Applied rewrites49.2%

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

                        if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999996e-24

                        1. Initial program 99.7%

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

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

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

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

                        if 0.99725809995349779 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                        1. Initial program 82.5%

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

                          \[\leadsto \color{blue}{\sin th} \]
                        4. Step-by-step derivation
                          1. lower-sin.f6491.5

                            \[\leadsto \color{blue}{\sin th} \]
                        5. Applied rewrites91.5%

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

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

                      Alternative 9: 54.1% accurate, 0.3× speedup?

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

                        1. Initial program 89.0%

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

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                            \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                          7. 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 \]
                          8. 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 \]
                          9. 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 \]
                          10. lower-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 \]
                          11. 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 \]
                          12. cos-diffN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                          13. cos-sin-sumN/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 \]
                          14. lower--.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 \]
                          15. 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 \]
                          16. lower-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 \]
                          17. lower-+.f6468.9

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

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                          19. 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 \]
                          20. lift-sin.f64N/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 \]
                          21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \frac{\sin ky}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \cdot \left(\mathsf{fma}\left(\color{blue}{th \cdot th}, \frac{-1}{6}, 1\right) \cdot th\right) \]
                          7. lower-*.f6433.0

                            \[\leadsto \frac{\sin ky}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}} \cdot \left(\mathsf{fma}\left(\color{blue}{th \cdot th}, -0.16666666666666666, 1\right) \cdot th\right) \]
                        10. Applied rewrites33.0%

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

                        if -1 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-257

                        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. lift-+.f64N/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                            \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                          7. 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 \]
                          8. 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 \]
                          9. 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 \]
                          10. lower-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 \]
                          11. 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 \]
                          12. cos-diffN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                          13. cos-sin-sumN/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 \]
                          14. lower--.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 \]
                          15. 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 \]
                          16. lower-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 \]
                          17. lower-+.f6499.5

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

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                          19. 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 \]
                          20. lift-sin.f64N/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 \]
                          21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        if 2e-257 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 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. Taylor expanded in ky around 0

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

                            \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                          2. lower-sin.f6460.6

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

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

                        if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                        1. Initial program 89.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. lower-sin.f6463.9

                            \[\leadsto \color{blue}{\sin th} \]
                        5. Applied rewrites63.9%

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

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

                      Alternative 10: 57.8% accurate, 0.5× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.1:\\ \;\;\;\;\frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky + ky\right)\right)}} \cdot \sin th\\ \mathbf{elif}\;t\_1 \leq 10^{-7}:\\ \;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                      (FPCore (kx ky th)
                       :precision binary64
                       (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0))))))
                         (if (<= t_1 -0.1)
                           (* (/ (sin ky) (sqrt (* 0.5 (- 1.0 (cos (+ ky ky)))))) (sin th))
                           (if (<= t_1 1e-7) (* (/ (sin ky) (sin kx)) (sin th)) (sin th)))))
                      double code(double kx, double ky, double th) {
                      	double t_1 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
                      	double tmp;
                      	if (t_1 <= -0.1) {
                      		tmp = (sin(ky) / sqrt((0.5 * (1.0 - cos((ky + ky)))))) * sin(th);
                      	} else if (t_1 <= 1e-7) {
                      		tmp = (sin(ky) / sin(kx)) * sin(th);
                      	} else {
                      		tmp = sin(th);
                      	}
                      	return tmp;
                      }
                      
                      real(8) function code(kx, ky, th)
                          real(8), intent (in) :: kx
                          real(8), intent (in) :: ky
                          real(8), intent (in) :: th
                          real(8) :: t_1
                          real(8) :: tmp
                          t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
                          if (t_1 <= (-0.1d0)) then
                              tmp = (sin(ky) / sqrt((0.5d0 * (1.0d0 - cos((ky + ky)))))) * sin(th)
                          else if (t_1 <= 1d-7) then
                              tmp = (sin(ky) / sin(kx)) * sin(th)
                          else
                              tmp = sin(th)
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double kx, double ky, double th) {
                      	double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
                      	double tmp;
                      	if (t_1 <= -0.1) {
                      		tmp = (Math.sin(ky) / Math.sqrt((0.5 * (1.0 - Math.cos((ky + ky)))))) * Math.sin(th);
                      	} else if (t_1 <= 1e-7) {
                      		tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
                      	} else {
                      		tmp = Math.sin(th);
                      	}
                      	return tmp;
                      }
                      
                      def code(kx, ky, th):
                      	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))
                      	tmp = 0
                      	if t_1 <= -0.1:
                      		tmp = (math.sin(ky) / math.sqrt((0.5 * (1.0 - math.cos((ky + ky)))))) * math.sin(th)
                      	elif t_1 <= 1e-7:
                      		tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th)
                      	else:
                      		tmp = math.sin(th)
                      	return tmp
                      
                      function code(kx, ky, th)
                      	t_1 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))))
                      	tmp = 0.0
                      	if (t_1 <= -0.1)
                      		tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(ky + ky)))))) * sin(th));
                      	elseif (t_1 <= 1e-7)
                      		tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th));
                      	else
                      		tmp = sin(th);
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(kx, ky, th)
                      	t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)));
                      	tmp = 0.0;
                      	if (t_1 <= -0.1)
                      		tmp = (sin(ky) / sqrt((0.5 * (1.0 - cos((ky + ky)))))) * sin(th);
                      	elseif (t_1 <= 1e-7)
                      		tmp = (sin(ky) / sin(kx)) * sin(th);
                      	else
                      		tmp = sin(th);
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.1], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 * N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
                      \mathbf{if}\;t\_1 \leq -0.1:\\
                      \;\;\;\;\frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky + ky\right)\right)}} \cdot \sin th\\
                      
                      \mathbf{elif}\;t\_1 \leq 10^{-7}:\\
                      \;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\sin th\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 3 regimes
                      2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

                        1. Initial program 93.9%

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

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                            \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                          7. 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 \]
                          8. 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 \]
                          9. 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 \]
                          10. lower-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 \]
                          11. 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 \]
                          12. cos-diffN/A

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                          13. cos-sin-sumN/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 \]
                          14. lower--.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 \]
                          15. 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 \]
                          16. lower-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 \]
                          17. lower-+.f6483.4

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

                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                          19. 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 \]
                          20. lift-sin.f64N/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 \]
                          21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}} \cdot \sin th \]
                        8. Step-by-step derivation
                          1. Applied rewrites46.2%

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

                          if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                          1. Initial program 99.7%

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

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

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

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

                          if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                          1. Initial program 89.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. lower-sin.f6463.9

                              \[\leadsto \color{blue}{\sin th} \]
                          5. Applied rewrites63.9%

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

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

                        Alternative 11: 50.5% accurate, 0.5× speedup?

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

                          1. Initial program 89.0%

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

                              \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                              \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                            7. 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 \]
                            8. 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 \]
                            9. 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 \]
                            10. lower-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 \]
                            11. 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 \]
                            12. cos-diffN/A

                              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                            13. cos-sin-sumN/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 \]
                            14. lower--.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 \]
                            15. 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 \]
                            16. lower-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 \]
                            17. lower-+.f6468.9

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

                              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                            19. 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 \]
                            20. lift-sin.f64N/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 \]
                            21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \frac{\sin ky}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \cdot \left(\mathsf{fma}\left(\color{blue}{th \cdot th}, \frac{-1}{6}, 1\right) \cdot th\right) \]
                            7. lower-*.f6433.0

                              \[\leadsto \frac{\sin ky}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}} \cdot \left(\mathsf{fma}\left(\color{blue}{th \cdot th}, -0.16666666666666666, 1\right) \cdot th\right) \]
                          10. Applied rewrites33.0%

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

                          if -1 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 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. Taylor expanded in ky around 0

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

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

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

                          if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                          1. Initial program 89.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. lower-sin.f6463.9

                              \[\leadsto \color{blue}{\sin th} \]
                          5. Applied rewrites63.9%

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

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

                        Alternative 12: 50.5% accurate, 0.5× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.1:\\ \;\;\;\;\sqrt{\frac{-1}{\cos \left(2 \cdot ky\right) - 1}} \cdot \left(\sqrt{2} \cdot \left(th \cdot \sin ky\right)\right)\\ \mathbf{elif}\;t\_1 \leq 10^{-7}:\\ \;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                        (FPCore (kx ky th)
                         :precision binary64
                         (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0))))))
                           (if (<= t_1 -0.1)
                             (*
                              (sqrt (/ -1.0 (- (cos (* 2.0 ky)) 1.0)))
                              (* (sqrt 2.0) (* th (sin ky))))
                             (if (<= t_1 1e-7) (* (/ ky (sin kx)) (sin th)) (sin th)))))
                        double code(double kx, double ky, double th) {
                        	double t_1 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
                        	double tmp;
                        	if (t_1 <= -0.1) {
                        		tmp = sqrt((-1.0 / (cos((2.0 * ky)) - 1.0))) * (sqrt(2.0) * (th * sin(ky)));
                        	} else if (t_1 <= 1e-7) {
                        		tmp = (ky / sin(kx)) * sin(th);
                        	} else {
                        		tmp = sin(th);
                        	}
                        	return tmp;
                        }
                        
                        real(8) function code(kx, ky, th)
                            real(8), intent (in) :: kx
                            real(8), intent (in) :: ky
                            real(8), intent (in) :: th
                            real(8) :: t_1
                            real(8) :: tmp
                            t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
                            if (t_1 <= (-0.1d0)) then
                                tmp = sqrt(((-1.0d0) / (cos((2.0d0 * ky)) - 1.0d0))) * (sqrt(2.0d0) * (th * sin(ky)))
                            else if (t_1 <= 1d-7) then
                                tmp = (ky / sin(kx)) * sin(th)
                            else
                                tmp = sin(th)
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double kx, double ky, double th) {
                        	double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
                        	double tmp;
                        	if (t_1 <= -0.1) {
                        		tmp = Math.sqrt((-1.0 / (Math.cos((2.0 * ky)) - 1.0))) * (Math.sqrt(2.0) * (th * Math.sin(ky)));
                        	} else if (t_1 <= 1e-7) {
                        		tmp = (ky / Math.sin(kx)) * Math.sin(th);
                        	} else {
                        		tmp = Math.sin(th);
                        	}
                        	return tmp;
                        }
                        
                        def code(kx, ky, th):
                        	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))
                        	tmp = 0
                        	if t_1 <= -0.1:
                        		tmp = math.sqrt((-1.0 / (math.cos((2.0 * ky)) - 1.0))) * (math.sqrt(2.0) * (th * math.sin(ky)))
                        	elif t_1 <= 1e-7:
                        		tmp = (ky / math.sin(kx)) * math.sin(th)
                        	else:
                        		tmp = math.sin(th)
                        	return tmp
                        
                        function code(kx, ky, th)
                        	t_1 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))))
                        	tmp = 0.0
                        	if (t_1 <= -0.1)
                        		tmp = Float64(sqrt(Float64(-1.0 / Float64(cos(Float64(2.0 * ky)) - 1.0))) * Float64(sqrt(2.0) * Float64(th * sin(ky))));
                        	elseif (t_1 <= 1e-7)
                        		tmp = Float64(Float64(ky / sin(kx)) * sin(th));
                        	else
                        		tmp = sin(th);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(kx, ky, th)
                        	t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)));
                        	tmp = 0.0;
                        	if (t_1 <= -0.1)
                        		tmp = sqrt((-1.0 / (cos((2.0 * ky)) - 1.0))) * (sqrt(2.0) * (th * sin(ky)));
                        	elseif (t_1 <= 1e-7)
                        		tmp = (ky / sin(kx)) * sin(th);
                        	else
                        		tmp = sin(th);
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.1], N[(N[Sqrt[N[(-1.0 / N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
                        \mathbf{if}\;t\_1 \leq -0.1:\\
                        \;\;\;\;\sqrt{\frac{-1}{\cos \left(2 \cdot ky\right) - 1}} \cdot \left(\sqrt{2} \cdot \left(th \cdot \sin ky\right)\right)\\
                        
                        \mathbf{elif}\;t\_1 \leq 10^{-7}:\\
                        \;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\sin th\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 3 regimes
                        2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

                          1. Initial program 93.9%

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

                              \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                              \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                            7. 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 \]
                            8. 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 \]
                            9. 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 \]
                            10. lower-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 \]
                            11. 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 \]
                            12. cos-diffN/A

                              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                            13. cos-sin-sumN/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 \]
                            14. lower--.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 \]
                            15. 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 \]
                            16. lower-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 \]
                            17. lower-+.f6483.4

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

                              \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                            19. 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 \]
                            20. lift-sin.f64N/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 \]
                            21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \left(\sin ky \cdot th\right) \cdot \left(\sqrt{2} \cdot \color{blue}{\sqrt{\frac{1}{2 - \left(\cos \left(2 \cdot kx\right) + \cos \left(2 \cdot ky\right)\right)}}}\right) \]
                          9. Step-by-step derivation
                            1. Applied rewrites43.0%

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

                              \[\leadsto \left(th \cdot \left(\sin ky \cdot \sqrt{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot ky\right)}}} \]
                            3. Step-by-step derivation
                              1. Applied rewrites23.5%

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

                              if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                              1. Initial program 99.7%

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

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

                                  \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                2. lower-sin.f6463.5

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

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

                              if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                              1. Initial program 89.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. lower-sin.f6463.9

                                  \[\leadsto \color{blue}{\sin th} \]
                              5. Applied rewrites63.9%

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

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

                            Alternative 13: 50.6% accurate, 0.5× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.1:\\ \;\;\;\;\sqrt{\frac{2}{1 - \cos \left(2 \cdot ky\right)}} \cdot \left(th \cdot \sin ky\right)\\ \mathbf{elif}\;t\_1 \leq 10^{-7}:\\ \;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                            (FPCore (kx ky th)
                             :precision binary64
                             (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0))))))
                               (if (<= t_1 -0.1)
                                 (* (sqrt (/ 2.0 (- 1.0 (cos (* 2.0 ky))))) (* th (sin ky)))
                                 (if (<= t_1 1e-7) (* (/ ky (sin kx)) (sin th)) (sin th)))))
                            double code(double kx, double ky, double th) {
                            	double t_1 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
                            	double tmp;
                            	if (t_1 <= -0.1) {
                            		tmp = sqrt((2.0 / (1.0 - cos((2.0 * ky))))) * (th * sin(ky));
                            	} else if (t_1 <= 1e-7) {
                            		tmp = (ky / sin(kx)) * sin(th);
                            	} else {
                            		tmp = sin(th);
                            	}
                            	return tmp;
                            }
                            
                            real(8) function code(kx, ky, th)
                                real(8), intent (in) :: kx
                                real(8), intent (in) :: ky
                                real(8), intent (in) :: th
                                real(8) :: t_1
                                real(8) :: tmp
                                t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
                                if (t_1 <= (-0.1d0)) then
                                    tmp = sqrt((2.0d0 / (1.0d0 - cos((2.0d0 * ky))))) * (th * sin(ky))
                                else if (t_1 <= 1d-7) then
                                    tmp = (ky / sin(kx)) * sin(th)
                                else
                                    tmp = sin(th)
                                end if
                                code = tmp
                            end function
                            
                            public static double code(double kx, double ky, double th) {
                            	double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
                            	double tmp;
                            	if (t_1 <= -0.1) {
                            		tmp = Math.sqrt((2.0 / (1.0 - Math.cos((2.0 * ky))))) * (th * Math.sin(ky));
                            	} else if (t_1 <= 1e-7) {
                            		tmp = (ky / Math.sin(kx)) * Math.sin(th);
                            	} else {
                            		tmp = Math.sin(th);
                            	}
                            	return tmp;
                            }
                            
                            def code(kx, ky, th):
                            	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))
                            	tmp = 0
                            	if t_1 <= -0.1:
                            		tmp = math.sqrt((2.0 / (1.0 - math.cos((2.0 * ky))))) * (th * math.sin(ky))
                            	elif t_1 <= 1e-7:
                            		tmp = (ky / math.sin(kx)) * math.sin(th)
                            	else:
                            		tmp = math.sin(th)
                            	return tmp
                            
                            function code(kx, ky, th)
                            	t_1 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))))
                            	tmp = 0.0
                            	if (t_1 <= -0.1)
                            		tmp = Float64(sqrt(Float64(2.0 / Float64(1.0 - cos(Float64(2.0 * ky))))) * Float64(th * sin(ky)));
                            	elseif (t_1 <= 1e-7)
                            		tmp = Float64(Float64(ky / sin(kx)) * sin(th));
                            	else
                            		tmp = sin(th);
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(kx, ky, th)
                            	t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)));
                            	tmp = 0.0;
                            	if (t_1 <= -0.1)
                            		tmp = sqrt((2.0 / (1.0 - cos((2.0 * ky))))) * (th * sin(ky));
                            	elseif (t_1 <= 1e-7)
                            		tmp = (ky / sin(kx)) * sin(th);
                            	else
                            		tmp = sin(th);
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.1], N[(N[Sqrt[N[(2.0 / N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
                            \mathbf{if}\;t\_1 \leq -0.1:\\
                            \;\;\;\;\sqrt{\frac{2}{1 - \cos \left(2 \cdot ky\right)}} \cdot \left(th \cdot \sin ky\right)\\
                            
                            \mathbf{elif}\;t\_1 \leq 10^{-7}:\\
                            \;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\sin th\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

                              1. Initial program 93.9%

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

                                  \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                                  \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                7. 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 \]
                                8. 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 \]
                                9. 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 \]
                                10. lower-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 \]
                                11. 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 \]
                                12. cos-diffN/A

                                  \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                13. cos-sin-sumN/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 \]
                                14. lower--.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 \]
                                15. 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 \]
                                16. lower-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 \]
                                17. lower-+.f6483.4

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

                                  \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                                19. 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 \]
                                20. lift-sin.f64N/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 \]
                                21. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{2}{1 - \cos \left(2 \cdot ky\right)}} \]
                              9. Step-by-step derivation
                                1. Applied rewrites23.5%

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

                                if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                1. Initial program 99.7%

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

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

                                    \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                  2. lower-sin.f6463.5

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

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

                                if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                1. Initial program 89.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. lower-sin.f6463.9

                                    \[\leadsto \color{blue}{\sin th} \]
                                5. Applied rewrites63.9%

                                  \[\leadsto \color{blue}{\sin th} \]
                              10. Recombined 3 regimes into one program.
                              11. Final simplification50.5%

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

                              Alternative 14: 44.2% accurate, 0.8× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                              (FPCore (kx ky th)
                               :precision binary64
                               (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-7)
                                 (* (/ ky (sin kx)) (sin th))
                                 (sin th)))
                              double code(double kx, double ky, double th) {
                              	double tmp;
                              	if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 1e-7) {
                              		tmp = (ky / sin(kx)) * sin(th);
                              	} else {
                              		tmp = sin(th);
                              	}
                              	return tmp;
                              }
                              
                              real(8) function code(kx, ky, th)
                                  real(8), intent (in) :: kx
                                  real(8), intent (in) :: ky
                                  real(8), intent (in) :: th
                                  real(8) :: tmp
                                  if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 1d-7) then
                                      tmp = (ky / sin(kx)) * sin(th)
                                  else
                                      tmp = sin(th)
                                  end if
                                  code = tmp
                              end function
                              
                              public static double code(double kx, double ky, double th) {
                              	double tmp;
                              	if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 1e-7) {
                              		tmp = (ky / Math.sin(kx)) * Math.sin(th);
                              	} else {
                              		tmp = Math.sin(th);
                              	}
                              	return tmp;
                              }
                              
                              def code(kx, ky, th):
                              	tmp = 0
                              	if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 1e-7:
                              		tmp = (ky / math.sin(kx)) * math.sin(th)
                              	else:
                              		tmp = math.sin(th)
                              	return tmp
                              
                              function code(kx, ky, th)
                              	tmp = 0.0
                              	if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7)
                              		tmp = Float64(Float64(ky / sin(kx)) * sin(th));
                              	else
                              		tmp = sin(th);
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(kx, ky, th)
                              	tmp = 0.0;
                              	if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7)
                              		tmp = (ky / sin(kx)) * sin(th);
                              	else
                              		tmp = sin(th);
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\
                              \;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\sin th\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                1. Initial program 96.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. lower-/.f64N/A

                                    \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                  2. lower-sin.f6435.1

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

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

                                if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                1. Initial program 89.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. lower-sin.f6463.9

                                    \[\leadsto \color{blue}{\sin th} \]
                                5. Applied rewrites63.9%

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

                                \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                              5. Add Preprocessing

                              Alternative 15: 44.2% accurate, 0.8× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\frac{\sin th}{\sin kx} \cdot ky\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                              (FPCore (kx ky th)
                               :precision binary64
                               (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-7)
                                 (* (/ (sin th) (sin kx)) ky)
                                 (sin th)))
                              double code(double kx, double ky, double th) {
                              	double tmp;
                              	if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 1e-7) {
                              		tmp = (sin(th) / sin(kx)) * ky;
                              	} else {
                              		tmp = sin(th);
                              	}
                              	return tmp;
                              }
                              
                              real(8) function code(kx, ky, th)
                                  real(8), intent (in) :: kx
                                  real(8), intent (in) :: ky
                                  real(8), intent (in) :: th
                                  real(8) :: tmp
                                  if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 1d-7) then
                                      tmp = (sin(th) / sin(kx)) * ky
                                  else
                                      tmp = sin(th)
                                  end if
                                  code = tmp
                              end function
                              
                              public static double code(double kx, double ky, double th) {
                              	double tmp;
                              	if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 1e-7) {
                              		tmp = (Math.sin(th) / Math.sin(kx)) * ky;
                              	} else {
                              		tmp = Math.sin(th);
                              	}
                              	return tmp;
                              }
                              
                              def code(kx, ky, th):
                              	tmp = 0
                              	if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 1e-7:
                              		tmp = (math.sin(th) / math.sin(kx)) * ky
                              	else:
                              		tmp = math.sin(th)
                              	return tmp
                              
                              function code(kx, ky, th)
                              	tmp = 0.0
                              	if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7)
                              		tmp = Float64(Float64(sin(th) / sin(kx)) * ky);
                              	else
                              		tmp = sin(th);
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(kx, ky, th)
                              	tmp = 0.0;
                              	if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7)
                              		tmp = (sin(th) / sin(kx)) * ky;
                              	else
                              		tmp = sin(th);
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * ky), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\
                              \;\;\;\;\frac{\sin th}{\sin kx} \cdot ky\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\sin th\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

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

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

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

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

                                  \[\leadsto \frac{\sin th}{\sin kx} \cdot ky \]
                                7. Step-by-step derivation
                                  1. Applied rewrites35.1%

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

                                  if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                  1. Initial program 89.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. lower-sin.f6463.9

                                      \[\leadsto \color{blue}{\sin th} \]
                                  5. Applied rewrites63.9%

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

                                  \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\frac{\sin th}{\sin kx} \cdot ky\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                10. Add Preprocessing

                                Alternative 16: 34.6% accurate, 1.0× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\frac{\sin th \cdot ky}{\mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                (FPCore (kx ky th)
                                 :precision binary64
                                 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-7)
                                   (/ (* (sin th) ky) (* (fma -0.16666666666666666 (* kx kx) 1.0) kx))
                                   (sin th)))
                                double code(double kx, double ky, double th) {
                                	double tmp;
                                	if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 1e-7) {
                                		tmp = (sin(th) * ky) / (fma(-0.16666666666666666, (kx * kx), 1.0) * kx);
                                	} else {
                                		tmp = sin(th);
                                	}
                                	return tmp;
                                }
                                
                                function code(kx, ky, th)
                                	tmp = 0.0
                                	if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7)
                                		tmp = Float64(Float64(sin(th) * ky) / Float64(fma(-0.16666666666666666, Float64(kx * kx), 1.0) * kx));
                                	else
                                		tmp = sin(th);
                                	end
                                	return tmp
                                end
                                
                                code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[(N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\
                                \;\;\;\;\frac{\sin th \cdot ky}{\mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx}\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\sin th\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                  1. Initial program 96.9%

                                    \[\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. lower-sin.f643.7

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

                                    \[\leadsto \color{blue}{\sin th} \]
                                  6. Taylor expanded in ky around 0

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

                                      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sin kx}} \]
                                    2. lower-*.f64N/A

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

                                      \[\leadsto \frac{ky \cdot \color{blue}{\sin th}}{\sin kx} \]
                                    4. lower-sin.f6434.6

                                      \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sin kx}} \]
                                  8. Applied rewrites34.6%

                                    \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sin kx}} \]
                                  9. Taylor expanded in kx around 0

                                    \[\leadsto \frac{ky \cdot \sin th}{kx \cdot \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}} \]
                                  10. Step-by-step derivation
                                    1. Applied rewrites23.7%

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

                                    if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                    1. Initial program 89.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. lower-sin.f6463.9

                                        \[\leadsto \color{blue}{\sin th} \]
                                    5. Applied rewrites63.9%

                                      \[\leadsto \color{blue}{\sin th} \]
                                  11. Recombined 2 regimes into one program.
                                  12. Final simplification36.6%

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

                                  Alternative 17: 14.8% accurate, 1.0× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \sin th \leq 10^{-323}:\\ \;\;\;\;\left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;1 \cdot th\\ \end{array} \end{array} \]
                                  (FPCore (kx ky th)
                                   :precision binary64
                                   (if (<=
                                        (*
                                         (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0))))
                                         (sin th))
                                        1e-323)
                                     (* (* (* th th) th) -0.16666666666666666)
                                     (* 1.0 th)))
                                  double code(double kx, double ky, double th) {
                                  	double tmp;
                                  	if (((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) * sin(th)) <= 1e-323) {
                                  		tmp = ((th * th) * th) * -0.16666666666666666;
                                  	} else {
                                  		tmp = 1.0 * th;
                                  	}
                                  	return tmp;
                                  }
                                  
                                  real(8) function code(kx, ky, th)
                                      real(8), intent (in) :: kx
                                      real(8), intent (in) :: ky
                                      real(8), intent (in) :: th
                                      real(8) :: tmp
                                      if (((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) * sin(th)) <= 1d-323) then
                                          tmp = ((th * th) * th) * (-0.16666666666666666d0)
                                      else
                                          tmp = 1.0d0 * th
                                      end if
                                      code = tmp
                                  end function
                                  
                                  public static double code(double kx, double ky, double th) {
                                  	double tmp;
                                  	if (((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) * Math.sin(th)) <= 1e-323) {
                                  		tmp = ((th * th) * th) * -0.16666666666666666;
                                  	} else {
                                  		tmp = 1.0 * th;
                                  	}
                                  	return tmp;
                                  }
                                  
                                  def code(kx, ky, th):
                                  	tmp = 0
                                  	if ((math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) * math.sin(th)) <= 1e-323:
                                  		tmp = ((th * th) * th) * -0.16666666666666666
                                  	else:
                                  		tmp = 1.0 * th
                                  	return tmp
                                  
                                  function code(kx, ky, th)
                                  	tmp = 0.0
                                  	if (Float64(Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) * sin(th)) <= 1e-323)
                                  		tmp = Float64(Float64(Float64(th * th) * th) * -0.16666666666666666);
                                  	else
                                  		tmp = Float64(1.0 * th);
                                  	end
                                  	return tmp
                                  end
                                  
                                  function tmp_2 = code(kx, ky, th)
                                  	tmp = 0.0;
                                  	if (((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) * sin(th)) <= 1e-323)
                                  		tmp = ((th * th) * th) * -0.16666666666666666;
                                  	else
                                  		tmp = 1.0 * th;
                                  	end
                                  	tmp_2 = tmp;
                                  end
                                  
                                  code[kx_, ky_, th_] := If[LessEqual[N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], 1e-323], N[(N[(N[(th * th), $MachinePrecision] * th), $MachinePrecision] * -0.16666666666666666), $MachinePrecision], N[(1.0 * th), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \sin th \leq 10^{-323}:\\
                                  \;\;\;\;\left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;1 \cdot th\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if (*.f64 (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) (sin.f64 th)) < 9.88131e-324

                                    1. Initial program 93.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. lower-sin.f6420.8

                                        \[\leadsto \color{blue}{\sin th} \]
                                    5. Applied rewrites20.8%

                                      \[\leadsto \color{blue}{\sin th} \]
                                    6. Taylor expanded in th around 0

                                      \[\leadsto th \cdot \color{blue}{\left(1 + \frac{-1}{6} \cdot {th}^{2}\right)} \]
                                    7. Step-by-step derivation
                                      1. Applied rewrites9.9%

                                        \[\leadsto \mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot \color{blue}{th} \]
                                      2. Taylor expanded in th around inf

                                        \[\leadsto \frac{-1}{6} \cdot {th}^{\color{blue}{3}} \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites19.1%

                                          \[\leadsto \left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666 \]

                                        if 9.88131e-324 < (*.f64 (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) (sin.f64 th))

                                        1. Initial program 95.6%

                                          \[\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. lower-sin.f6426.6

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

                                          \[\leadsto \color{blue}{\sin th} \]
                                        6. Taylor expanded in th around 0

                                          \[\leadsto th \cdot \color{blue}{\left(1 + \frac{-1}{6} \cdot {th}^{2}\right)} \]
                                        7. Step-by-step derivation
                                          1. Applied rewrites15.5%

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

                                            \[\leadsto 1 \cdot th \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites15.4%

                                              \[\leadsto 1 \cdot th \]
                                          4. Recombined 2 regimes into one program.
                                          5. Final simplification17.7%

                                            \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \sin th \leq 10^{-323}:\\ \;\;\;\;\left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;1 \cdot th\\ \end{array} \]
                                          6. Add Preprocessing

                                          Alternative 18: 34.6% accurate, 1.0× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\frac{\sin th \cdot ky}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                          (FPCore (kx ky th)
                                           :precision binary64
                                           (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-7)
                                             (/ (* (sin th) ky) kx)
                                             (sin th)))
                                          double code(double kx, double ky, double th) {
                                          	double tmp;
                                          	if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 1e-7) {
                                          		tmp = (sin(th) * ky) / kx;
                                          	} else {
                                          		tmp = sin(th);
                                          	}
                                          	return tmp;
                                          }
                                          
                                          real(8) function code(kx, ky, th)
                                              real(8), intent (in) :: kx
                                              real(8), intent (in) :: ky
                                              real(8), intent (in) :: th
                                              real(8) :: tmp
                                              if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 1d-7) then
                                                  tmp = (sin(th) * ky) / kx
                                              else
                                                  tmp = sin(th)
                                              end if
                                              code = tmp
                                          end function
                                          
                                          public static double code(double kx, double ky, double th) {
                                          	double tmp;
                                          	if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 1e-7) {
                                          		tmp = (Math.sin(th) * ky) / kx;
                                          	} else {
                                          		tmp = Math.sin(th);
                                          	}
                                          	return tmp;
                                          }
                                          
                                          def code(kx, ky, th):
                                          	tmp = 0
                                          	if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 1e-7:
                                          		tmp = (math.sin(th) * ky) / kx
                                          	else:
                                          		tmp = math.sin(th)
                                          	return tmp
                                          
                                          function code(kx, ky, th)
                                          	tmp = 0.0
                                          	if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7)
                                          		tmp = Float64(Float64(sin(th) * ky) / kx);
                                          	else
                                          		tmp = sin(th);
                                          	end
                                          	return tmp
                                          end
                                          
                                          function tmp_2 = code(kx, ky, th)
                                          	tmp = 0.0;
                                          	if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7)
                                          		tmp = (sin(th) * ky) / kx;
                                          	else
                                          		tmp = sin(th);
                                          	end
                                          	tmp_2 = tmp;
                                          end
                                          
                                          code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / kx), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\
                                          \;\;\;\;\frac{\sin th \cdot ky}{kx}\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\sin th\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                            1. Initial program 96.9%

                                              \[\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. lower-sin.f643.7

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

                                              \[\leadsto \color{blue}{\sin th} \]
                                            6. Taylor expanded in ky around 0

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

                                                \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sin kx}} \]
                                              2. lower-*.f64N/A

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

                                                \[\leadsto \frac{ky \cdot \color{blue}{\sin th}}{\sin kx} \]
                                              4. lower-sin.f6434.6

                                                \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sin kx}} \]
                                            8. Applied rewrites34.6%

                                              \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sin kx}} \]
                                            9. Taylor expanded in kx around 0

                                              \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{kx}} \]
                                            10. Step-by-step derivation
                                              1. Applied rewrites24.1%

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

                                              if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                              1. Initial program 89.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. lower-sin.f6463.9

                                                  \[\leadsto \color{blue}{\sin th} \]
                                              5. Applied rewrites63.9%

                                                \[\leadsto \color{blue}{\sin th} \]
                                            11. Recombined 2 regimes into one program.
                                            12. Final simplification36.8%

                                              \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\frac{\sin th \cdot ky}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                            13. Add Preprocessing

                                            Alternative 19: 35.3% accurate, 1.0× speedup?

                                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\frac{ky}{\sin kx} \cdot th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                            (FPCore (kx ky th)
                                             :precision binary64
                                             (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-7)
                                               (* (/ ky (sin kx)) th)
                                               (sin th)))
                                            double code(double kx, double ky, double th) {
                                            	double tmp;
                                            	if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 1e-7) {
                                            		tmp = (ky / sin(kx)) * th;
                                            	} else {
                                            		tmp = sin(th);
                                            	}
                                            	return tmp;
                                            }
                                            
                                            real(8) function code(kx, ky, th)
                                                real(8), intent (in) :: kx
                                                real(8), intent (in) :: ky
                                                real(8), intent (in) :: th
                                                real(8) :: tmp
                                                if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 1d-7) then
                                                    tmp = (ky / sin(kx)) * th
                                                else
                                                    tmp = sin(th)
                                                end if
                                                code = tmp
                                            end function
                                            
                                            public static double code(double kx, double ky, double th) {
                                            	double tmp;
                                            	if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 1e-7) {
                                            		tmp = (ky / Math.sin(kx)) * th;
                                            	} else {
                                            		tmp = Math.sin(th);
                                            	}
                                            	return tmp;
                                            }
                                            
                                            def code(kx, ky, th):
                                            	tmp = 0
                                            	if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 1e-7:
                                            		tmp = (ky / math.sin(kx)) * th
                                            	else:
                                            		tmp = math.sin(th)
                                            	return tmp
                                            
                                            function code(kx, ky, th)
                                            	tmp = 0.0
                                            	if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7)
                                            		tmp = Float64(Float64(ky / sin(kx)) * th);
                                            	else
                                            		tmp = sin(th);
                                            	end
                                            	return tmp
                                            end
                                            
                                            function tmp_2 = code(kx, ky, th)
                                            	tmp = 0.0;
                                            	if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7)
                                            		tmp = (ky / sin(kx)) * th;
                                            	else
                                            		tmp = sin(th);
                                            	end
                                            	tmp_2 = tmp;
                                            end
                                            
                                            code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \begin{array}{l}
                                            \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\
                                            \;\;\;\;\frac{ky}{\sin kx} \cdot th\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;\sin th\\
                                            
                                            
                                            \end{array}
                                            \end{array}
                                            
                                            Derivation
                                            1. Split input into 2 regimes
                                            2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                              1. Initial program 96.9%

                                                \[\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. lower-sin.f643.7

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

                                                \[\leadsto \color{blue}{\sin th} \]
                                              6. Taylor expanded in ky around 0

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

                                                  \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sin kx}} \]
                                                2. lower-*.f64N/A

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

                                                  \[\leadsto \frac{ky \cdot \color{blue}{\sin th}}{\sin kx} \]
                                                4. lower-sin.f6434.6

                                                  \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sin kx}} \]
                                              8. Applied rewrites34.6%

                                                \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sin kx}} \]
                                              9. Taylor expanded in th around 0

                                                \[\leadsto \frac{ky \cdot th}{\color{blue}{\sin kx}} \]
                                              10. Step-by-step derivation
                                                1. Applied rewrites24.2%

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

                                                if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                                1. Initial program 89.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. lower-sin.f6463.9

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                5. Applied rewrites63.9%

                                                  \[\leadsto \color{blue}{\sin th} \]
                                              11. Recombined 2 regimes into one program.
                                              12. Final simplification36.9%

                                                \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\frac{ky}{\sin kx} \cdot th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                              13. Add Preprocessing

                                              Alternative 20: 30.4% accurate, 1.0× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 9.5 \cdot 10^{-68}:\\ \;\;\;\;\left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                              (FPCore (kx ky th)
                                               :precision binary64
                                               (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 9.5e-68)
                                                 (* (* (* th th) th) -0.16666666666666666)
                                                 (sin th)))
                                              double code(double kx, double ky, double th) {
                                              	double tmp;
                                              	if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 9.5e-68) {
                                              		tmp = ((th * th) * th) * -0.16666666666666666;
                                              	} else {
                                              		tmp = sin(th);
                                              	}
                                              	return tmp;
                                              }
                                              
                                              real(8) function code(kx, ky, th)
                                                  real(8), intent (in) :: kx
                                                  real(8), intent (in) :: ky
                                                  real(8), intent (in) :: th
                                                  real(8) :: tmp
                                                  if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 9.5d-68) then
                                                      tmp = ((th * th) * th) * (-0.16666666666666666d0)
                                                  else
                                                      tmp = sin(th)
                                                  end if
                                                  code = tmp
                                              end function
                                              
                                              public static double code(double kx, double ky, double th) {
                                              	double tmp;
                                              	if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 9.5e-68) {
                                              		tmp = ((th * th) * th) * -0.16666666666666666;
                                              	} else {
                                              		tmp = Math.sin(th);
                                              	}
                                              	return tmp;
                                              }
                                              
                                              def code(kx, ky, th):
                                              	tmp = 0
                                              	if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 9.5e-68:
                                              		tmp = ((th * th) * th) * -0.16666666666666666
                                              	else:
                                              		tmp = math.sin(th)
                                              	return tmp
                                              
                                              function code(kx, ky, th)
                                              	tmp = 0.0
                                              	if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 9.5e-68)
                                              		tmp = Float64(Float64(Float64(th * th) * th) * -0.16666666666666666);
                                              	else
                                              		tmp = sin(th);
                                              	end
                                              	return tmp
                                              end
                                              
                                              function tmp_2 = code(kx, ky, th)
                                              	tmp = 0.0;
                                              	if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 9.5e-68)
                                              		tmp = ((th * th) * th) * -0.16666666666666666;
                                              	else
                                              		tmp = sin(th);
                                              	end
                                              	tmp_2 = tmp;
                                              end
                                              
                                              code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 9.5e-68], N[(N[(N[(th * th), $MachinePrecision] * th), $MachinePrecision] * -0.16666666666666666), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 9.5 \cdot 10^{-68}:\\
                                              \;\;\;\;\left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\sin th\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 2 regimes
                                              2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.4999999999999997e-68

                                                1. Initial program 96.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. lower-sin.f643.5

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                5. Applied rewrites3.5%

                                                  \[\leadsto \color{blue}{\sin th} \]
                                                6. Taylor expanded in th around 0

                                                  \[\leadsto th \cdot \color{blue}{\left(1 + \frac{-1}{6} \cdot {th}^{2}\right)} \]
                                                7. Step-by-step derivation
                                                  1. Applied rewrites3.4%

                                                    \[\leadsto \mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot \color{blue}{th} \]
                                                  2. Taylor expanded in th around inf

                                                    \[\leadsto \frac{-1}{6} \cdot {th}^{\color{blue}{3}} \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites18.2%

                                                      \[\leadsto \left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666 \]

                                                    if 9.4999999999999997e-68 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                                    1. Initial program 90.0%

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

                                                      \[\leadsto \color{blue}{\sin th} \]
                                                    4. Step-by-step derivation
                                                      1. lower-sin.f6458.9

                                                        \[\leadsto \color{blue}{\sin th} \]
                                                    5. Applied rewrites58.9%

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

                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 9.5 \cdot 10^{-68}:\\ \;\;\;\;\left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                                  6. Add Preprocessing

                                                  Alternative 21: 75.7% accurate, 1.4× speedup?

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

                                                    1. Initial program 92.8%

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

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

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

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

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

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

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

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                                                      8. lower-hypot.f6499.7

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

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

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

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

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

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

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

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

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

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

                                                    if 0.0030000000000000001 < 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. lift-+.f64N/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\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. lift-pow.f64N/A

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

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

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

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                                      7. 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 \]
                                                      8. 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 \]
                                                      9. 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 \]
                                                      10. lower-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 \]
                                                      11. 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 \]
                                                      12. cos-diffN/A

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
                                                      13. cos-sin-sumN/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 \]
                                                      14. lower--.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 \]
                                                      15. 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 \]
                                                      16. lower-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 \]
                                                      17. lower-+.f6499.2

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

                                                        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
                                                      19. 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 \]
                                                      20. lift-sin.f64N/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 \]
                                                      21. lift-sin.f64N/A

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

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

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

                                                  Alternative 22: 13.0% accurate, 105.3× speedup?

                                                  \[\begin{array}{l} \\ 1 \cdot th \end{array} \]
                                                  (FPCore (kx ky th) :precision binary64 (* 1.0 th))
                                                  double code(double kx, double ky, double th) {
                                                  	return 1.0 * th;
                                                  }
                                                  
                                                  real(8) function code(kx, ky, th)
                                                      real(8), intent (in) :: kx
                                                      real(8), intent (in) :: ky
                                                      real(8), intent (in) :: th
                                                      code = 1.0d0 * th
                                                  end function
                                                  
                                                  public static double code(double kx, double ky, double th) {
                                                  	return 1.0 * th;
                                                  }
                                                  
                                                  def code(kx, ky, th):
                                                  	return 1.0 * th
                                                  
                                                  function code(kx, ky, th)
                                                  	return Float64(1.0 * th)
                                                  end
                                                  
                                                  function tmp = code(kx, ky, th)
                                                  	tmp = 1.0 * th;
                                                  end
                                                  
                                                  code[kx_, ky_, th_] := N[(1.0 * th), $MachinePrecision]
                                                  
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  1 \cdot th
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Initial program 94.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. lower-sin.f6423.0

                                                      \[\leadsto \color{blue}{\sin th} \]
                                                  5. Applied rewrites23.0%

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                  6. Taylor expanded in th around 0

                                                    \[\leadsto th \cdot \color{blue}{\left(1 + \frac{-1}{6} \cdot {th}^{2}\right)} \]
                                                  7. Step-by-step derivation
                                                    1. Applied rewrites12.0%

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

                                                      \[\leadsto 1 \cdot th \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites12.2%

                                                        \[\leadsto 1 \cdot th \]
                                                      2. Add Preprocessing

                                                      Reproduce

                                                      ?
                                                      herbie shell --seed 2024240 
                                                      (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)))