Toniolo and Linder, Equation (3b), real

Percentage Accurate: 93.9% → 99.7%
Time: 11.9s
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: 93.9% 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 96.2%

    \[\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: 83.2% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_1 := {\sin ky}^{2}\\
t_2 := \frac{\sin ky}{\sqrt{t\_1 + {\sin kx}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.98:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{t\_1}}\\

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

\mathbf{elif}\;t\_2 \leq 0.05:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\

\mathbf{elif}\;t\_2 \leq 0.99:\\
\;\;\;\;\frac{\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}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx\right)} \cdot \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.97999999999999998

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
      7. lower-/.f6488.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -0.97999999999999998 < (/.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))))) < -1e-3

      1. Initial program 99.3%

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
        7. lower-/.f6499.3

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
      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. *-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. 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)}}} \]
        7. associate-/r*N/A

          \[\leadsto \left(\sin ky \cdot th\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)}}} \]
        8. metadata-evalN/A

          \[\leadsto \left(\sin ky \cdot th\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)}} \]
        9. lower-/.f64N/A

          \[\leadsto \left(\sin ky \cdot th\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)}}} \]
        10. +-commutativeN/A

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

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

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

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

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

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

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

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

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

        \[\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-*.f6498.2

          \[\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 rewrites98.2%

        \[\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 \]
      8. Taylor expanded in ky around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{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)}}{\frac{\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)}}{\sin ky}} \]
      6. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \frac{\color{blue}{\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}}{\frac{\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)}}{\sin ky}} \]
        2. lower-*.f64N/A

          \[\leadsto \frac{\color{blue}{\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}}{\frac{\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)}}{\sin ky}} \]
      7. Applied rewrites55.1%

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

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

      1. Initial program 95.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.f64100.0

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx}\right)} \cdot \sin th \]
    11. Recombined 5 regimes into one program.
    12. Final simplification81.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.98:\\ \;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{{\sin ky}^{2}}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.001:\\ \;\;\;\;\left(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(\cos \left(2 \cdot ky\right) - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.05:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot 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.99:\\ \;\;\;\;\frac{\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}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx\right)} \cdot \sin th\\ \end{array} \]
    13. Add Preprocessing

    Alternative 3: 82.1% accurate, 0.3× speedup?

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
        7. lower-/.f6488.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -0.97999999999999998 < (/.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))))) < -1e-3

        1. Initial program 99.3%

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
          7. lower-/.f6499.3

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
        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. *-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. 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)}}} \]
          7. associate-/r*N/A

            \[\leadsto \left(\sin ky \cdot th\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)}}} \]
          8. metadata-evalN/A

            \[\leadsto \left(\sin ky \cdot th\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)}} \]
          9. lower-/.f64N/A

            \[\leadsto \left(\sin ky \cdot th\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)}}} \]
          10. +-commutativeN/A

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

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

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

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

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

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

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

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

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

          \[\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-*.f6498.2

            \[\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 rewrites98.2%

          \[\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 \]
        8. Taylor expanded in ky around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{th \cdot \left(1 + {th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right)\right)}}{\frac{\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)}}{\sin ky}} \]
        6. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\left(1 + {th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right)\right) \cdot th}}{\frac{\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)}}{\sin ky}} \]
          2. lower-*.f64N/A

            \[\leadsto \frac{\color{blue}{\left(1 + {th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right)\right) \cdot th}}{\frac{\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)}}{\sin ky}} \]
          3. +-commutativeN/A

            \[\leadsto \frac{\color{blue}{\left({th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right) + 1\right)} \cdot th}{\frac{\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)}}{\sin ky}} \]
          4. *-commutativeN/A

            \[\leadsto \frac{\left(\color{blue}{\left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right) \cdot {th}^{2}} + 1\right) \cdot th}{\frac{\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)}}{\sin ky}} \]
          5. lower-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}, {th}^{2}, 1\right)} \cdot th}{\frac{\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)}}{\sin ky}} \]
          6. sub-negN/A

            \[\leadsto \frac{\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}{\frac{\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)}}{\sin ky}} \]
          7. *-commutativeN/A

            \[\leadsto \frac{\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}{\frac{\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)}}{\sin ky}} \]
          8. metadata-evalN/A

            \[\leadsto \frac{\mathsf{fma}\left({th}^{2} \cdot \frac{1}{120} + \color{blue}{\frac{-1}{6}}, {th}^{2}, 1\right) \cdot th}{\frac{\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)}}{\sin ky}} \]
          9. lower-fma.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left({th}^{2}, \frac{1}{120}, \frac{-1}{6}\right)}, {th}^{2}, 1\right) \cdot th}{\frac{\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)}}{\sin ky}} \]
          10. unpow2N/A

            \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{th \cdot th}, \frac{1}{120}, \frac{-1}{6}\right), {th}^{2}, 1\right) \cdot th}{\frac{\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)}}{\sin ky}} \]
          11. lower-*.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{th \cdot th}, \frac{1}{120}, \frac{-1}{6}\right), {th}^{2}, 1\right) \cdot th}{\frac{\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)}}{\sin ky}} \]
          12. unpow2N/A

            \[\leadsto \frac{\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}{\frac{\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)}}{\sin ky}} \]
          13. lower-*.f6455.6

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

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

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

        1. Initial program 95.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 \frac{\sin ky}{\color{blue}{\sin ky + \frac{1}{2} \cdot \frac{{kx}^{2}}{\sin ky}}} \cdot \sin th \]
        4. Step-by-step derivation
          1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
          12. lower-sin.f64100.0

            \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{\sin ky}, \color{blue}{\sin ky}\right)} \cdot \sin th \]
        5. Applied rewrites100.0%

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

          \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
        7. Step-by-step derivation
          1. Applied rewrites100.0%

            \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
        8. Recombined 5 regimes into one program.
        9. Final simplification81.8%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.98:\\ \;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{{\sin ky}^{2}}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.001:\\ \;\;\;\;\left(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(\cos \left(2 \cdot ky\right) - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.05:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot 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.9999996186923419:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, 0.008333333333333333, -0.16666666666666666\right), th \cdot th, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \sin th\\ \end{array} \]
        10. Add Preprocessing

        Alternative 4: 78.2% 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)\\ \mathbf{if}\;t\_1 \leq -0.98:\\ \;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}}\\ \mathbf{elif}\;t\_1 \leq -0.001:\\ \;\;\;\;\left(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(t\_2 - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\ \mathbf{elif}\;t\_1 \leq 0.05:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\ \mathbf{elif}\;t\_1 \leq 0.9999996186923419:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, 0.008333333333333333, -0.16666666666666666\right), th \cdot th, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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))))
           (if (<= t_1 -0.98)
             (/ (* (sin th) (sin ky)) (sqrt (* (- 1.0 t_2) 0.5)))
             (if (<= t_1 -0.001)
               (*
                (* th (sin ky))
                (sqrt (/ 2.0 (- 1.0 (- t_2 (- 1.0 (cos (* 2.0 kx))))))))
               (if (<= t_1 0.05)
                 (*
                  (/
                   (*
                    (fma
                     (fma (* ky ky) 0.008333333333333333 -0.16666666666666666)
                     (* ky ky)
                     1.0)
                    ky)
                   (hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
                  (sin th))
                 (if (<= t_1 0.9999996186923419)
                   (/
                    (*
                     (fma
                      (fma (* th th) 0.008333333333333333 -0.16666666666666666)
                      (* th th)
                      1.0)
                     th)
                    (/
                     (sqrt
                      (fma
                       (- 1.0 (cos (+ ky ky)))
                       0.5
                       (* (- 1.0 (cos (+ kx kx))) 0.5)))
                     (sin ky)))
                   (* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (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 tmp;
        	if (t_1 <= -0.98) {
        		tmp = (sin(th) * sin(ky)) / sqrt(((1.0 - t_2) * 0.5));
        	} else if (t_1 <= -0.001) {
        		tmp = (th * sin(ky)) * sqrt((2.0 / (1.0 - (t_2 - (1.0 - cos((2.0 * kx)))))));
        	} else if (t_1 <= 0.05) {
        		tmp = ((fma(fma((ky * ky), 0.008333333333333333, -0.16666666666666666), (ky * ky), 1.0) * ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
        	} else if (t_1 <= 0.9999996186923419) {
        		tmp = (fma(fma((th * th), 0.008333333333333333, -0.16666666666666666), (th * th), 1.0) * th) / (sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((1.0 - cos((kx + kx))) * 0.5))) / sin(ky));
        	} else {
        		tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * 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))
        	tmp = 0.0
        	if (t_1 <= -0.98)
        		tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(Float64(1.0 - t_2) * 0.5)));
        	elseif (t_1 <= -0.001)
        		tmp = Float64(Float64(th * sin(ky)) * sqrt(Float64(2.0 / Float64(1.0 - Float64(t_2 - Float64(1.0 - cos(Float64(2.0 * kx))))))));
        	elseif (t_1 <= 0.05)
        		tmp = Float64(Float64(Float64(fma(fma(Float64(ky * ky), 0.008333333333333333, -0.16666666666666666), Float64(ky * ky), 1.0) * ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th));
        	elseif (t_1 <= 0.9999996186923419)
        		tmp = Float64(Float64(fma(fma(Float64(th * th), 0.008333333333333333, -0.16666666666666666), Float64(th * th), 1.0) * th) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) / sin(ky)));
        	else
        		tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * 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[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.98], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.001], N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[(t$95$2 - N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.05], N[(N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * 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.9999996186923419], N[(N[(N[(N[(N[(th * th), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(th * th), $MachinePrecision] + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(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] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $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)\\
        \mathbf{if}\;t\_1 \leq -0.98:\\
        \;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}}\\
        
        \mathbf{elif}\;t\_1 \leq -0.001:\\
        \;\;\;\;\left(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(t\_2 - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\
        
        \mathbf{elif}\;t\_1 \leq 0.05:\\
        \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
        
        \mathbf{elif}\;t\_1 \leq 0.9999996186923419:\\
        \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, 0.008333333333333333, -0.16666666666666666\right), th \cdot th, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.97999999999999998

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
            7. lower-/.f6488.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -0.97999999999999998 < (/.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))))) < -1e-3

          1. Initial program 99.3%

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
            7. lower-/.f6499.3

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
          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. *-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. 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)}}} \]
            7. associate-/r*N/A

              \[\leadsto \left(\sin ky \cdot th\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)}}} \]
            8. metadata-evalN/A

              \[\leadsto \left(\sin ky \cdot th\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)}} \]
            9. lower-/.f64N/A

              \[\leadsto \left(\sin ky \cdot th\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)}}} \]
            10. +-commutativeN/A

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

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

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

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

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

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

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

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

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

            \[\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-*.f6498.2

              \[\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 rewrites98.2%

            \[\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 \]
          8. Taylor expanded in ky around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{th \cdot \left(1 + {th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right)\right)}}{\frac{\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)}}{\sin ky}} \]
          6. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \frac{\color{blue}{\left(1 + {th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right)\right) \cdot th}}{\frac{\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)}}{\sin ky}} \]
            2. lower-*.f64N/A

              \[\leadsto \frac{\color{blue}{\left(1 + {th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right)\right) \cdot th}}{\frac{\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)}}{\sin ky}} \]
            3. +-commutativeN/A

              \[\leadsto \frac{\color{blue}{\left({th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right) + 1\right)} \cdot th}{\frac{\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)}}{\sin ky}} \]
            4. *-commutativeN/A

              \[\leadsto \frac{\left(\color{blue}{\left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right) \cdot {th}^{2}} + 1\right) \cdot th}{\frac{\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)}}{\sin ky}} \]
            5. lower-fma.f64N/A

              \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}, {th}^{2}, 1\right)} \cdot th}{\frac{\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)}}{\sin ky}} \]
            6. sub-negN/A

              \[\leadsto \frac{\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}{\frac{\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)}}{\sin ky}} \]
            7. *-commutativeN/A

              \[\leadsto \frac{\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}{\frac{\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)}}{\sin ky}} \]
            8. metadata-evalN/A

              \[\leadsto \frac{\mathsf{fma}\left({th}^{2} \cdot \frac{1}{120} + \color{blue}{\frac{-1}{6}}, {th}^{2}, 1\right) \cdot th}{\frac{\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)}}{\sin ky}} \]
            9. lower-fma.f64N/A

              \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left({th}^{2}, \frac{1}{120}, \frac{-1}{6}\right)}, {th}^{2}, 1\right) \cdot th}{\frac{\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)}}{\sin ky}} \]
            10. unpow2N/A

              \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{th \cdot th}, \frac{1}{120}, \frac{-1}{6}\right), {th}^{2}, 1\right) \cdot th}{\frac{\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)}}{\sin ky}} \]
            11. lower-*.f64N/A

              \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{th \cdot th}, \frac{1}{120}, \frac{-1}{6}\right), {th}^{2}, 1\right) \cdot th}{\frac{\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)}}{\sin ky}} \]
            12. unpow2N/A

              \[\leadsto \frac{\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}{\frac{\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)}}{\sin ky}} \]
            13. lower-*.f6455.6

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

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

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

          1. Initial program 95.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 \frac{\sin ky}{\color{blue}{\sin ky + \frac{1}{2} \cdot \frac{{kx}^{2}}{\sin ky}}} \cdot \sin th \]
          4. Step-by-step derivation
            1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
            12. lower-sin.f64100.0

              \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{\sin ky}, \color{blue}{\sin ky}\right)} \cdot \sin th \]
          5. Applied rewrites100.0%

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

            \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
          7. Step-by-step derivation
            1. Applied rewrites100.0%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.98:\\ \;\;\;\;\frac{\sin th \cdot \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 -0.001:\\ \;\;\;\;\left(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(\cos \left(2 \cdot ky\right) - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.05:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot 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.9999996186923419:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, 0.008333333333333333, -0.16666666666666666\right), th \cdot th, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \sin th\\ \end{array} \]
          10. Add Preprocessing

          Alternative 5: 78.2% accurate, 0.3× speedup?

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

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

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

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

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

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

                \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              7. lower-/.f6488.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -0.97999999999999998 < (/.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))))) < -1e-3

            1. Initial program 99.3%

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

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

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

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

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

                \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
              7. lower-/.f6499.3

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
            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. *-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. 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)}}} \]
              7. associate-/r*N/A

                \[\leadsto \left(\sin ky \cdot th\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)}}} \]
              8. metadata-evalN/A

                \[\leadsto \left(\sin ky \cdot th\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)}} \]
              9. lower-/.f64N/A

                \[\leadsto \left(\sin ky \cdot th\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)}}} \]
              10. +-commutativeN/A

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

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

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

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

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

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

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

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

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

              \[\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-*.f6498.2

                \[\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 rewrites98.2%

              \[\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 \]
            8. Taylor expanded in ky around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}} \]
            10. 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)}}} \]
            11. 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. metadata-evalN/A

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

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

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

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

              \[\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.99999961869234189 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

            1. Initial program 95.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 \frac{\sin ky}{\color{blue}{\sin ky + \frac{1}{2} \cdot \frac{{kx}^{2}}{\sin ky}}} \cdot \sin th \]
            4. Step-by-step derivation
              1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
              12. lower-sin.f64100.0

                \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{\sin ky}, \color{blue}{\sin ky}\right)} \cdot \sin th \]
            5. Applied rewrites100.0%

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

              \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
            7. Step-by-step derivation
              1. Applied rewrites100.0%

                \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
            8. Recombined 5 regimes into one program.
            9. Final simplification77.8%

              \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.98:\\ \;\;\;\;\frac{\sin th \cdot \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 -0.001:\\ \;\;\;\;\left(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(\cos \left(2 \cdot ky\right) - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.05:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot 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.9999996186923419:\\ \;\;\;\;\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{else}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \sin th\\ \end{array} \]
            10. Add Preprocessing

            Alternative 6: 78.2% accurate, 0.3× speedup?

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                7. lower-/.f6488.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if -0.97999999999999998 < (/.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))))) < -1e-3

              1. Initial program 99.3%

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

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

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

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

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

                  \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                7. lower-/.f6499.3

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
              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. *-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. 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)}}} \]
                7. associate-/r*N/A

                  \[\leadsto \left(\sin ky \cdot th\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)}}} \]
                8. metadata-evalN/A

                  \[\leadsto \left(\sin ky \cdot th\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)}} \]
                9. lower-/.f64N/A

                  \[\leadsto \left(\sin ky \cdot th\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)}}} \]
                10. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                \[\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-*.f6498.2

                  \[\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 rewrites98.2%

                \[\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 \]
              8. Taylor expanded in ky around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}} \]
              10. 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)}}} \]
              11. 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. metadata-evalN/A

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

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

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

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

                \[\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.99999961869234189 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

              1. Initial program 95.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 \frac{\sin ky}{\color{blue}{\sin ky + \frac{1}{2} \cdot \frac{{kx}^{2}}{\sin ky}}} \cdot \sin th \]
              4. Step-by-step derivation
                1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
                12. lower-sin.f64100.0

                  \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{\sin ky}, \color{blue}{\sin ky}\right)} \cdot \sin th \]
              5. Applied rewrites100.0%

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

                \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
              7. Step-by-step derivation
                1. Applied rewrites100.0%

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

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

              Alternative 7: 78.2% 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(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(t\_2 - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\ \mathbf{if}\;t\_1 \leq -0.98:\\ \;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}}\\ \mathbf{elif}\;t\_1 \leq -0.001:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_1 \leq 0.05:\\ \;\;\;\;\frac{\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\ \mathbf{elif}\;t\_1 \leq 0.9999996186923419:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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
                       (*
                        (* th (sin ky))
                        (sqrt (/ 2.0 (- 1.0 (- t_2 (- 1.0 (cos (* 2.0 kx))))))))))
                 (if (<= t_1 -0.98)
                   (/ (* (sin th) (sin ky)) (sqrt (* (- 1.0 t_2) 0.5)))
                   (if (<= t_1 -0.001)
                     t_3
                     (if (<= t_1 0.05)
                       (*
                        (/
                         (* (fma (* ky ky) -0.16666666666666666 1.0) ky)
                         (hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
                        (sin th))
                       (if (<= t_1 0.9999996186923419)
                         t_3
                         (* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (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 = (th * sin(ky)) * sqrt((2.0 / (1.0 - (t_2 - (1.0 - cos((2.0 * kx)))))));
              	double tmp;
              	if (t_1 <= -0.98) {
              		tmp = (sin(th) * sin(ky)) / sqrt(((1.0 - t_2) * 0.5));
              	} else if (t_1 <= -0.001) {
              		tmp = t_3;
              	} else if (t_1 <= 0.05) {
              		tmp = ((fma((ky * ky), -0.16666666666666666, 1.0) * ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
              	} else if (t_1 <= 0.9999996186923419) {
              		tmp = t_3;
              	} else {
              		tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * 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(th * sin(ky)) * sqrt(Float64(2.0 / Float64(1.0 - Float64(t_2 - Float64(1.0 - cos(Float64(2.0 * kx))))))))
              	tmp = 0.0
              	if (t_1 <= -0.98)
              		tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(Float64(1.0 - t_2) * 0.5)));
              	elseif (t_1 <= -0.001)
              		tmp = t_3;
              	elseif (t_1 <= 0.05)
              		tmp = Float64(Float64(Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th));
              	elseif (t_1 <= 0.9999996186923419)
              		tmp = t_3;
              	else
              		tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * 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[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[(t$95$2 - N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.98], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.001], t$95$3, If[LessEqual[t$95$1, 0.05], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * 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.9999996186923419], t$95$3, N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $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(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(t\_2 - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\
              \mathbf{if}\;t\_1 \leq -0.98:\\
              \;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}}\\
              
              \mathbf{elif}\;t\_1 \leq -0.001:\\
              \;\;\;\;t\_3\\
              
              \mathbf{elif}\;t\_1 \leq 0.05:\\
              \;\;\;\;\frac{\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
              
              \mathbf{elif}\;t\_1 \leq 0.9999996186923419:\\
              \;\;\;\;t\_3\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.97999999999999998

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

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

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

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

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

                    \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                  7. lower-/.f6488.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if -0.97999999999999998 < (/.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))))) < -1e-3 or 0.050000000000000003 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99999961869234189

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

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

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

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

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

                    \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                  7. lower-/.f6499.3

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                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. *-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. 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)}}} \]
                  7. associate-/r*N/A

                    \[\leadsto \left(\sin ky \cdot th\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)}}} \]
                  8. metadata-evalN/A

                    \[\leadsto \left(\sin ky \cdot th\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)}} \]
                  9. lower-/.f64N/A

                    \[\leadsto \left(\sin ky \cdot th\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)}}} \]
                  10. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                  \[\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-*.f6498.2

                    \[\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 rewrites98.2%

                  \[\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 \]
                8. Taylor expanded in ky around 0

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

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

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

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

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

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

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

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

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

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

                1. Initial program 95.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 \frac{\sin ky}{\color{blue}{\sin ky + \frac{1}{2} \cdot \frac{{kx}^{2}}{\sin ky}}} \cdot \sin th \]
                4. Step-by-step derivation
                  1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
                  12. lower-sin.f64100.0

                    \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{\sin ky}, \color{blue}{\sin ky}\right)} \cdot \sin th \]
                5. Applied rewrites100.0%

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

                  \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
                7. Step-by-step derivation
                  1. Applied rewrites100.0%

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

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

                Alternative 8: 61.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.708:\\ \;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}}\\ \mathbf{elif}\;t\_1 \leq 0.999:\\ \;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.708)
                     (/ (* (sin th) (sin ky)) (sqrt (* (- 1.0 (cos (* 2.0 ky))) 0.5)))
                     (if (<= t_1 0.999)
                       (* (/ (sin th) (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5))) (sin ky))
                       (* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (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 tmp;
                	if (t_1 <= -0.708) {
                		tmp = (sin(th) * sin(ky)) / sqrt(((1.0 - cos((2.0 * ky))) * 0.5));
                	} else if (t_1 <= 0.999) {
                		tmp = (sin(th) / sqrt(((1.0 - cos((kx + kx))) * 0.5))) * sin(ky);
                	} else {
                		tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * 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.708)
                		tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(Float64(1.0 - cos(Float64(2.0 * ky))) * 0.5)));
                	elseif (t_1 <= 0.999)
                		tmp = Float64(Float64(sin(th) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) * sin(ky));
                	else
                		tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * 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, -0.708], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.999], 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], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $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.708:\\
                \;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}}\\
                
                \mathbf{elif}\;t\_1 \leq 0.999:\\
                \;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.70799999999999996

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

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

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

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

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

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

                      \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                    7. lower-/.f6490.8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                    7. lower-/.f6499.4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  1. Initial program 95.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 \frac{\sin ky}{\color{blue}{\sin ky + \frac{1}{2} \cdot \frac{{kx}^{2}}{\sin ky}}} \cdot \sin th \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
                    12. lower-sin.f64100.0

                      \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{\sin ky}, \color{blue}{\sin ky}\right)} \cdot \sin th \]
                  5. Applied rewrites100.0%

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

                    \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
                  7. Step-by-step derivation
                    1. Applied rewrites100.0%

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

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.708:\\ \;\;\;\;\frac{\sin th \cdot \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 0.999:\\ \;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \sin th\\ \end{array} \]
                  10. Add Preprocessing

                  Alternative 9: 55.0% 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.88:\\ \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\ \mathbf{elif}\;t\_1 \leq 0.999:\\ \;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.88)
                       (/
                        (* (fma (* th th) -0.16666666666666666 1.0) th)
                        (/
                         (sqrt
                          (fma
                           (- 1.0 (cos (* 2.0 ky)))
                           0.5
                           (*
                            (fma
                             (fma 0.044444444444444446 (* kx kx) -0.3333333333333333)
                             (* kx kx)
                             1.0)
                            (* kx kx))))
                         (sin ky)))
                       (if (<= t_1 0.999)
                         (* (/ (sin th) (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5))) (sin ky))
                         (* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (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 tmp;
                  	if (t_1 <= -0.88) {
                  		tmp = (fma((th * th), -0.16666666666666666, 1.0) * th) / (sqrt(fma((1.0 - cos((2.0 * ky))), 0.5, (fma(fma(0.044444444444444446, (kx * kx), -0.3333333333333333), (kx * kx), 1.0) * (kx * kx)))) / sin(ky));
                  	} else if (t_1 <= 0.999) {
                  		tmp = (sin(th) / sqrt(((1.0 - cos((kx + kx))) * 0.5))) * sin(ky);
                  	} else {
                  		tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * 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.88)
                  		tmp = Float64(Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(2.0 * ky))), 0.5, Float64(fma(fma(0.044444444444444446, Float64(kx * kx), -0.3333333333333333), Float64(kx * kx), 1.0) * Float64(kx * kx)))) / sin(ky)));
                  	elseif (t_1 <= 0.999)
                  		tmp = Float64(Float64(sin(th) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) * sin(ky));
                  	else
                  		tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * 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, -0.88], N[(N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(N[(0.044444444444444446 * N[(kx * kx), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.999], 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], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $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.88:\\
                  \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\
                  
                  \mathbf{elif}\;t\_1 \leq 0.999:\\
                  \;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.880000000000000004

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

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

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

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

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

                        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                      7. lower-/.f6489.8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                      7. lower-/.f6499.4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    1. Initial program 95.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 \frac{\sin ky}{\color{blue}{\sin ky + \frac{1}{2} \cdot \frac{{kx}^{2}}{\sin ky}}} \cdot \sin th \]
                    4. Step-by-step derivation
                      1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
                      12. lower-sin.f64100.0

                        \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{\sin ky}, \color{blue}{\sin ky}\right)} \cdot \sin th \]
                    5. Applied rewrites100.0%

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

                      \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(\frac{1}{2} \cdot kx, \frac{kx}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
                    7. Step-by-step derivation
                      1. Applied rewrites100.0%

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

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

                    Alternative 10: 55.1% 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.88:\\ \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\ \mathbf{elif}\;t\_1 \leq 0.71:\\ \;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\ \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.88)
                         (/
                          (* (fma (* th th) -0.16666666666666666 1.0) th)
                          (/
                           (sqrt
                            (fma
                             (- 1.0 (cos (* 2.0 ky)))
                             0.5
                             (*
                              (fma
                               (fma 0.044444444444444446 (* kx kx) -0.3333333333333333)
                               (* kx kx)
                               1.0)
                              (* kx kx))))
                           (sin ky)))
                         (if (<= t_1 0.71)
                           (* (/ (sin th) (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5))) (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 tmp;
                    	if (t_1 <= -0.88) {
                    		tmp = (fma((th * th), -0.16666666666666666, 1.0) * th) / (sqrt(fma((1.0 - cos((2.0 * ky))), 0.5, (fma(fma(0.044444444444444446, (kx * kx), -0.3333333333333333), (kx * kx), 1.0) * (kx * kx)))) / sin(ky));
                    	} else if (t_1 <= 0.71) {
                    		tmp = (sin(th) / sqrt(((1.0 - cos((kx + kx))) * 0.5))) * sin(ky);
                    	} 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 <= -0.88)
                    		tmp = Float64(Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(2.0 * ky))), 0.5, Float64(fma(fma(0.044444444444444446, Float64(kx * kx), -0.3333333333333333), Float64(kx * kx), 1.0) * Float64(kx * kx)))) / sin(ky)));
                    	elseif (t_1 <= 0.71)
                    		tmp = Float64(Float64(sin(th) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) * sin(ky));
                    	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, -0.88], N[(N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(N[(0.044444444444444446 * N[(kx * kx), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.71], 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], 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.88:\\
                    \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\
                    
                    \mathbf{elif}\;t\_1 \leq 0.71:\\
                    \;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\
                    
                    \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.880000000000000004

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

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

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

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

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

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        7. lower-/.f6489.8

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

                        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}} \]
                      5. Taylor expanded in kx around 0

                        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}{\sin ky}} \]
                      6. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                        2. lower-*.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                        3. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        4. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        5. lower--.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}}{\sin ky}} \]
                        6. lower-cos.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        7. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        8. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        9. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        10. lower-*.f6459.9

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}}{\sin ky}} \]
                      7. Applied rewrites59.9%

                        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                      8. Taylor expanded in th around 0

                        \[\leadsto \frac{\color{blue}{th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                      9. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \frac{\color{blue}{\left(1 + \frac{-1}{6} \cdot {th}^{2}\right) \cdot th}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        2. lower-*.f64N/A

                          \[\leadsto \frac{\color{blue}{\left(1 + \frac{-1}{6} \cdot {th}^{2}\right) \cdot th}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        3. +-commutativeN/A

                          \[\leadsto \frac{\color{blue}{\left(\frac{-1}{6} \cdot {th}^{2} + 1\right)} \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        4. *-commutativeN/A

                          \[\leadsto \frac{\left(\color{blue}{{th}^{2} \cdot \frac{-1}{6}} + 1\right) \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        5. lower-fma.f64N/A

                          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({th}^{2}, \frac{-1}{6}, 1\right)} \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        6. unpow2N/A

                          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{th \cdot th}, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        7. lower-*.f6433.1

                          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{th \cdot th}, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}{\sin ky}} \]
                      10. Applied rewrites33.1%

                        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}{\sin ky}} \]
                      11. Taylor expanded in kx around 0

                        \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right) + {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)}}}{\sin ky}} \]
                      12. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}} + {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)}}{\sin ky}} \]
                        2. lower-fma.f64N/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}}{\sin ky}} \]
                        3. metadata-evalN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right), \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        4. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        5. lower--.f64N/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        6. lower-cos.f64N/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        7. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        8. metadata-evalN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(\color{blue}{2} \cdot ky\right), \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        9. *-commutativeN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        10. lower-*.f64N/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        11. *-commutativeN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky \cdot 2\right), \frac{1}{2}, \color{blue}{\left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right) \cdot {kx}^{2}}\right)}}{\sin ky}} \]
                        12. lower-*.f64N/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky \cdot 2\right), \frac{1}{2}, \color{blue}{\left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right) \cdot {kx}^{2}}\right)}}{\sin ky}} \]
                      13. Applied rewrites34.3%

                        \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky \cdot 2\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}}{\sin ky}} \]

                      if -0.880000000000000004 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.70999999999999996

                      1. Initial program 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 \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
                        2. *-commutativeN/A

                          \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        3. lift-/.f64N/A

                          \[\leadsto \sin th \cdot \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        4. clear-numN/A

                          \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        5. un-div-invN/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        6. lower-/.f64N/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        7. lower-/.f6499.5

                          \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                      4. Applied rewrites84.9%

                        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}} \]
                      5. Taylor expanded in kx around 0

                        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}{\sin ky}} \]
                      6. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                        2. lower-*.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                        3. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        4. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        5. lower--.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}}{\sin ky}} \]
                        6. lower-cos.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        7. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        8. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        9. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        10. lower-*.f648.4

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}}{\sin ky}} \]
                      7. Applied rewrites8.4%

                        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                      8. Step-by-step derivation
                        1. lift-/.f64N/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                        2. lift-/.f64N/A

                          \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                        3. associate-/r/N/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \cdot \sin ky} \]
                        4. lower-*.f64N/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \cdot \sin ky} \]
                      9. Applied rewrites56.3%

                        \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky} \]

                      if 0.70999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                      1. Initial program 96.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.f6482.0

                          \[\leadsto \color{blue}{\sin th} \]
                      5. Applied rewrites82.0%

                        \[\leadsto \color{blue}{\sin th} \]
                    3. Recombined 3 regimes into one program.
                    4. Final simplification56.1%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.88:\\ \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.71:\\ \;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                    5. Add Preprocessing

                    Alternative 11: 55.1% 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.88:\\ \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\ \mathbf{elif}\;t\_1 \leq 0.71:\\ \;\;\;\;\frac{\sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \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.88)
                         (/
                          (* (fma (* th th) -0.16666666666666666 1.0) th)
                          (/
                           (sqrt
                            (fma
                             (- 1.0 (cos (* 2.0 ky)))
                             0.5
                             (*
                              (fma
                               (fma 0.044444444444444446 (* kx kx) -0.3333333333333333)
                               (* kx kx)
                               1.0)
                              (* kx kx))))
                           (sin ky)))
                         (if (<= t_1 0.71)
                           (* (/ (sin ky) (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5))) (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.88) {
                    		tmp = (fma((th * th), -0.16666666666666666, 1.0) * th) / (sqrt(fma((1.0 - cos((2.0 * ky))), 0.5, (fma(fma(0.044444444444444446, (kx * kx), -0.3333333333333333), (kx * kx), 1.0) * (kx * kx)))) / sin(ky));
                    	} else if (t_1 <= 0.71) {
                    		tmp = (sin(ky) / sqrt(((1.0 - cos((kx + kx))) * 0.5))) * 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 <= -0.88)
                    		tmp = Float64(Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(2.0 * ky))), 0.5, Float64(fma(fma(0.044444444444444446, Float64(kx * kx), -0.3333333333333333), Float64(kx * kx), 1.0) * Float64(kx * kx)))) / sin(ky)));
                    	elseif (t_1 <= 0.71)
                    		tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) * 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, -0.88], N[(N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(N[(0.044444444444444446 * N[(kx * kx), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.71], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $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.88:\\
                    \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\
                    
                    \mathbf{elif}\;t\_1 \leq 0.71:\\
                    \;\;\;\;\frac{\sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \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.880000000000000004

                      1. Initial program 89.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 \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
                        2. *-commutativeN/A

                          \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        3. lift-/.f64N/A

                          \[\leadsto \sin th \cdot \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        4. clear-numN/A

                          \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        5. un-div-invN/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        6. lower-/.f64N/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        7. lower-/.f6489.8

                          \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                      4. Applied rewrites70.1%

                        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}} \]
                      5. Taylor expanded in kx around 0

                        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}{\sin ky}} \]
                      6. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                        2. lower-*.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                        3. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        4. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        5. lower--.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}}{\sin ky}} \]
                        6. lower-cos.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        7. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        8. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        9. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        10. lower-*.f6459.9

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}}{\sin ky}} \]
                      7. Applied rewrites59.9%

                        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                      8. Taylor expanded in th around 0

                        \[\leadsto \frac{\color{blue}{th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                      9. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \frac{\color{blue}{\left(1 + \frac{-1}{6} \cdot {th}^{2}\right) \cdot th}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        2. lower-*.f64N/A

                          \[\leadsto \frac{\color{blue}{\left(1 + \frac{-1}{6} \cdot {th}^{2}\right) \cdot th}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        3. +-commutativeN/A

                          \[\leadsto \frac{\color{blue}{\left(\frac{-1}{6} \cdot {th}^{2} + 1\right)} \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        4. *-commutativeN/A

                          \[\leadsto \frac{\left(\color{blue}{{th}^{2} \cdot \frac{-1}{6}} + 1\right) \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        5. lower-fma.f64N/A

                          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({th}^{2}, \frac{-1}{6}, 1\right)} \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        6. unpow2N/A

                          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{th \cdot th}, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        7. lower-*.f6433.1

                          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{th \cdot th}, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}{\sin ky}} \]
                      10. Applied rewrites33.1%

                        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}{\sin ky}} \]
                      11. Taylor expanded in kx around 0

                        \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right) + {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)}}}{\sin ky}} \]
                      12. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}} + {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)}}{\sin ky}} \]
                        2. lower-fma.f64N/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}}{\sin ky}} \]
                        3. metadata-evalN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right), \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        4. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        5. lower--.f64N/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        6. lower-cos.f64N/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        7. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        8. metadata-evalN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(\color{blue}{2} \cdot ky\right), \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        9. *-commutativeN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        10. lower-*.f64N/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}, \frac{1}{2}, {kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}}{\sin ky}} \]
                        11. *-commutativeN/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky \cdot 2\right), \frac{1}{2}, \color{blue}{\left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right) \cdot {kx}^{2}}\right)}}{\sin ky}} \]
                        12. lower-*.f64N/A

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky \cdot 2\right), \frac{1}{2}, \color{blue}{\left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right) \cdot {kx}^{2}}\right)}}{\sin ky}} \]
                      13. Applied rewrites34.3%

                        \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky \cdot 2\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}}{\sin ky}} \]

                      if -0.880000000000000004 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.70999999999999996

                      1. Initial program 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 \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
                        2. *-commutativeN/A

                          \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        3. lift-/.f64N/A

                          \[\leadsto \sin th \cdot \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        4. clear-numN/A

                          \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        5. un-div-invN/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        6. lower-/.f64N/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        7. lower-/.f6499.5

                          \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                      4. Applied rewrites84.9%

                        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}} \]
                      5. Taylor expanded in kx around 0

                        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}{\sin ky}} \]
                      6. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                        2. lower-*.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                        3. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        4. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        5. lower--.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}}{\sin ky}} \]
                        6. lower-cos.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        7. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        8. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        9. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        10. lower-*.f648.4

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}}{\sin ky}} \]
                      7. Applied rewrites8.4%

                        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                      8. Step-by-step derivation
                        1. lift-/.f64N/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                        2. clear-numN/A

                          \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}{\sin th}}} \]
                        3. associate-/r/N/A

                          \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \cdot \sin th} \]
                        4. lift-/.f64N/A

                          \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \cdot \sin th \]
                        5. clear-numN/A

                          \[\leadsto \color{blue}{\frac{\sin ky}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \cdot \sin th \]
                        6. lower-*.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} \]
                      9. Applied rewrites56.3%

                        \[\leadsto \color{blue}{\frac{\sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin th} \]

                      if 0.70999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                      1. Initial program 96.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.f6482.0

                          \[\leadsto \color{blue}{\sin th} \]
                      5. Applied rewrites82.0%

                        \[\leadsto \color{blue}{\sin th} \]
                    3. Recombined 3 regimes into one program.
                    4. Final simplification56.1%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.88:\\ \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.71:\\ \;\;\;\;\frac{\sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                    5. Add Preprocessing

                    Alternative 12: 53.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.02:\\ \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{0.5 \cdot \left(1 - \cos \left(ky + ky\right)\right)}}{\sin ky}}\\ \mathbf{elif}\;t\_1 \leq 0.05:\\ \;\;\;\;\frac{\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\right) \cdot \sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}\\ \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.02)
                         (/
                          (* (fma (* th th) -0.16666666666666666 1.0) th)
                          (/ (sqrt (* 0.5 (- 1.0 (cos (+ ky ky))))) (sin ky)))
                         (if (<= t_1 0.05)
                           (/
                            (* (* (fma (* ky ky) -0.16666666666666666 1.0) ky) (sin th))
                            (sqrt (* (- 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 tmp;
                    	if (t_1 <= -0.02) {
                    		tmp = (fma((th * th), -0.16666666666666666, 1.0) * th) / (sqrt((0.5 * (1.0 - cos((ky + ky))))) / sin(ky));
                    	} else if (t_1 <= 0.05) {
                    		tmp = ((fma((ky * ky), -0.16666666666666666, 1.0) * ky) * sin(th)) / sqrt(((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))))
                    	tmp = 0.0
                    	if (t_1 <= -0.02)
                    		tmp = Float64(Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th) / Float64(sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(ky + ky))))) / sin(ky)));
                    	elseif (t_1 <= 0.05)
                    		tmp = Float64(Float64(Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) * sin(th)) / sqrt(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]}, If[LessEqual[t$95$1, -0.02], N[(N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(0.5 * N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.05], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $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}}}\\
                    \mathbf{if}\;t\_1 \leq -0.02:\\
                    \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{0.5 \cdot \left(1 - \cos \left(ky + ky\right)\right)}}{\sin ky}}\\
                    
                    \mathbf{elif}\;t\_1 \leq 0.05:\\
                    \;\;\;\;\frac{\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\right) \cdot \sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}\\
                    
                    \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.0200000000000000004

                      1. Initial program 92.7%

                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                      2. Add Preprocessing
                      3. Step-by-step derivation
                        1. lift-*.f64N/A

                          \[\leadsto \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
                        2. *-commutativeN/A

                          \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        3. lift-/.f64N/A

                          \[\leadsto \sin th \cdot \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        4. clear-numN/A

                          \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        5. un-div-invN/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        6. lower-/.f64N/A

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        7. lower-/.f6492.7

                          \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                      4. Applied rewrites78.8%

                        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}} \]
                      5. Taylor expanded in kx around 0

                        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}{\sin ky}} \]
                      6. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                        2. lower-*.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                        3. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        4. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        5. lower--.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}}{\sin ky}} \]
                        6. lower-cos.f64N/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        7. distribute-lft-neg-inN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        8. metadata-evalN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        9. *-commutativeN/A

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        10. lower-*.f6447.7

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}}{\sin ky}} \]
                      7. Applied rewrites47.7%

                        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                      8. Taylor expanded in th around 0

                        \[\leadsto \frac{\color{blue}{th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                      9. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \frac{\color{blue}{\left(1 + \frac{-1}{6} \cdot {th}^{2}\right) \cdot th}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        2. lower-*.f64N/A

                          \[\leadsto \frac{\color{blue}{\left(1 + \frac{-1}{6} \cdot {th}^{2}\right) \cdot th}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        3. +-commutativeN/A

                          \[\leadsto \frac{\color{blue}{\left(\frac{-1}{6} \cdot {th}^{2} + 1\right)} \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        4. *-commutativeN/A

                          \[\leadsto \frac{\left(\color{blue}{{th}^{2} \cdot \frac{-1}{6}} + 1\right) \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        5. lower-fma.f64N/A

                          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({th}^{2}, \frac{-1}{6}, 1\right)} \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        6. unpow2N/A

                          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{th \cdot th}, \frac{-1}{6}, 1\right) \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                        7. lower-*.f6426.4

                          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{th \cdot th}, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}{\sin ky}} \]
                      10. Applied rewrites26.4%

                        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}{\sin ky}} \]
                      11. Step-by-step derivation
                        1. Applied rewrites26.4%

                          \[\leadsto \frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\left(1 - \cos \left(ky + ky\right)\right) \cdot 0.5}}{\sin ky}} \]

                        if -0.0200000000000000004 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.050000000000000003

                        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 \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
                          2. *-commutativeN/A

                            \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          3. lift-/.f64N/A

                            \[\leadsto \sin th \cdot \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          4. clear-numN/A

                            \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          5. un-div-invN/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          6. lower-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          7. lower-/.f6499.5

                            \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        4. Applied rewrites77.0%

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}} \]
                        5. Taylor expanded in kx around 0

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}{\sin ky}} \]
                        6. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                          2. lower-*.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                          3. metadata-evalN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          4. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          5. lower--.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}}{\sin ky}} \]
                          6. lower-cos.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          7. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          8. metadata-evalN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          9. *-commutativeN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          10. lower-*.f642.6

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}}{\sin ky}} \]
                        7. Applied rewrites2.6%

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                        8. Step-by-step derivation
                          1. lift-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                          2. lift-/.f64N/A

                            \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                          3. associate-/r/N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \cdot \sin ky} \]
                          4. associate-*l/N/A

                            \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \]
                          5. *-commutativeN/A

                            \[\leadsto \frac{\color{blue}{\sin ky \cdot \sin th}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \]
                          6. lower-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \]
                          7. *-commutativeN/A

                            \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \]
                          8. lower-*.f642.3

                            \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}} \]
                        9. Applied rewrites74.5%

                          \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}} \]
                        10. Taylor expanded in ky around 0

                          \[\leadsto \frac{\sin th \cdot \color{blue}{\left(ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right)}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                        11. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \frac{\sin th \cdot \color{blue}{\left(\left(1 + \frac{-1}{6} \cdot {ky}^{2}\right) \cdot ky\right)}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          2. lower-*.f64N/A

                            \[\leadsto \frac{\sin th \cdot \color{blue}{\left(\left(1 + \frac{-1}{6} \cdot {ky}^{2}\right) \cdot ky\right)}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          3. +-commutativeN/A

                            \[\leadsto \frac{\sin th \cdot \left(\color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2} + 1\right)} \cdot ky\right)}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          4. *-commutativeN/A

                            \[\leadsto \frac{\sin th \cdot \left(\left(\color{blue}{{ky}^{2} \cdot \frac{-1}{6}} + 1\right) \cdot ky\right)}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          5. lower-fma.f64N/A

                            \[\leadsto \frac{\sin th \cdot \left(\color{blue}{\mathsf{fma}\left({ky}^{2}, \frac{-1}{6}, 1\right)} \cdot ky\right)}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          6. unpow2N/A

                            \[\leadsto \frac{\sin th \cdot \left(\mathsf{fma}\left(\color{blue}{ky \cdot ky}, \frac{-1}{6}, 1\right) \cdot ky\right)}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          7. lower-*.f6474.0

                            \[\leadsto \frac{\sin th \cdot \left(\mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.16666666666666666, 1\right) \cdot ky\right)}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \]
                        12. Applied rewrites74.0%

                          \[\leadsto \frac{\sin th \cdot \color{blue}{\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\right)}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \]

                        if 0.050000000000000003 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                        1. Initial program 97.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.f6466.6

                            \[\leadsto \color{blue}{\sin th} \]
                        5. Applied rewrites66.6%

                          \[\leadsto \color{blue}{\sin th} \]
                      12. Recombined 3 regimes into one program.
                      13. Final simplification53.8%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.02:\\ \;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{0.5 \cdot \left(1 - \cos \left(ky + ky\right)\right)}}{\sin ky}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.05:\\ \;\;\;\;\frac{\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\right) \cdot \sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                      14. Add Preprocessing

                      Alternative 13: 48.2% accurate, 0.5× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_1 := \sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}\\ t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\ \mathbf{if}\;t\_2 \leq -0.001:\\ \;\;\;\;\frac{th \cdot \sin ky}{t\_1}\\ \mathbf{elif}\;t\_2 \leq 0.05:\\ \;\;\;\;\frac{\sin th \cdot ky}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                      (FPCore (kx ky th)
                       :precision binary64
                       (let* ((t_1 (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5)))
                              (t_2 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0))))))
                         (if (<= t_2 -0.001)
                           (/ (* th (sin ky)) t_1)
                           (if (<= t_2 0.05) (/ (* (sin th) ky) t_1) (sin th)))))
                      double code(double kx, double ky, double th) {
                      	double t_1 = sqrt(((1.0 - cos((kx + kx))) * 0.5));
                      	double t_2 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
                      	double tmp;
                      	if (t_2 <= -0.001) {
                      		tmp = (th * sin(ky)) / t_1;
                      	} else if (t_2 <= 0.05) {
                      		tmp = (sin(th) * ky) / t_1;
                      	} 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) :: tmp
                          t_1 = sqrt(((1.0d0 - cos((kx + kx))) * 0.5d0))
                          t_2 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
                          if (t_2 <= (-0.001d0)) then
                              tmp = (th * sin(ky)) / t_1
                          else if (t_2 <= 0.05d0) then
                              tmp = (sin(th) * ky) / t_1
                          else
                              tmp = sin(th)
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double kx, double ky, double th) {
                      	double t_1 = Math.sqrt(((1.0 - Math.cos((kx + kx))) * 0.5));
                      	double t_2 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
                      	double tmp;
                      	if (t_2 <= -0.001) {
                      		tmp = (th * Math.sin(ky)) / t_1;
                      	} else if (t_2 <= 0.05) {
                      		tmp = (Math.sin(th) * ky) / t_1;
                      	} else {
                      		tmp = Math.sin(th);
                      	}
                      	return tmp;
                      }
                      
                      def code(kx, ky, th):
                      	t_1 = math.sqrt(((1.0 - math.cos((kx + kx))) * 0.5))
                      	t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))
                      	tmp = 0
                      	if t_2 <= -0.001:
                      		tmp = (th * math.sin(ky)) / t_1
                      	elif t_2 <= 0.05:
                      		tmp = (math.sin(th) * ky) / t_1
                      	else:
                      		tmp = math.sin(th)
                      	return tmp
                      
                      function code(kx, ky, th)
                      	t_1 = sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))
                      	t_2 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))))
                      	tmp = 0.0
                      	if (t_2 <= -0.001)
                      		tmp = Float64(Float64(th * sin(ky)) / t_1);
                      	elseif (t_2 <= 0.05)
                      		tmp = Float64(Float64(sin(th) * ky) / t_1);
                      	else
                      		tmp = sin(th);
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(kx, ky, th)
                      	t_1 = sqrt(((1.0 - cos((kx + kx))) * 0.5));
                      	t_2 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)));
                      	tmp = 0.0;
                      	if (t_2 <= -0.001)
                      		tmp = (th * sin(ky)) / t_1;
                      	elseif (t_2 <= 0.05)
                      		tmp = (sin(th) * ky) / t_1;
                      	else
                      		tmp = sin(th);
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $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]}, If[LessEqual[t$95$2, -0.001], N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 0.05], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_1 := \sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}\\
                      t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
                      \mathbf{if}\;t\_2 \leq -0.001:\\
                      \;\;\;\;\frac{th \cdot \sin ky}{t\_1}\\
                      
                      \mathbf{elif}\;t\_2 \leq 0.05:\\
                      \;\;\;\;\frac{\sin th \cdot ky}{t\_1}\\
                      
                      \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))))) < -1e-3

                        1. Initial program 92.7%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Step-by-step derivation
                          1. lift-*.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
                          2. *-commutativeN/A

                            \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          3. lift-/.f64N/A

                            \[\leadsto \sin th \cdot \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          4. clear-numN/A

                            \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          5. un-div-invN/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          6. lower-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          7. lower-/.f6492.7

                            \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        4. Applied rewrites78.8%

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}} \]
                        5. Taylor expanded in kx around 0

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}{\sin ky}} \]
                        6. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                          2. lower-*.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                          3. metadata-evalN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          4. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          5. lower--.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}}{\sin ky}} \]
                          6. lower-cos.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          7. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          8. metadata-evalN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          9. *-commutativeN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          10. lower-*.f6447.7

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}}{\sin ky}} \]
                        7. Applied rewrites47.7%

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                        8. Step-by-step derivation
                          1. lift-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                          2. lift-/.f64N/A

                            \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                          3. associate-/r/N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \cdot \sin ky} \]
                          4. associate-*l/N/A

                            \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \]
                          5. *-commutativeN/A

                            \[\leadsto \frac{\color{blue}{\sin ky \cdot \sin th}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \]
                          6. lower-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \]
                          7. *-commutativeN/A

                            \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \]
                          8. lower-*.f6447.6

                            \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}} \]
                        9. Applied rewrites10.0%

                          \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}} \]
                        10. Taylor expanded in th around 0

                          \[\leadsto \frac{\color{blue}{th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                        11. Step-by-step derivation
                          1. lower-*.f64N/A

                            \[\leadsto \frac{\color{blue}{th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          2. lower-sin.f646.2

                            \[\leadsto \frac{th \cdot \color{blue}{\sin ky}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \]
                        12. Applied rewrites6.2%

                          \[\leadsto \frac{\color{blue}{th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \]

                        if -1e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.050000000000000003

                        1. Initial program 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 \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
                          2. *-commutativeN/A

                            \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          3. lift-/.f64N/A

                            \[\leadsto \sin th \cdot \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          4. clear-numN/A

                            \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          5. un-div-invN/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          6. lower-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          7. lower-/.f6499.5

                            \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        4. Applied rewrites77.0%

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}} \]
                        5. Taylor expanded in kx around 0

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}{\sin ky}} \]
                        6. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                          2. lower-*.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                          3. metadata-evalN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          4. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          5. lower--.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}}{\sin ky}} \]
                          6. lower-cos.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          7. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          8. metadata-evalN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          9. *-commutativeN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          10. lower-*.f642.6

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}}{\sin ky}} \]
                        7. Applied rewrites2.6%

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                        8. Step-by-step derivation
                          1. lift-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                          2. lift-/.f64N/A

                            \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                          3. associate-/r/N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \cdot \sin ky} \]
                          4. associate-*l/N/A

                            \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \]
                          5. *-commutativeN/A

                            \[\leadsto \frac{\color{blue}{\sin ky \cdot \sin th}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \]
                          6. lower-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \]
                          7. *-commutativeN/A

                            \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \]
                          8. lower-*.f642.3

                            \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}} \]
                        9. Applied rewrites74.5%

                          \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}} \]
                        10. Taylor expanded in ky around 0

                          \[\leadsto \frac{\color{blue}{ky \cdot \sin th}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                        11. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \frac{\color{blue}{\sin th \cdot ky}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          2. lower-*.f64N/A

                            \[\leadsto \frac{\color{blue}{\sin th \cdot ky}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          3. lower-sin.f6473.9

                            \[\leadsto \frac{\color{blue}{\sin th} \cdot ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \]
                        12. Applied rewrites73.9%

                          \[\leadsto \frac{\color{blue}{\sin th \cdot ky}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \]

                        if 0.050000000000000003 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                        1. Initial program 97.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.f6466.6

                            \[\leadsto \color{blue}{\sin th} \]
                        5. Applied rewrites66.6%

                          \[\leadsto \color{blue}{\sin th} \]
                      3. Recombined 3 regimes into one program.
                      4. Final simplification46.1%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq -0.001:\\ \;\;\;\;\frac{th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.05:\\ \;\;\;\;\frac{\sin th \cdot ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                      5. Add Preprocessing

                      Alternative 14: 46.9% accurate, 0.8× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.05:\\ \;\;\;\;\frac{\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\right) \cdot \sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}\\ \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)))) 0.05)
                         (/
                          (* (* (fma (* ky ky) -0.16666666666666666 1.0) ky) (sin th))
                          (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5)))
                         (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)))) <= 0.05) {
                      		tmp = ((fma((ky * ky), -0.16666666666666666, 1.0) * ky) * sin(th)) / sqrt(((1.0 - cos((kx + kx))) * 0.5));
                      	} 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)))) <= 0.05)
                      		tmp = Float64(Float64(Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) * sin(th)) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5)));
                      	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], 0.05], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $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 0.05:\\
                      \;\;\;\;\frac{\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\right) \cdot \sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\sin th\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.050000000000000003

                        1. Initial program 95.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 \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
                          2. *-commutativeN/A

                            \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          3. lift-/.f64N/A

                            \[\leadsto \sin th \cdot \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          4. clear-numN/A

                            \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          5. un-div-invN/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          6. lower-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                          7. lower-/.f6495.9

                            \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                        4. Applied rewrites78.0%

                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}} \]
                        5. Taylor expanded in kx around 0

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}{\sin ky}} \]
                        6. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                          2. lower-*.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                          3. metadata-evalN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          4. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          5. lower--.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}}{\sin ky}} \]
                          6. lower-cos.f64N/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          7. distribute-lft-neg-inN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          8. metadata-evalN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          9. *-commutativeN/A

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                          10. lower-*.f6426.6

                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}}{\sin ky}} \]
                        7. Applied rewrites26.6%

                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                        8. Step-by-step derivation
                          1. lift-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                          2. lift-/.f64N/A

                            \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                          3. associate-/r/N/A

                            \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \cdot \sin ky} \]
                          4. associate-*l/N/A

                            \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \]
                          5. *-commutativeN/A

                            \[\leadsto \frac{\color{blue}{\sin ky \cdot \sin th}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \]
                          6. lower-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \]
                          7. *-commutativeN/A

                            \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \]
                          8. lower-*.f6426.4

                            \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}} \]
                        9. Applied rewrites40.1%

                          \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}} \]
                        10. Taylor expanded in ky around 0

                          \[\leadsto \frac{\sin th \cdot \color{blue}{\left(ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right)}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                        11. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \frac{\sin th \cdot \color{blue}{\left(\left(1 + \frac{-1}{6} \cdot {ky}^{2}\right) \cdot ky\right)}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          2. lower-*.f64N/A

                            \[\leadsto \frac{\sin th \cdot \color{blue}{\left(\left(1 + \frac{-1}{6} \cdot {ky}^{2}\right) \cdot ky\right)}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          3. +-commutativeN/A

                            \[\leadsto \frac{\sin th \cdot \left(\color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2} + 1\right)} \cdot ky\right)}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          4. *-commutativeN/A

                            \[\leadsto \frac{\sin th \cdot \left(\left(\color{blue}{{ky}^{2} \cdot \frac{-1}{6}} + 1\right) \cdot ky\right)}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          5. lower-fma.f64N/A

                            \[\leadsto \frac{\sin th \cdot \left(\color{blue}{\mathsf{fma}\left({ky}^{2}, \frac{-1}{6}, 1\right)} \cdot ky\right)}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          6. unpow2N/A

                            \[\leadsto \frac{\sin th \cdot \left(\mathsf{fma}\left(\color{blue}{ky \cdot ky}, \frac{-1}{6}, 1\right) \cdot ky\right)}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}}} \]
                          7. lower-*.f6435.6

                            \[\leadsto \frac{\sin th \cdot \left(\mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.16666666666666666, 1\right) \cdot ky\right)}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \]
                        12. Applied rewrites35.6%

                          \[\leadsto \frac{\sin th \cdot \color{blue}{\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\right)}}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \]

                        if 0.050000000000000003 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                        1. Initial program 97.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.f6466.6

                            \[\leadsto \color{blue}{\sin th} \]
                        5. Applied rewrites66.6%

                          \[\leadsto \color{blue}{\sin th} \]
                      3. Recombined 2 regimes into one program.
                      4. Final simplification44.6%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.05:\\ \;\;\;\;\frac{\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\right) \cdot \sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                      5. Add Preprocessing

                      Alternative 15: 44.7% accurate, 0.8× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\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)))) 2e-8)
                         (* (/ (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)))) <= 2e-8) {
                      		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)))) <= 2d-8) 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)))) <= 2e-8) {
                      		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)))) <= 2e-8:
                      		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)))) <= 2e-8)
                      		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)))) <= 2e-8)
                      		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], 2e-8], 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 2 \cdot 10^{-8}:\\
                      \;\;\;\;\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))))) < 2e-8

                        1. Initial program 95.8%

                          \[\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 rewrites23.1%

                          \[\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 rewrites25.7%

                            \[\leadsto \frac{\sin th}{\sin kx} \cdot ky \]

                          if 2e-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 97.2%

                            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                          2. Add Preprocessing
                          3. Taylor expanded in kx around 0

                            \[\leadsto \color{blue}{\sin th} \]
                          4. Step-by-step derivation
                            1. lower-sin.f6464.5

                              \[\leadsto \color{blue}{\sin th} \]
                          5. Applied rewrites64.5%

                            \[\leadsto \color{blue}{\sin th} \]
                        8. Recombined 2 regimes into one program.
                        9. Final simplification37.4%

                          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\sin th}{\sin kx} \cdot ky\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                        10. Add Preprocessing

                        Alternative 16: 30.6% accurate, 0.9× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-71}:\\ \;\;\;\;\left(\frac{\left(ky \cdot ky\right) \cdot \sin th}{\left(kx \cdot kx\right) \cdot kx} \cdot -0.5\right) \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-71)
                           (* (* (/ (* (* ky ky) (sin th)) (* (* kx kx) kx)) -0.5) 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-71) {
                        		tmp = ((((ky * ky) * sin(th)) / ((kx * kx) * kx)) * -0.5) * 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-71) then
                                tmp = ((((ky * ky) * sin(th)) / ((kx * kx) * kx)) * (-0.5d0)) * 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-71) {
                        		tmp = ((((ky * ky) * Math.sin(th)) / ((kx * kx) * kx)) * -0.5) * 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-71:
                        		tmp = ((((ky * ky) * math.sin(th)) / ((kx * kx) * kx)) * -0.5) * 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-71)
                        		tmp = Float64(Float64(Float64(Float64(Float64(ky * ky) * sin(th)) / Float64(Float64(kx * kx) * kx)) * -0.5) * 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-71)
                        		tmp = ((((ky * ky) * sin(th)) / ((kx * kx) * kx)) * -0.5) * 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-71], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[(N[(kx * kx), $MachinePrecision] * kx), $MachinePrecision]), $MachinePrecision] * -0.5), $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^{-71}:\\
                        \;\;\;\;\left(\frac{\left(ky \cdot ky\right) \cdot \sin th}{\left(kx \cdot kx\right) \cdot kx} \cdot -0.5\right) \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.9999999999999992e-72

                          1. Initial program 95.7%

                            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                          2. Add Preprocessing
                          3. Taylor expanded in 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 rewrites22.6%

                            \[\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 kx around 0

                            \[\leadsto \left(\frac{-1}{2} \cdot \frac{{ky}^{2} \cdot \sin th}{{kx}^{3}}\right) \cdot ky \]
                          7. Step-by-step derivation
                            1. Applied rewrites9.1%

                              \[\leadsto \left(\frac{\left(ky \cdot ky\right) \cdot \sin th}{\left(kx \cdot kx\right) \cdot kx} \cdot -0.5\right) \cdot ky \]

                            if 9.9999999999999992e-72 < (/.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 97.4%

                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                            2. Add Preprocessing
                            3. Taylor expanded in kx around 0

                              \[\leadsto \color{blue}{\sin th} \]
                            4. Step-by-step derivation
                              1. lower-sin.f6461.1

                                \[\leadsto \color{blue}{\sin th} \]
                            5. Applied rewrites61.1%

                              \[\leadsto \color{blue}{\sin th} \]
                          8. Recombined 2 regimes into one program.
                          9. Final simplification25.8%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-71}:\\ \;\;\;\;\left(\frac{\left(ky \cdot ky\right) \cdot \sin th}{\left(kx \cdot kx\right) \cdot kx} \cdot -0.5\right) \cdot ky\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                          10. Add Preprocessing

                          Alternative 17: 99.4% accurate, 1.0× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx\right)} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th}{\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\\ \end{array} \end{array} \]
                          (FPCore (kx ky th)
                           :precision binary64
                           (if (<= (pow (sin kx) 2.0) 5e-9)
                             (*
                              (/
                               (sin ky)
                               (hypot (sin ky) (* (fma -0.16666666666666666 (* kx kx) 1.0) kx)))
                              (sin th))
                             (*
                              (/
                               (sin th)
                               (sqrt (fma (- 1.0 (cos (+ ky ky))) 0.5 (* (- 1.0 (cos (+ kx kx))) 0.5))))
                              (sin ky))))
                          double code(double kx, double ky, double th) {
                          	double tmp;
                          	if (pow(sin(kx), 2.0) <= 5e-9) {
                          		tmp = (sin(ky) / hypot(sin(ky), (fma(-0.16666666666666666, (kx * kx), 1.0) * kx))) * sin(th);
                          	} else {
                          		tmp = (sin(th) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((1.0 - cos((kx + kx))) * 0.5)))) * sin(ky);
                          	}
                          	return tmp;
                          }
                          
                          function code(kx, ky, th)
                          	tmp = 0.0
                          	if ((sin(kx) ^ 2.0) <= 5e-9)
                          		tmp = Float64(Float64(sin(ky) / hypot(sin(ky), Float64(fma(-0.16666666666666666, Float64(kx * kx), 1.0) * kx))) * sin(th));
                          	else
                          		tmp = Float64(Float64(sin(th) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5)))) * sin(ky));
                          	end
                          	return tmp
                          end
                          
                          code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 5e-9], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * kx), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $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[ky], $MachinePrecision]), $MachinePrecision]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;{\sin kx}^{2} \leq 5 \cdot 10^{-9}:\\
                          \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx\right)} \cdot \sin th\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\frac{\sin th}{\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\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 5.0000000000000001e-9

                            1. Initial program 92.6%

                              \[\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.9

                                \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                            4. Applied rewrites99.9%

                              \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                            5. Taylor expanded in kx around 0

                              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)} \cdot \sin th \]
                            6. Step-by-step derivation
                              1. *-commutativeN/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right) \cdot kx}\right)} \cdot \sin th \]
                              2. lower-*.f64N/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right) \cdot kx}\right)} \cdot \sin th \]
                              3. +-commutativeN/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2} + 1\right)} \cdot kx\right)} \cdot \sin th \]
                              4. lower-fma.f64N/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(\frac{-1}{6}, {kx}^{2}, 1\right)} \cdot kx\right)} \cdot \sin th \]
                              5. unpow2N/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{kx \cdot kx}, 1\right) \cdot kx\right)} \cdot \sin th \]
                              6. lower-*.f6499.9

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right) \cdot kx\right)} \cdot \sin th \]
                            7. Applied rewrites99.9%

                              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx}\right)} \cdot \sin th \]

                            if 5.0000000000000001e-9 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

                            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 \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
                              2. lift-/.f64N/A

                                \[\leadsto \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                              3. associate-*l/N/A

                                \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                              4. associate-/l*N/A

                                \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                              5. *-commutativeN/A

                                \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                              6. lower-*.f64N/A

                                \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin ky} \]
                            4. Applied rewrites99.0%

                              \[\leadsto \color{blue}{\frac{\sin th}{\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} \]
                          3. Recombined 2 regimes into one program.
                          4. Add Preprocessing

                          Alternative 18: 99.4% accurate, 1.0× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot 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 (<= (pow (sin kx) 2.0) 5e-9)
                             (*
                              (/
                               (sin ky)
                               (hypot (sin ky) (* (fma -0.16666666666666666 (* kx kx) 1.0) 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 (pow(sin(kx), 2.0) <= 5e-9) {
                          		tmp = (sin(ky) / hypot(sin(ky), (fma(-0.16666666666666666, (kx * kx), 1.0) * 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 ((sin(kx) ^ 2.0) <= 5e-9)
                          		tmp = Float64(Float64(sin(ky) / hypot(sin(ky), Float64(fma(-0.16666666666666666, Float64(kx * kx), 1.0) * 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[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 5e-9], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * 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}\;{\sin kx}^{2} \leq 5 \cdot 10^{-9}:\\
                          \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot 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 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 5.0000000000000001e-9

                            1. Initial program 92.6%

                              \[\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.9

                                \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                            4. Applied rewrites99.9%

                              \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                            5. Taylor expanded in kx around 0

                              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)} \cdot \sin th \]
                            6. Step-by-step derivation
                              1. *-commutativeN/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right) \cdot kx}\right)} \cdot \sin th \]
                              2. lower-*.f64N/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right) \cdot kx}\right)} \cdot \sin th \]
                              3. +-commutativeN/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2} + 1\right)} \cdot kx\right)} \cdot \sin th \]
                              4. lower-fma.f64N/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(\frac{-1}{6}, {kx}^{2}, 1\right)} \cdot kx\right)} \cdot \sin th \]
                              5. unpow2N/A

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{kx \cdot kx}, 1\right) \cdot kx\right)} \cdot \sin th \]
                              6. lower-*.f6499.9

                                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, \color{blue}{kx \cdot kx}, 1\right) \cdot kx\right)} \cdot \sin th \]
                            7. Applied rewrites99.9%

                              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx}\right)} \cdot \sin th \]

                            if 5.0000000000000001e-9 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

                            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.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 rewrites98.9%

                              \[\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 19: 15.4% 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 8 \cdot 10^{-297}:\\ \;\;\;\;\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))
                                8e-297)
                             (* (* (* 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)) <= 8e-297) {
                          		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)) <= 8d-297) 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)) <= 8e-297) {
                          		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)) <= 8e-297:
                          		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)) <= 8e-297)
                          		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)) <= 8e-297)
                          		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], 8e-297], 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 8 \cdot 10^{-297}:\\
                          \;\;\;\;\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)) < 8.00000000000000032e-297

                            1. Initial program 96.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.f6421.1

                                \[\leadsto \color{blue}{\sin th} \]
                            5. Applied rewrites21.1%

                              \[\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 rewrites11.3%

                                \[\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 rewrites11.7%

                                  \[\leadsto \left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666 \]

                                if 8.00000000000000032e-297 < (*.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.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.f6422.5

                                    \[\leadsto \color{blue}{\sin th} \]
                                5. Applied rewrites22.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 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.6%

                                      \[\leadsto 1 \cdot th \]
                                  4. Recombined 2 regimes into one program.
                                  5. Final simplification13.6%

                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \sin th \leq 8 \cdot 10^{-297}:\\ \;\;\;\;\left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;1 \cdot th\\ \end{array} \]
                                  6. Add Preprocessing

                                  Alternative 20: 30.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^{-61}:\\ \;\;\;\;\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)))) 1e-61)
                                     (* (* (* 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)))) <= 1e-61) {
                                  		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)))) <= 1d-61) 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)))) <= 1e-61) {
                                  		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)))) <= 1e-61:
                                  		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)))) <= 1e-61)
                                  		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)))) <= 1e-61)
                                  		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], 1e-61], 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 10^{-61}:\\
                                  \;\;\;\;\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))))) < 1e-61

                                    1. Initial program 95.7%

                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in kx around 0

                                      \[\leadsto \color{blue}{\sin th} \]
                                    4. Step-by-step derivation
                                      1. lower-sin.f643.3

                                        \[\leadsto \color{blue}{\sin th} \]
                                    5. Applied rewrites3.3%

                                      \[\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.1%

                                        \[\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 rewrites10.5%

                                          \[\leadsto \left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666 \]

                                        if 1e-61 < (/.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 97.4%

                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in kx around 0

                                          \[\leadsto \color{blue}{\sin th} \]
                                        4. Step-by-step derivation
                                          1. lower-sin.f6461.1

                                            \[\leadsto \color{blue}{\sin th} \]
                                        5. Applied rewrites61.1%

                                          \[\leadsto \color{blue}{\sin th} \]
                                      4. Recombined 2 regimes into one program.
                                      5. Final simplification26.7%

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-61}:\\ \;\;\;\;\left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                      6. Add Preprocessing

                                      Alternative 21: 67.4% accurate, 1.8× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 170000000000:\\ \;\;\;\;\frac{\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot 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 th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}}\\ \end{array} \end{array} \]
                                      (FPCore (kx ky th)
                                       :precision binary64
                                       (if (<= ky 170000000000.0)
                                         (*
                                          (/
                                           (* (fma (* ky ky) -0.16666666666666666 1.0) ky)
                                           (hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
                                          (sin th))
                                         (/ (* (sin th) (sin ky)) (sqrt (* (- 1.0 (cos (* 2.0 ky))) 0.5)))))
                                      double code(double kx, double ky, double th) {
                                      	double tmp;
                                      	if (ky <= 170000000000.0) {
                                      		tmp = ((fma((ky * ky), -0.16666666666666666, 1.0) * ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
                                      	} else {
                                      		tmp = (sin(th) * sin(ky)) / sqrt(((1.0 - cos((2.0 * ky))) * 0.5));
                                      	}
                                      	return tmp;
                                      }
                                      
                                      function code(kx, ky, th)
                                      	tmp = 0.0
                                      	if (ky <= 170000000000.0)
                                      		tmp = Float64(Float64(Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th));
                                      	else
                                      		tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(Float64(1.0 - cos(Float64(2.0 * ky))) * 0.5)));
                                      	end
                                      	return tmp
                                      end
                                      
                                      code[kx_, ky_, th_] := If[LessEqual[ky, 170000000000.0], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * 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[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;ky \leq 170000000000:\\
                                      \;\;\;\;\frac{\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot 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 th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}}\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if ky < 1.7e11

                                        1. Initial program 95.2%

                                          \[\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.6

                                            \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                        4. Applied rewrites99.6%

                                          \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                        5. Taylor expanded in ky around 0

                                          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky \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-*.f6461.5

                                            \[\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 rewrites61.5%

                                          \[\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 \]
                                        8. Taylor expanded in ky around 0

                                          \[\leadsto \frac{\color{blue}{ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)}}{\mathsf{hypot}\left(\mathsf{fma}\left(\frac{-1}{6}, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th \]
                                        9. Step-by-step derivation
                                          1. *-commutativeN/A

                                            \[\leadsto \frac{\color{blue}{\left(1 + \frac{-1}{6} \cdot {ky}^{2}\right) \cdot ky}}{\mathsf{hypot}\left(\mathsf{fma}\left(\frac{-1}{6}, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th \]
                                          2. lower-*.f64N/A

                                            \[\leadsto \frac{\color{blue}{\left(1 + \frac{-1}{6} \cdot {ky}^{2}\right) \cdot ky}}{\mathsf{hypot}\left(\mathsf{fma}\left(\frac{-1}{6}, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th \]
                                          3. +-commutativeN/A

                                            \[\leadsto \frac{\color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2} + 1\right)} \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(\frac{-1}{6}, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th \]
                                          4. *-commutativeN/A

                                            \[\leadsto \frac{\left(\color{blue}{{ky}^{2} \cdot \frac{-1}{6}} + 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(\frac{-1}{6}, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th \]
                                          5. lower-fma.f64N/A

                                            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({ky}^{2}, \frac{-1}{6}, 1\right)} \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(\frac{-1}{6}, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th \]
                                          6. unpow2N/A

                                            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{ky \cdot ky}, \frac{-1}{6}, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(\frac{-1}{6}, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th \]
                                          7. lower-*.f6462.1

                                            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{ky \cdot ky}, -0.16666666666666666, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th \]
                                        10. Applied rewrites62.1%

                                          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky}}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th \]

                                        if 1.7e11 < 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 \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
                                          2. *-commutativeN/A

                                            \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                          3. lift-/.f64N/A

                                            \[\leadsto \sin th \cdot \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                                          4. clear-numN/A

                                            \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                                          5. un-div-invN/A

                                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                                          6. lower-/.f64N/A

                                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                                          7. lower-/.f6499.7

                                            \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
                                        4. Applied rewrites99.0%

                                          \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}} \]
                                        5. Taylor expanded in kx around 0

                                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}{\sin ky}} \]
                                        6. Step-by-step derivation
                                          1. *-commutativeN/A

                                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                                          2. lower-*.f64N/A

                                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}}{\sin ky}} \]
                                          3. metadata-evalN/A

                                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                                          4. distribute-lft-neg-inN/A

                                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                                          5. lower--.f64N/A

                                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}}{\sin ky}} \]
                                          6. lower-cos.f64N/A

                                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                                          7. distribute-lft-neg-inN/A

                                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                                          8. metadata-evalN/A

                                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                                          9. *-commutativeN/A

                                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}}{\sin ky}} \]
                                          10. lower-*.f6465.0

                                            \[\leadsto \frac{\sin th}{\frac{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}}{\sin ky}} \]
                                        7. Applied rewrites65.0%

                                          \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}}{\sin ky}} \]
                                        8. Step-by-step derivation
                                          1. lift-/.f64N/A

                                            \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                                          2. lift-/.f64N/A

                                            \[\leadsto \frac{\sin th}{\color{blue}{\frac{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}{\sin ky}}} \]
                                          3. associate-/r/N/A

                                            \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \cdot \sin ky} \]
                                          4. associate-*l/N/A

                                            \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \]
                                          5. *-commutativeN/A

                                            \[\leadsto \frac{\color{blue}{\sin ky \cdot \sin th}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \]
                                          6. lower-/.f64N/A

                                            \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}}} \]
                                          7. *-commutativeN/A

                                            \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot \frac{1}{2}}} \]
                                          8. lower-*.f6465.1

                                            \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}} \]
                                        9. Applied rewrites11.1%

                                          \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}} \]
                                        10. Taylor expanded in kx around 0

                                          \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
                                        11. Step-by-step derivation
                                          1. *-commutativeN/A

                                            \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}} \]
                                          2. lower-*.f64N/A

                                            \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot \frac{1}{2}}}} \]
                                          3. metadata-evalN/A

                                            \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right) \cdot \frac{1}{2}}} \]
                                          4. distribute-lft-neg-inN/A

                                            \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}} \]
                                          5. lower--.f64N/A

                                            \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)} \cdot \frac{1}{2}}} \]
                                          6. lower-cos.f64N/A

                                            \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right) \cdot \frac{1}{2}}} \]
                                          7. distribute-lft-neg-inN/A

                                            \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot ky\right)}\right) \cdot \frac{1}{2}}} \]
                                          8. metadata-evalN/A

                                            \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(\color{blue}{2} \cdot ky\right)\right) \cdot \frac{1}{2}}} \]
                                          9. *-commutativeN/A

                                            \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot \frac{1}{2}}} \]
                                          10. lower-*.f6465.1

                                            \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \color{blue}{\left(ky \cdot 2\right)}\right) \cdot 0.5}} \]
                                        12. Applied rewrites65.1%

                                          \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\left(1 - \cos \left(ky \cdot 2\right)\right) \cdot 0.5}}} \]
                                      3. Recombined 2 regimes into one program.
                                      4. Final simplification62.8%

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 170000000000:\\ \;\;\;\;\frac{\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot 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 th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}}\\ \end{array} \]
                                      5. Add Preprocessing

                                      Alternative 22: 13.6% 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 96.2%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in kx around 0

                                        \[\leadsto \color{blue}{\sin th} \]
                                      4. Step-by-step derivation
                                        1. lower-sin.f6421.8

                                          \[\leadsto \color{blue}{\sin th} \]
                                      5. Applied rewrites21.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 rewrites13.3%

                                          \[\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 rewrites13.7%

                                            \[\leadsto 1 \cdot th \]
                                          2. Add Preprocessing

                                          Reproduce

                                          ?
                                          herbie shell --seed 2024235 
                                          (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)))