Toniolo and Linder, Equation (3b), real

Percentage Accurate: 93.4% → 99.7%
Time: 12.9s
Alternatives: 27
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 27 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.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
	return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
	return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th):
	return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th)
	return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th))
end
function tmp = code(kx, ky, th)
	tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th);
end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}

Alternative 1: 99.7% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
	return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
	return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th):
	return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th)
	return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th))
end
function tmp = code(kx, ky, th)
	tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\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. Add Preprocessing

Alternative 2: 80.0% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_2 \leq -0.2:\\
\;\;\;\;t\_3\\

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

\mathbf{elif}\;t\_2 \leq 0.99:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq 1:\\
\;\;\;\;\sin th\\

\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(t\_1, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\


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

    1. Initial program 81.9%

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot \sin th \]
      2. lower-*.f6481.9

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

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot \sin th \]
    6. Applied rewrites58.7%

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

    if -0.998999999999999999 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.20000000000000001 or 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.98999999999999999

    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. 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 rewrites97.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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

    1. Initial program 98.3%

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

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

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

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

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

    1. Initial program 2.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)}\right)} \cdot \sin th \]
    8. 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)}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
    9. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\mathsf{fma}\left(ky, \left(ky \cdot ky\right) \cdot -0.16666666666666666, ky\right)}, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
  3. Recombined 5 regimes into one program.
  4. Final simplification78.0%

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

Alternative 3: 62.5% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-277}:\\
\;\;\;\;\sin ky \cdot \left(th \cdot \sqrt{\frac{1}{t\_1}}\right)\\

\mathbf{elif}\;t\_2 \leq 10^{-77}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\

\mathbf{elif}\;t\_2 \leq 0.99:\\
\;\;\;\;\sin ky \cdot \frac{th}{\sqrt{t\_1}}\\

\mathbf{elif}\;t\_2 \leq 1:\\
\;\;\;\;\sin th\\

\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right), \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\


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

    1. Initial program 81.9%

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot \sin th \]
      2. lower-*.f6481.9

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

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot \sin th \]
    6. Applied rewrites58.7%

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

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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5e-277 < (/.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.9999999999999993e-78

    1. Initial program 99.8%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Taylor expanded in 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. lower-*.f64N/A

        \[\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)} \]
      2. distribute-lft-inN/A

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

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

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

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

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

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

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

      if 9.9999999999999993e-78 < (/.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.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. 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 rewrites92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}} \]
      11. Step-by-step derivation
        1. Applied rewrites51.1%

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

        1. Initial program 98.3%

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

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

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

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

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

        1. Initial program 2.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)}\right)} \cdot \sin th \]
        8. 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)}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
        9. Step-by-step derivation
          1. +-commutativeN/A

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\mathsf{fma}\left(ky, \left(ky \cdot ky\right) \cdot -0.16666666666666666, ky\right)}, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
      12. Recombined 6 regimes into one program.
      13. Final simplification63.9%

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

      Alternative 4: 62.5% accurate, 0.2× speedup?

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

        1. Initial program 81.9%

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

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

            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot \sin th \]
          2. lower-*.f6481.9

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

          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot \sin th \]
        6. Applied rewrites58.7%

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

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

        1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 5e-277 < (/.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.9999999999999993e-78

          1. Initial program 99.8%

            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
          2. Add Preprocessing
          3. Taylor expanded in 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. lower-*.f64N/A

              \[\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)} \]
            2. distribute-lft-inN/A

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

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

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

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

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

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

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

            if 9.9999999999999993e-78 < (/.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.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. 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 rewrites92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}} \]
            11. Step-by-step derivation
              1. Applied rewrites51.1%

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

              1. Initial program 98.3%

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

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

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

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

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

              1. Initial program 2.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)}\right)} \cdot \sin th \]
              8. 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)}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
              9. Step-by-step derivation
                1. +-commutativeN/A

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\mathsf{fma}\left(ky, \left(ky \cdot ky\right) \cdot -0.16666666666666666, ky\right)}, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
            12. Recombined 6 regimes into one program.
            13. Final simplification63.9%

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

            Alternative 5: 62.4% accurate, 0.2× speedup?

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

              1. Initial program 81.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. 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 rewrites56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              1. Initial program 99.6%

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

                  \[\leadsto \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 rewrites75.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if 5e-277 < (/.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.9999999999999993e-78

              1. Initial program 99.8%

                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
              2. Add Preprocessing
              3. Taylor expanded in 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. lower-*.f64N/A

                  \[\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)} \]
                2. distribute-lft-inN/A

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

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

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

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

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

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

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

                if 9.9999999999999993e-78 < (/.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.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. 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 rewrites92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}} \]
                11. Step-by-step derivation
                  1. Applied rewrites51.1%

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

                  1. Initial program 98.3%

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

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

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

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

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

                  1. Initial program 2.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)}\right)} \cdot \sin th \]
                  8. 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)}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                  9. Step-by-step derivation
                    1. +-commutativeN/A

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\mathsf{fma}\left(ky, \left(ky \cdot ky\right) \cdot -0.16666666666666666, ky\right)}, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                12. Recombined 6 regimes into one program.
                13. Final simplification63.8%

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

                Alternative 6: 62.4% accurate, 0.2× speedup?

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

                  1. Initial program 81.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. 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 rewrites56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  1. Initial program 99.6%

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

                      \[\leadsto \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 rewrites75.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}} \]
                  11. Step-by-step derivation
                    1. Applied rewrites47.5%

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

                    if 5e-277 < (/.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.9999999999999993e-78

                    1. Initial program 99.8%

                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                    2. Add Preprocessing
                    3. Taylor expanded in 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. lower-*.f64N/A

                        \[\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)} \]
                      2. distribute-lft-inN/A

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

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

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

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

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

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

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

                      if 9.9999999999999993e-78 < (/.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.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. 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 rewrites92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \color{blue}{\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}} \]
                      11. Step-by-step derivation
                        1. Applied rewrites51.1%

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

                        1. Initial program 98.3%

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

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

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

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

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

                        1. Initial program 2.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)}\right)} \cdot \sin th \]
                        8. 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)}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                        9. Step-by-step derivation
                          1. +-commutativeN/A

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

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

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

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

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

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

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

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

                          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\mathsf{fma}\left(ky, \left(ky \cdot ky\right) \cdot -0.16666666666666666, ky\right)}, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                      12. Recombined 6 regimes into one program.
                      13. Final simplification63.8%

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

                      Alternative 7: 62.4% accurate, 0.2× speedup?

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

                        1. Initial program 81.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. 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 rewrites56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        if -1 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 5e-277 or 9.9999999999999993e-78 < (/.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.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. 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 rewrites82.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          if 5e-277 < (/.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.9999999999999993e-78

                          1. Initial program 99.8%

                            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                          2. Add Preprocessing
                          3. Taylor expanded in 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. lower-*.f64N/A

                              \[\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)} \]
                            2. distribute-lft-inN/A

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

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

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

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

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

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

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

                            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

                            1. Initial program 98.3%

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

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

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

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

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

                            1. Initial program 2.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)}\right)} \cdot \sin th \]
                            8. 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)}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                            9. Step-by-step derivation
                              1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                          Alternative 8: 87.4% accurate, 0.2× speedup?

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

                              \[\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, kx \cdot \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2} + 1\right)}\right)} \cdot \sin th \]
                              2. distribute-lft-inN/A

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

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

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

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

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

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

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

                            if -0.998999999999999999 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.20000000000000001 or 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.98999999999999999

                            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. 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 rewrites97.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          Alternative 9: 58.8% accurate, 0.3× speedup?

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

                            1. Initial program 85.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. 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 rewrites67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            1. Initial program 99.7%

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

                              \[\leadsto \color{blue}{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. lower-*.f64N/A

                                \[\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)} \]
                              2. distribute-lft-inN/A

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

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

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

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

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

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

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

                              if 1.99999999999999992e-80 < (/.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.69999999999999996

                              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. 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 rewrites92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              if 0.69999999999999996 < (/.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 87.5%

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

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

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

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

                            Alternative 10: 58.4% accurate, 0.3× speedup?

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

                              1. Initial program 85.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. 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 rewrites67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              1. Initial program 99.7%

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

                                \[\leadsto \color{blue}{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. lower-*.f64N/A

                                  \[\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)} \]
                                2. distribute-lft-inN/A

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

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

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

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

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

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

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

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

                                1. Initial program 99.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 rewrites80.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                1. Initial program 90.2%

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

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

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

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

                              Alternative 11: 51.2% accurate, 0.3× speedup?

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

                                1. Initial program 81.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. 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 rewrites58.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  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.99999999999999992e-80

                                  1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

                                  1. Initial program 99.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 rewrites80.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \]
                                    14. *-commutativeN/A

                                      \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \]
                                    15. lower-*.f6479.0

                                      \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \]
                                  7. Applied rewrites79.0%

                                    \[\leadsto \color{blue}{\left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}}} \]

                                  if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                  1. Initial program 90.2%

                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in kx around 0

                                    \[\leadsto \color{blue}{\sin th} \]
                                  4. Step-by-step derivation
                                    1. lower-sin.f6463.1

                                      \[\leadsto \color{blue}{\sin th} \]
                                  5. Applied rewrites63.1%

                                    \[\leadsto \color{blue}{\sin th} \]
                                13. Recombined 4 regimes into one program.
                                14. Add Preprocessing

                                Alternative 12: 51.2% accurate, 0.3× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.2:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-80}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{elif}\;t\_1 \leq 10^{-7}:\\ \;\;\;\;\left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                (FPCore (kx ky th)
                                 :precision binary64
                                 (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
                                   (if (<= t_1 -0.2)
                                     (* (* (sin ky) th) (sqrt (/ 1.0 (fma -0.5 (cos (* ky -2.0)) 0.5))))
                                     (if (<= t_1 2e-80)
                                       (* ky (/ (sin th) (sin kx)))
                                       (if (<= t_1 1e-7)
                                         (*
                                          (* (* ky (sin th)) (sqrt 2.0))
                                          (sqrt (/ 1.0 (- 1.0 (cos (* kx -2.0))))))
                                         (sin th))))))
                                double code(double kx, double ky, double th) {
                                	double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
                                	double tmp;
                                	if (t_1 <= -0.2) {
                                		tmp = (sin(ky) * th) * sqrt((1.0 / fma(-0.5, cos((ky * -2.0)), 0.5)));
                                	} else if (t_1 <= 2e-80) {
                                		tmp = ky * (sin(th) / sin(kx));
                                	} else if (t_1 <= 1e-7) {
                                		tmp = ((ky * sin(th)) * sqrt(2.0)) * sqrt((1.0 / (1.0 - cos((kx * -2.0)))));
                                	} else {
                                		tmp = sin(th);
                                	}
                                	return tmp;
                                }
                                
                                function code(kx, ky, th)
                                	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
                                	tmp = 0.0
                                	if (t_1 <= -0.2)
                                		tmp = Float64(Float64(sin(ky) * th) * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(ky * -2.0)), 0.5))));
                                	elseif (t_1 <= 2e-80)
                                		tmp = Float64(ky * Float64(sin(th) / sin(kx)));
                                	elseif (t_1 <= 1e-7)
                                		tmp = Float64(Float64(Float64(ky * sin(th)) * sqrt(2.0)) * sqrt(Float64(1.0 / Float64(1.0 - cos(Float64(kx * -2.0))))));
                                	else
                                		tmp = sin(th);
                                	end
                                	return tmp
                                end
                                
                                code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.2], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-80], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], N[(N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(1.0 - N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
                                \mathbf{if}\;t\_1 \leq -0.2:\\
                                \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\
                                
                                \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-80}:\\
                                \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
                                
                                \mathbf{elif}\;t\_1 \leq 10^{-7}:\\
                                \;\;\;\;\left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}}\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\sin th\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 4 regimes
                                2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.20000000000000001

                                  1. Initial program 85.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. 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 rewrites67.4%

                                    \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                  5. Taylor expanded in ky around 0

                                    \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin ky \]
                                  6. Step-by-step derivation
                                    1. *-commutativeN/A

                                      \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}} \cdot \sin ky \]
                                    2. lower-*.f64N/A

                                      \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}} \cdot \sin ky \]
                                    3. lower-sqrt.f64N/A

                                      \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                    4. metadata-evalN/A

                                      \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                    5. distribute-lft-neg-inN/A

                                      \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                    6. lower--.f64N/A

                                      \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                    7. cos-negN/A

                                      \[\leadsto \frac{\sin th}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                    8. lower-cos.f64N/A

                                      \[\leadsto \frac{\sin th}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                    9. *-commutativeN/A

                                      \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                    10. lower-*.f64N/A

                                      \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                    11. lower-sqrt.f646.8

                                      \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\sqrt{0.5}}} \cdot \sin ky \]
                                  7. Applied rewrites6.8%

                                    \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}} \cdot \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} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\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} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                    2. *-commutativeN/A

                                      \[\leadsto \color{blue}{\left(\sin ky \cdot th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                    3. lower-*.f64N/A

                                      \[\leadsto \color{blue}{\left(\sin ky \cdot th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                    4. lower-sin.f64N/A

                                      \[\leadsto \left(\color{blue}{\sin ky} \cdot th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                    5. lower-sqrt.f64N/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                    6. lower-/.f64N/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                    7. associate-+r+N/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)}}} \]
                                    8. +-commutativeN/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right) + \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
                                    9. lower-fma.f64N/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(2 \cdot kx\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
                                    10. metadata-evalN/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                    11. distribute-lft-neg-inN/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                    12. lower--.f64N/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, \color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                    13. cos-negN/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                    14. lower-cos.f64N/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                    15. *-commutativeN/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                    16. lower-*.f64N/A

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                  10. Applied rewrites35.7%

                                    \[\leadsto \color{blue}{\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}} \]
                                  11. Taylor expanded in kx around 0

                                    \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(-2 \cdot ky\right)}} \]
                                  12. Step-by-step derivation
                                    1. Applied rewrites27.1%

                                      \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}} \]

                                    if -0.20000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 1.99999999999999992e-80

                                    1. Initial program 99.7%

                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in ky around 0

                                      \[\leadsto \color{blue}{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. lower-*.f64N/A

                                        \[\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)} \]
                                      2. distribute-lft-inN/A

                                        \[\leadsto ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right)\right)} + \frac{\sin th}{\sin kx}\right) \]
                                      3. *-commutativeN/A

                                        \[\leadsto ky \cdot \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right)\right) + \frac{\sin th}{\sin kx}\right) \]
                                      4. associate-+r+N/A

                                        \[\leadsto ky \cdot \color{blue}{\left(\left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2} + \left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right) + \frac{\sin th}{\sin kx}\right)\right)} \]
                                      5. +-commutativeN/A

                                        \[\leadsto ky \cdot \color{blue}{\left(\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right) + \frac{\sin th}{\sin kx}\right) + \left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2}\right)} \]
                                    5. Applied rewrites68.1%

                                      \[\leadsto \color{blue}{ky \cdot \mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right), \frac{\sin th}{\sin kx}, \frac{\left(ky \cdot ky\right) \cdot \left(-0.5 \cdot \sin th\right)}{{\sin kx}^{3}}\right)} \]
                                    6. Taylor expanded in ky around 0

                                      \[\leadsto ky \cdot \frac{\sin th}{\color{blue}{\sin kx}} \]
                                    7. Step-by-step derivation
                                      1. Applied rewrites74.8%

                                        \[\leadsto ky \cdot \frac{\sin th}{\color{blue}{\sin kx}} \]

                                      if 1.99999999999999992e-80 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                      1. Initial program 99.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 rewrites80.0%

                                        \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                      5. Taylor expanded in ky around 0

                                        \[\leadsto \color{blue}{\left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}}} \]
                                      6. Step-by-step derivation
                                        1. lower-*.f64N/A

                                          \[\leadsto \color{blue}{\left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}}} \]
                                        2. associate-*r*N/A

                                          \[\leadsto \color{blue}{\left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right)} \cdot \sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}} \]
                                        3. lower-*.f64N/A

                                          \[\leadsto \color{blue}{\left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right)} \cdot \sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}} \]
                                        4. lower-*.f64N/A

                                          \[\leadsto \left(\color{blue}{\left(ky \cdot \sin th\right)} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}} \]
                                        5. lower-sin.f64N/A

                                          \[\leadsto \left(\left(ky \cdot \color{blue}{\sin th}\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}} \]
                                        6. lower-sqrt.f64N/A

                                          \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \color{blue}{\sqrt{2}}\right) \cdot \sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}} \]
                                        7. lower-sqrt.f64N/A

                                          \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}}} \]
                                        8. lower-/.f64N/A

                                          \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\color{blue}{\frac{1}{1 - \cos \left(2 \cdot kx\right)}}} \]
                                        9. metadata-evalN/A

                                          \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)}} \]
                                        10. distribute-lft-neg-inN/A

                                          \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \]
                                        11. lower--.f64N/A

                                          \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \]
                                        12. cos-negN/A

                                          \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \]
                                        13. lower-cos.f64N/A

                                          \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \]
                                        14. *-commutativeN/A

                                          \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \]
                                        15. lower-*.f6479.0

                                          \[\leadsto \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \]
                                      7. Applied rewrites79.0%

                                        \[\leadsto \color{blue}{\left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}}} \]

                                      if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                      1. Initial program 90.2%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in kx around 0

                                        \[\leadsto \color{blue}{\sin th} \]
                                      4. Step-by-step derivation
                                        1. lower-sin.f6463.1

                                          \[\leadsto \color{blue}{\sin th} \]
                                      5. Applied rewrites63.1%

                                        \[\leadsto \color{blue}{\sin th} \]
                                    8. Recombined 4 regimes into one program.
                                    9. Add Preprocessing

                                    Alternative 13: 49.8% accurate, 0.3× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin ky \cdot th\\ t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_2 \leq -0.2:\\ \;\;\;\;t\_1 \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;t\_2 \leq 10^{-77}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{elif}\;t\_2 \leq 10^{-7}:\\ \;\;\;\;t\_1 \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), ky \cdot ky\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                    (FPCore (kx ky th)
                                     :precision binary64
                                     (let* ((t_1 (* (sin ky) th))
                                            (t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
                                       (if (<= t_2 -0.2)
                                         (* t_1 (sqrt (/ 1.0 (fma -0.5 (cos (* ky -2.0)) 0.5))))
                                         (if (<= t_2 1e-77)
                                           (* ky (/ (sin th) (sin kx)))
                                           (if (<= t_2 1e-7)
                                             (* t_1 (sqrt (/ 1.0 (fma 0.5 (- 1.0 (cos (* kx -2.0))) (* ky ky)))))
                                             (sin th))))))
                                    double code(double kx, double ky, double th) {
                                    	double t_1 = sin(ky) * th;
                                    	double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
                                    	double tmp;
                                    	if (t_2 <= -0.2) {
                                    		tmp = t_1 * sqrt((1.0 / fma(-0.5, cos((ky * -2.0)), 0.5)));
                                    	} else if (t_2 <= 1e-77) {
                                    		tmp = ky * (sin(th) / sin(kx));
                                    	} else if (t_2 <= 1e-7) {
                                    		tmp = t_1 * sqrt((1.0 / fma(0.5, (1.0 - cos((kx * -2.0))), (ky * ky))));
                                    	} else {
                                    		tmp = sin(th);
                                    	}
                                    	return tmp;
                                    }
                                    
                                    function code(kx, ky, th)
                                    	t_1 = Float64(sin(ky) * th)
                                    	t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
                                    	tmp = 0.0
                                    	if (t_2 <= -0.2)
                                    		tmp = Float64(t_1 * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(ky * -2.0)), 0.5))));
                                    	elseif (t_2 <= 1e-77)
                                    		tmp = Float64(ky * Float64(sin(th) / sin(kx)));
                                    	elseif (t_2 <= 1e-7)
                                    		tmp = Float64(t_1 * sqrt(Float64(1.0 / fma(0.5, Float64(1.0 - cos(Float64(kx * -2.0))), Float64(ky * ky)))));
                                    	else
                                    		tmp = sin(th);
                                    	end
                                    	return tmp
                                    end
                                    
                                    code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.2], N[(t$95$1 * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e-77], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e-7], N[(t$95$1 * N[Sqrt[N[(1.0 / N[(0.5 * N[(1.0 - N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    t_1 := \sin ky \cdot th\\
                                    t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
                                    \mathbf{if}\;t\_2 \leq -0.2:\\
                                    \;\;\;\;t\_1 \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\
                                    
                                    \mathbf{elif}\;t\_2 \leq 10^{-77}:\\
                                    \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
                                    
                                    \mathbf{elif}\;t\_2 \leq 10^{-7}:\\
                                    \;\;\;\;t\_1 \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), ky \cdot ky\right)}}\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\sin th\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 4 regimes
                                    2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.20000000000000001

                                      1. Initial program 85.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. 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 rewrites67.4%

                                        \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                      5. Taylor expanded in ky around 0

                                        \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin ky \]
                                      6. Step-by-step derivation
                                        1. *-commutativeN/A

                                          \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}} \cdot \sin ky \]
                                        2. lower-*.f64N/A

                                          \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}} \cdot \sin ky \]
                                        3. lower-sqrt.f64N/A

                                          \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                        4. metadata-evalN/A

                                          \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                        5. distribute-lft-neg-inN/A

                                          \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                        6. lower--.f64N/A

                                          \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                        7. cos-negN/A

                                          \[\leadsto \frac{\sin th}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                        8. lower-cos.f64N/A

                                          \[\leadsto \frac{\sin th}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                        9. *-commutativeN/A

                                          \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                        10. lower-*.f64N/A

                                          \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                        11. lower-sqrt.f646.8

                                          \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\sqrt{0.5}}} \cdot \sin ky \]
                                      7. Applied rewrites6.8%

                                        \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}} \cdot \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} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\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} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                        2. *-commutativeN/A

                                          \[\leadsto \color{blue}{\left(\sin ky \cdot th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                        3. lower-*.f64N/A

                                          \[\leadsto \color{blue}{\left(\sin ky \cdot th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                        4. lower-sin.f64N/A

                                          \[\leadsto \left(\color{blue}{\sin ky} \cdot th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                        5. lower-sqrt.f64N/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                        6. lower-/.f64N/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                        7. associate-+r+N/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)}}} \]
                                        8. +-commutativeN/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right) + \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
                                        9. lower-fma.f64N/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(2 \cdot kx\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
                                        10. metadata-evalN/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                        11. distribute-lft-neg-inN/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                        12. lower--.f64N/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, \color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                        13. cos-negN/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                        14. lower-cos.f64N/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                        15. *-commutativeN/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                        16. lower-*.f64N/A

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                      10. Applied rewrites35.7%

                                        \[\leadsto \color{blue}{\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}} \]
                                      11. Taylor expanded in kx around 0

                                        \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(-2 \cdot ky\right)}} \]
                                      12. Step-by-step derivation
                                        1. Applied rewrites27.1%

                                          \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}} \]

                                        if -0.20000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999993e-78

                                        1. Initial program 99.7%

                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in ky around 0

                                          \[\leadsto \color{blue}{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. lower-*.f64N/A

                                            \[\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)} \]
                                          2. distribute-lft-inN/A

                                            \[\leadsto ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right)\right)} + \frac{\sin th}{\sin kx}\right) \]
                                          3. *-commutativeN/A

                                            \[\leadsto ky \cdot \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right)\right) + \frac{\sin th}{\sin kx}\right) \]
                                          4. associate-+r+N/A

                                            \[\leadsto ky \cdot \color{blue}{\left(\left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2} + \left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right) + \frac{\sin th}{\sin kx}\right)\right)} \]
                                          5. +-commutativeN/A

                                            \[\leadsto ky \cdot \color{blue}{\left(\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right) + \frac{\sin th}{\sin kx}\right) + \left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2}\right)} \]
                                        5. Applied rewrites67.3%

                                          \[\leadsto \color{blue}{ky \cdot \mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right), \frac{\sin th}{\sin kx}, \frac{\left(ky \cdot ky\right) \cdot \left(-0.5 \cdot \sin th\right)}{{\sin kx}^{3}}\right)} \]
                                        6. Taylor expanded in ky around 0

                                          \[\leadsto ky \cdot \frac{\sin th}{\color{blue}{\sin kx}} \]
                                        7. Step-by-step derivation
                                          1. Applied rewrites73.9%

                                            \[\leadsto ky \cdot \frac{\sin th}{\color{blue}{\sin kx}} \]

                                          if 9.9999999999999993e-78 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                          1. Initial program 99.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. 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 rewrites77.8%

                                            \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                          5. Taylor expanded in ky around 0

                                            \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin ky \]
                                          6. Step-by-step derivation
                                            1. *-commutativeN/A

                                              \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}} \cdot \sin ky \]
                                            2. lower-*.f64N/A

                                              \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}} \cdot \sin ky \]
                                            3. lower-sqrt.f64N/A

                                              \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                            4. metadata-evalN/A

                                              \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                            5. distribute-lft-neg-inN/A

                                              \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                            6. lower--.f64N/A

                                              \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                            7. cos-negN/A

                                              \[\leadsto \frac{\sin th}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                            8. lower-cos.f64N/A

                                              \[\leadsto \frac{\sin th}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                            9. *-commutativeN/A

                                              \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                            10. lower-*.f64N/A

                                              \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                            11. lower-sqrt.f6476.7

                                              \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\sqrt{0.5}}} \cdot \sin ky \]
                                          7. Applied rewrites76.7%

                                            \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}} \cdot \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} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\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} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                            2. *-commutativeN/A

                                              \[\leadsto \color{blue}{\left(\sin ky \cdot th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                            3. lower-*.f64N/A

                                              \[\leadsto \color{blue}{\left(\sin ky \cdot th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                            4. lower-sin.f64N/A

                                              \[\leadsto \left(\color{blue}{\sin ky} \cdot th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                            5. lower-sqrt.f64N/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                            6. lower-/.f64N/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                            7. associate-+r+N/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)}}} \]
                                            8. +-commutativeN/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right) + \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
                                            9. lower-fma.f64N/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(2 \cdot kx\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
                                            10. metadata-evalN/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                            11. distribute-lft-neg-inN/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                            12. lower--.f64N/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, \color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                            13. cos-negN/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                            14. lower-cos.f64N/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                            15. *-commutativeN/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                            16. lower-*.f64N/A

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                          10. Applied rewrites46.0%

                                            \[\leadsto \color{blue}{\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}} \]
                                          11. Taylor expanded in ky around 0

                                            \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(kx \cdot -2\right), {ky}^{2}\right)}} \]
                                          12. Step-by-step derivation
                                            1. Applied rewrites46.7%

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), ky \cdot ky\right)}} \]

                                            if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                            1. Initial program 90.2%

                                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in kx around 0

                                              \[\leadsto \color{blue}{\sin th} \]
                                            4. Step-by-step derivation
                                              1. lower-sin.f6463.1

                                                \[\leadsto \color{blue}{\sin th} \]
                                            5. Applied rewrites63.1%

                                              \[\leadsto \color{blue}{\sin th} \]
                                          13. Recombined 4 regimes into one program.
                                          14. Add Preprocessing

                                          Alternative 14: 50.4% accurate, 0.5× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.2:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;t\_1 \leq 10^{-7}:\\ \;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                          (FPCore (kx ky th)
                                           :precision binary64
                                           (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
                                             (if (<= t_1 -0.2)
                                               (* (* (sin ky) th) (sqrt (/ 1.0 (fma -0.5 (cos (* ky -2.0)) 0.5))))
                                               (if (<= t_1 1e-7)
                                                 (* (sin th) (/ (fma ky (* -0.16666666666666666 (* ky ky)) ky) (sin kx)))
                                                 (sin th)))))
                                          double code(double kx, double ky, double th) {
                                          	double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
                                          	double tmp;
                                          	if (t_1 <= -0.2) {
                                          		tmp = (sin(ky) * th) * sqrt((1.0 / fma(-0.5, cos((ky * -2.0)), 0.5)));
                                          	} else if (t_1 <= 1e-7) {
                                          		tmp = sin(th) * (fma(ky, (-0.16666666666666666 * (ky * ky)), ky) / sin(kx));
                                          	} else {
                                          		tmp = sin(th);
                                          	}
                                          	return tmp;
                                          }
                                          
                                          function code(kx, ky, th)
                                          	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
                                          	tmp = 0.0
                                          	if (t_1 <= -0.2)
                                          		tmp = Float64(Float64(sin(ky) * th) * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(ky * -2.0)), 0.5))));
                                          	elseif (t_1 <= 1e-7)
                                          		tmp = Float64(sin(th) * Float64(fma(ky, Float64(-0.16666666666666666 * Float64(ky * ky)), ky) / sin(kx)));
                                          	else
                                          		tmp = sin(th);
                                          	end
                                          	return tmp
                                          end
                                          
                                          code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.2], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], N[(N[Sin[th], $MachinePrecision] * N[(N[(ky * N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] + ky), $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
                                          \mathbf{if}\;t\_1 \leq -0.2:\\
                                          \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\
                                          
                                          \mathbf{elif}\;t\_1 \leq 10^{-7}:\\
                                          \;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{\sin kx}\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\sin th\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 3 regimes
                                          2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.20000000000000001

                                            1. Initial program 85.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. 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 rewrites67.4%

                                              \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                            5. Taylor expanded in ky around 0

                                              \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin ky \]
                                            6. Step-by-step derivation
                                              1. *-commutativeN/A

                                                \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}} \cdot \sin ky \]
                                              2. lower-*.f64N/A

                                                \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}} \cdot \sin ky \]
                                              3. lower-sqrt.f64N/A

                                                \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                              4. metadata-evalN/A

                                                \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                              5. distribute-lft-neg-inN/A

                                                \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                              6. lower--.f64N/A

                                                \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                              7. cos-negN/A

                                                \[\leadsto \frac{\sin th}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                              8. lower-cos.f64N/A

                                                \[\leadsto \frac{\sin th}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                              9. *-commutativeN/A

                                                \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                              10. lower-*.f64N/A

                                                \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                              11. lower-sqrt.f646.8

                                                \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\sqrt{0.5}}} \cdot \sin ky \]
                                            7. Applied rewrites6.8%

                                              \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}} \cdot \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} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\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} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                              2. *-commutativeN/A

                                                \[\leadsto \color{blue}{\left(\sin ky \cdot th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                              3. lower-*.f64N/A

                                                \[\leadsto \color{blue}{\left(\sin ky \cdot th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                              4. lower-sin.f64N/A

                                                \[\leadsto \left(\color{blue}{\sin ky} \cdot th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                              5. lower-sqrt.f64N/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                              6. lower-/.f64N/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                              7. associate-+r+N/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)}}} \]
                                              8. +-commutativeN/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right) + \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
                                              9. lower-fma.f64N/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(2 \cdot kx\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
                                              10. metadata-evalN/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                              11. distribute-lft-neg-inN/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                              12. lower--.f64N/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, \color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                              13. cos-negN/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                              14. lower-cos.f64N/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                              15. *-commutativeN/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                              16. lower-*.f64N/A

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                            10. Applied rewrites35.7%

                                              \[\leadsto \color{blue}{\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}} \]
                                            11. Taylor expanded in kx around 0

                                              \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(-2 \cdot ky\right)}} \]
                                            12. Step-by-step derivation
                                              1. Applied rewrites27.1%

                                                \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}} \]

                                              if -0.20000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                              1. Initial program 99.7%

                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                              2. Add Preprocessing
                                              3. Taylor expanded in ky around 0

                                                \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                              4. Step-by-step derivation
                                                1. lower-sin.f6470.4

                                                  \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                              5. Applied rewrites70.4%

                                                \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                              6. Taylor expanded in ky around 0

                                                \[\leadsto \frac{\color{blue}{ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)}}{\sin kx} \cdot \sin th \]
                                              7. Step-by-step derivation
                                                1. +-commutativeN/A

                                                  \[\leadsto \frac{ky \cdot \color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2} + 1\right)}}{\sin kx} \cdot \sin th \]
                                                2. distribute-lft-inN/A

                                                  \[\leadsto \frac{\color{blue}{ky \cdot \left(\frac{-1}{6} \cdot {ky}^{2}\right) + ky \cdot 1}}{\sin kx} \cdot \sin th \]
                                                3. *-rgt-identityN/A

                                                  \[\leadsto \frac{ky \cdot \left(\frac{-1}{6} \cdot {ky}^{2}\right) + \color{blue}{ky}}{\sin kx} \cdot \sin th \]
                                                4. lower-fma.f64N/A

                                                  \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky, \frac{-1}{6} \cdot {ky}^{2}, ky\right)}}{\sin kx} \cdot \sin th \]
                                                5. *-commutativeN/A

                                                  \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{{ky}^{2} \cdot \frac{-1}{6}}, ky\right)}{\sin kx} \cdot \sin th \]
                                                6. lower-*.f64N/A

                                                  \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{{ky}^{2} \cdot \frac{-1}{6}}, ky\right)}{\sin kx} \cdot \sin th \]
                                                7. unpow2N/A

                                                  \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{\left(ky \cdot ky\right)} \cdot \frac{-1}{6}, ky\right)}{\sin kx} \cdot \sin th \]
                                                8. lower-*.f6469.7

                                                  \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{\left(ky \cdot ky\right)} \cdot -0.16666666666666666, ky\right)}{\sin kx} \cdot \sin th \]
                                              8. Applied rewrites69.7%

                                                \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky, \left(ky \cdot ky\right) \cdot -0.16666666666666666, ky\right)}}{\sin kx} \cdot \sin th \]

                                              if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                              1. Initial program 90.2%

                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                              2. Add Preprocessing
                                              3. Taylor expanded in kx around 0

                                                \[\leadsto \color{blue}{\sin th} \]
                                              4. Step-by-step derivation
                                                1. lower-sin.f6463.1

                                                  \[\leadsto \color{blue}{\sin th} \]
                                              5. Applied rewrites63.1%

                                                \[\leadsto \color{blue}{\sin th} \]
                                            13. Recombined 3 regimes into one program.
                                            14. Final simplification53.9%

                                              \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.2:\\ \;\;\;\;\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                            15. Add Preprocessing

                                            Alternative 15: 35.3% accurate, 0.5× speedup?

                                            \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq 10^{-77}:\\ \;\;\;\;\frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)\\ \mathbf{elif}\;t\_1 \leq 10^{-7}:\\ \;\;\;\;\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(ky \cdot \left(th \cdot \sqrt{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                            (FPCore (kx ky th)
                                             :precision binary64
                                             (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
                                               (if (<= t_1 1e-77)
                                                 (*
                                                  (/ (fma ky (* -0.16666666666666666 (* ky ky)) ky) (sin kx))
                                                  (fma th (* -0.16666666666666666 (* th th)) th))
                                                 (if (<= t_1 1e-7)
                                                   (* (sqrt (/ 1.0 (- 1.0 (cos (* kx -2.0))))) (* ky (* th (sqrt 2.0))))
                                                   (sin th)))))
                                            double code(double kx, double ky, double th) {
                                            	double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
                                            	double tmp;
                                            	if (t_1 <= 1e-77) {
                                            		tmp = (fma(ky, (-0.16666666666666666 * (ky * ky)), ky) / sin(kx)) * fma(th, (-0.16666666666666666 * (th * th)), th);
                                            	} else if (t_1 <= 1e-7) {
                                            		tmp = sqrt((1.0 / (1.0 - cos((kx * -2.0))))) * (ky * (th * sqrt(2.0)));
                                            	} else {
                                            		tmp = sin(th);
                                            	}
                                            	return tmp;
                                            }
                                            
                                            function code(kx, ky, th)
                                            	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
                                            	tmp = 0.0
                                            	if (t_1 <= 1e-77)
                                            		tmp = Float64(Float64(fma(ky, Float64(-0.16666666666666666 * Float64(ky * ky)), ky) / sin(kx)) * fma(th, Float64(-0.16666666666666666 * Float64(th * th)), th));
                                            	elseif (t_1 <= 1e-7)
                                            		tmp = Float64(sqrt(Float64(1.0 / Float64(1.0 - cos(Float64(kx * -2.0))))) * Float64(ky * Float64(th * sqrt(2.0))));
                                            	else
                                            		tmp = sin(th);
                                            	end
                                            	return tmp
                                            end
                                            
                                            code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-77], N[(N[(N[(ky * N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] + ky), $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], N[(N[Sqrt[N[(1.0 / N[(1.0 - N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(ky * N[(th * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \begin{array}{l}
                                            t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
                                            \mathbf{if}\;t\_1 \leq 10^{-77}:\\
                                            \;\;\;\;\frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)\\
                                            
                                            \mathbf{elif}\;t\_1 \leq 10^{-7}:\\
                                            \;\;\;\;\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(ky \cdot \left(th \cdot \sqrt{2}\right)\right)\\
                                            
                                            \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))))) < 9.9999999999999993e-78

                                              1. Initial program 92.5%

                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                              2. Add Preprocessing
                                              3. Taylor expanded in ky around 0

                                                \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                              4. Step-by-step derivation
                                                1. lower-sin.f6440.0

                                                  \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                              5. Applied rewrites40.0%

                                                \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                              6. Taylor expanded in th around 0

                                                \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\left(th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)\right)} \]
                                              7. Step-by-step derivation
                                                1. +-commutativeN/A

                                                  \[\leadsto \frac{\sin ky}{\sin kx} \cdot \left(th \cdot \color{blue}{\left(\frac{-1}{6} \cdot {th}^{2} + 1\right)}\right) \]
                                                2. distribute-lft-inN/A

                                                  \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\left(th \cdot \left(\frac{-1}{6} \cdot {th}^{2}\right) + th \cdot 1\right)} \]
                                                3. *-rgt-identityN/A

                                                  \[\leadsto \frac{\sin ky}{\sin kx} \cdot \left(th \cdot \left(\frac{-1}{6} \cdot {th}^{2}\right) + \color{blue}{th}\right) \]
                                                4. lower-fma.f64N/A

                                                  \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
                                                5. lower-*.f64N/A

                                                  \[\leadsto \frac{\sin ky}{\sin kx} \cdot \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
                                                6. unpow2N/A

                                                  \[\leadsto \frac{\sin ky}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
                                                7. lower-*.f6431.2

                                                  \[\leadsto \frac{\sin ky}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
                                              8. Applied rewrites31.2%

                                                \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]
                                              9. Taylor expanded in ky around 0

                                                \[\leadsto \frac{\color{blue}{ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)}}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                              10. Step-by-step derivation
                                                1. +-commutativeN/A

                                                  \[\leadsto \frac{ky \cdot \color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2} + 1\right)}}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                2. distribute-lft-inN/A

                                                  \[\leadsto \frac{\color{blue}{ky \cdot \left(\frac{-1}{6} \cdot {ky}^{2}\right) + ky \cdot 1}}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                3. *-rgt-identityN/A

                                                  \[\leadsto \frac{ky \cdot \left(\frac{-1}{6} \cdot {ky}^{2}\right) + \color{blue}{ky}}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                4. lower-fma.f64N/A

                                                  \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky, \frac{-1}{6} \cdot {ky}^{2}, ky\right)}}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                5. lower-*.f64N/A

                                                  \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{\frac{-1}{6} \cdot {ky}^{2}}, ky\right)}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                6. unpow2N/A

                                                  \[\leadsto \frac{\mathsf{fma}\left(ky, \frac{-1}{6} \cdot \color{blue}{\left(ky \cdot ky\right)}, ky\right)}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                7. lower-*.f6430.5

                                                  \[\leadsto \frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \color{blue}{\left(ky \cdot ky\right)}, ky\right)}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]
                                              11. Applied rewrites30.5%

                                                \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]

                                              if 9.9999999999999993e-78 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                              1. Initial program 99.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. 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 rewrites77.8%

                                                \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                              5. Taylor expanded in ky around 0

                                                \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin ky \]
                                              6. Step-by-step derivation
                                                1. *-commutativeN/A

                                                  \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}} \cdot \sin ky \]
                                                2. lower-*.f64N/A

                                                  \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}} \cdot \sin ky \]
                                                3. lower-sqrt.f64N/A

                                                  \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                                4. metadata-evalN/A

                                                  \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                                5. distribute-lft-neg-inN/A

                                                  \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                                6. lower--.f64N/A

                                                  \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                                7. cos-negN/A

                                                  \[\leadsto \frac{\sin th}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                                8. lower-cos.f64N/A

                                                  \[\leadsto \frac{\sin th}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                                9. *-commutativeN/A

                                                  \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                                10. lower-*.f64N/A

                                                  \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin ky \]
                                                11. lower-sqrt.f6476.7

                                                  \[\leadsto \frac{\sin th}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\sqrt{0.5}}} \cdot \sin ky \]
                                              7. Applied rewrites76.7%

                                                \[\leadsto \frac{\sin th}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}} \cdot \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} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\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} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                                2. *-commutativeN/A

                                                  \[\leadsto \color{blue}{\left(\sin ky \cdot th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                                3. lower-*.f64N/A

                                                  \[\leadsto \color{blue}{\left(\sin ky \cdot th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                                4. lower-sin.f64N/A

                                                  \[\leadsto \left(\color{blue}{\sin ky} \cdot th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}} \]
                                                5. lower-sqrt.f64N/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                                6. lower-/.f64N/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \left(\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}} \]
                                                7. associate-+r+N/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right) + \frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)}}} \]
                                                8. +-commutativeN/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right) + \left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
                                                9. lower-fma.f64N/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(2 \cdot kx\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
                                                10. metadata-evalN/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                                11. distribute-lft-neg-inN/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                                12. lower--.f64N/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, \color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                                13. cos-negN/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                                14. lower-cos.f64N/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                                15. *-commutativeN/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                                16. lower-*.f64N/A

                                                  \[\leadsto \left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{1}{2}, 1 - \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
                                              10. Applied rewrites46.0%

                                                \[\leadsto \color{blue}{\left(\sin ky \cdot th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}} \]
                                              11. Taylor expanded in ky around 0

                                                \[\leadsto \left(ky \cdot \left(th \cdot \sqrt{2}\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{1 - \cos \left(-2 \cdot kx\right)}}} \]
                                              12. Step-by-step derivation
                                                1. Applied rewrites45.2%

                                                  \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \color{blue}{\left(ky \cdot \left(th \cdot \sqrt{2}\right)\right)} \]

                                                if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                                1. Initial program 90.2%

                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in kx around 0

                                                  \[\leadsto \color{blue}{\sin th} \]
                                                4. Step-by-step derivation
                                                  1. lower-sin.f6463.1

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                5. Applied rewrites63.1%

                                                  \[\leadsto \color{blue}{\sin th} \]
                                              13. Recombined 3 regimes into one program.
                                              14. Add Preprocessing

                                              Alternative 16: 43.8% accurate, 0.8× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                              (FPCore (kx ky th)
                                               :precision binary64
                                               (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 1e-7)
                                                 (* (sin th) (/ (fma ky (* -0.16666666666666666 (* ky ky)) ky) (sin kx)))
                                                 (sin th)))
                                              double code(double kx, double ky, double th) {
                                              	double tmp;
                                              	if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 1e-7) {
                                              		tmp = sin(th) * (fma(ky, (-0.16666666666666666 * (ky * ky)), ky) / sin(kx));
                                              	} else {
                                              		tmp = sin(th);
                                              	}
                                              	return tmp;
                                              }
                                              
                                              function code(kx, ky, th)
                                              	tmp = 0.0
                                              	if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 1e-7)
                                              		tmp = Float64(sin(th) * Float64(fma(ky, Float64(-0.16666666666666666 * Float64(ky * ky)), ky) / sin(kx)));
                                              	else
                                              		tmp = sin(th);
                                              	end
                                              	return tmp
                                              end
                                              
                                              code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(N[Sin[th], $MachinePrecision] * N[(N[(ky * N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] + ky), $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\
                                              \;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{\sin kx}\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\sin th\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 2 regimes
                                              2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                                1. Initial program 92.9%

                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in ky around 0

                                                  \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                                4. Step-by-step derivation
                                                  1. lower-sin.f6439.8

                                                    \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                                5. Applied rewrites39.8%

                                                  \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                                6. Taylor expanded in ky around 0

                                                  \[\leadsto \frac{\color{blue}{ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)}}{\sin kx} \cdot \sin th \]
                                                7. Step-by-step derivation
                                                  1. +-commutativeN/A

                                                    \[\leadsto \frac{ky \cdot \color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2} + 1\right)}}{\sin kx} \cdot \sin th \]
                                                  2. distribute-lft-inN/A

                                                    \[\leadsto \frac{\color{blue}{ky \cdot \left(\frac{-1}{6} \cdot {ky}^{2}\right) + ky \cdot 1}}{\sin kx} \cdot \sin th \]
                                                  3. *-rgt-identityN/A

                                                    \[\leadsto \frac{ky \cdot \left(\frac{-1}{6} \cdot {ky}^{2}\right) + \color{blue}{ky}}{\sin kx} \cdot \sin th \]
                                                  4. lower-fma.f64N/A

                                                    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky, \frac{-1}{6} \cdot {ky}^{2}, ky\right)}}{\sin kx} \cdot \sin th \]
                                                  5. *-commutativeN/A

                                                    \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{{ky}^{2} \cdot \frac{-1}{6}}, ky\right)}{\sin kx} \cdot \sin th \]
                                                  6. lower-*.f64N/A

                                                    \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{{ky}^{2} \cdot \frac{-1}{6}}, ky\right)}{\sin kx} \cdot \sin th \]
                                                  7. unpow2N/A

                                                    \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{\left(ky \cdot ky\right)} \cdot \frac{-1}{6}, ky\right)}{\sin kx} \cdot \sin th \]
                                                  8. lower-*.f6438.6

                                                    \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{\left(ky \cdot ky\right)} \cdot -0.16666666666666666, ky\right)}{\sin kx} \cdot \sin th \]
                                                8. Applied rewrites38.6%

                                                  \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky, \left(ky \cdot ky\right) \cdot -0.16666666666666666, ky\right)}}{\sin kx} \cdot \sin th \]

                                                if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                                1. Initial program 90.2%

                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in kx around 0

                                                  \[\leadsto \color{blue}{\sin th} \]
                                                4. Step-by-step derivation
                                                  1. lower-sin.f6463.1

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                5. Applied rewrites63.1%

                                                  \[\leadsto \color{blue}{\sin th} \]
                                              3. Recombined 2 regimes into one program.
                                              4. Final simplification47.1%

                                                \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                              5. Add Preprocessing

                                              Alternative 17: 44.0% accurate, 0.8× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                              (FPCore (kx ky th)
                                               :precision binary64
                                               (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 1e-7)
                                                 (* ky (/ (sin th) (sin kx)))
                                                 (sin th)))
                                              double code(double kx, double ky, double th) {
                                              	double tmp;
                                              	if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 1e-7) {
                                              		tmp = ky * (sin(th) / sin(kx));
                                              	} else {
                                              		tmp = sin(th);
                                              	}
                                              	return tmp;
                                              }
                                              
                                              real(8) function code(kx, ky, th)
                                                  real(8), intent (in) :: kx
                                                  real(8), intent (in) :: ky
                                                  real(8), intent (in) :: th
                                                  real(8) :: tmp
                                                  if ((sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 1d-7) then
                                                      tmp = ky * (sin(th) / sin(kx))
                                                  else
                                                      tmp = sin(th)
                                                  end if
                                                  code = tmp
                                              end function
                                              
                                              public static double code(double kx, double ky, double th) {
                                              	double tmp;
                                              	if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 1e-7) {
                                              		tmp = ky * (Math.sin(th) / Math.sin(kx));
                                              	} else {
                                              		tmp = Math.sin(th);
                                              	}
                                              	return tmp;
                                              }
                                              
                                              def code(kx, ky, th):
                                              	tmp = 0
                                              	if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 1e-7:
                                              		tmp = ky * (math.sin(th) / math.sin(kx))
                                              	else:
                                              		tmp = math.sin(th)
                                              	return tmp
                                              
                                              function code(kx, ky, th)
                                              	tmp = 0.0
                                              	if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 1e-7)
                                              		tmp = Float64(ky * Float64(sin(th) / sin(kx)));
                                              	else
                                              		tmp = sin(th);
                                              	end
                                              	return tmp
                                              end
                                              
                                              function tmp_2 = code(kx, ky, th)
                                              	tmp = 0.0;
                                              	if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 1e-7)
                                              		tmp = ky * (sin(th) / sin(kx));
                                              	else
                                              		tmp = sin(th);
                                              	end
                                              	tmp_2 = tmp;
                                              end
                                              
                                              code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\
                                              \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\sin th\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 2 regimes
                                              2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                                1. Initial program 92.9%

                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in ky around 0

                                                  \[\leadsto \color{blue}{ky \cdot \left({ky}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}} + \frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right) + \frac{\sin th}{\sin kx}\right)} \]
                                                4. Step-by-step derivation
                                                  1. lower-*.f64N/A

                                                    \[\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)} \]
                                                  2. distribute-lft-inN/A

                                                    \[\leadsto ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right)\right)} + \frac{\sin th}{\sin kx}\right) \]
                                                  3. *-commutativeN/A

                                                    \[\leadsto ky \cdot \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right)\right) + \frac{\sin th}{\sin kx}\right) \]
                                                  4. associate-+r+N/A

                                                    \[\leadsto ky \cdot \color{blue}{\left(\left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2} + \left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right) + \frac{\sin th}{\sin kx}\right)\right)} \]
                                                  5. +-commutativeN/A

                                                    \[\leadsto ky \cdot \color{blue}{\left(\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right) + \frac{\sin th}{\sin kx}\right) + \left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2}\right)} \]
                                                5. Applied rewrites33.2%

                                                  \[\leadsto \color{blue}{ky \cdot \mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right), \frac{\sin th}{\sin kx}, \frac{\left(ky \cdot ky\right) \cdot \left(-0.5 \cdot \sin th\right)}{{\sin kx}^{3}}\right)} \]
                                                6. Taylor expanded in ky around 0

                                                  \[\leadsto ky \cdot \frac{\sin th}{\color{blue}{\sin kx}} \]
                                                7. Step-by-step derivation
                                                  1. Applied rewrites38.6%

                                                    \[\leadsto ky \cdot \frac{\sin th}{\color{blue}{\sin kx}} \]

                                                  if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                                  1. Initial program 90.2%

                                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in kx around 0

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                  4. Step-by-step derivation
                                                    1. lower-sin.f6463.1

                                                      \[\leadsto \color{blue}{\sin th} \]
                                                  5. Applied rewrites63.1%

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                8. Recombined 2 regimes into one program.
                                                9. Add Preprocessing

                                                Alternative 18: 35.0% accurate, 0.9× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                                (FPCore (kx ky th)
                                                 :precision binary64
                                                 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 1e-7)
                                                   (*
                                                    (/ (fma ky (* -0.16666666666666666 (* ky ky)) ky) (sin kx))
                                                    (fma th (* -0.16666666666666666 (* th th)) th))
                                                   (sin th)))
                                                double code(double kx, double ky, double th) {
                                                	double tmp;
                                                	if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 1e-7) {
                                                		tmp = (fma(ky, (-0.16666666666666666 * (ky * ky)), ky) / sin(kx)) * fma(th, (-0.16666666666666666 * (th * th)), th);
                                                	} else {
                                                		tmp = sin(th);
                                                	}
                                                	return tmp;
                                                }
                                                
                                                function code(kx, ky, th)
                                                	tmp = 0.0
                                                	if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 1e-7)
                                                		tmp = Float64(Float64(fma(ky, Float64(-0.16666666666666666 * Float64(ky * ky)), ky) / sin(kx)) * fma(th, Float64(-0.16666666666666666 * Float64(th * th)), th));
                                                	else
                                                		tmp = sin(th);
                                                	end
                                                	return tmp
                                                end
                                                
                                                code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(N[(N[(ky * N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] + ky), $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\
                                                \;\;\;\;\frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;\sin th\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                                  1. Initial program 92.9%

                                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in ky around 0

                                                    \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                                  4. Step-by-step derivation
                                                    1. lower-sin.f6439.8

                                                      \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                                  5. Applied rewrites39.8%

                                                    \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                                  6. Taylor expanded in th around 0

                                                    \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\left(th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)\right)} \]
                                                  7. Step-by-step derivation
                                                    1. +-commutativeN/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \left(th \cdot \color{blue}{\left(\frac{-1}{6} \cdot {th}^{2} + 1\right)}\right) \]
                                                    2. distribute-lft-inN/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\left(th \cdot \left(\frac{-1}{6} \cdot {th}^{2}\right) + th \cdot 1\right)} \]
                                                    3. *-rgt-identityN/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \left(th \cdot \left(\frac{-1}{6} \cdot {th}^{2}\right) + \color{blue}{th}\right) \]
                                                    4. lower-fma.f64N/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
                                                    5. lower-*.f64N/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
                                                    6. unpow2N/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
                                                    7. lower-*.f6430.3

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
                                                  8. Applied rewrites30.3%

                                                    \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]
                                                  9. Taylor expanded in ky around 0

                                                    \[\leadsto \frac{\color{blue}{ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)}}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                  10. Step-by-step derivation
                                                    1. +-commutativeN/A

                                                      \[\leadsto \frac{ky \cdot \color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2} + 1\right)}}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                    2. distribute-lft-inN/A

                                                      \[\leadsto \frac{\color{blue}{ky \cdot \left(\frac{-1}{6} \cdot {ky}^{2}\right) + ky \cdot 1}}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                    3. *-rgt-identityN/A

                                                      \[\leadsto \frac{ky \cdot \left(\frac{-1}{6} \cdot {ky}^{2}\right) + \color{blue}{ky}}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                    4. lower-fma.f64N/A

                                                      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky, \frac{-1}{6} \cdot {ky}^{2}, ky\right)}}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                    5. lower-*.f64N/A

                                                      \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{\frac{-1}{6} \cdot {ky}^{2}}, ky\right)}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                    6. unpow2N/A

                                                      \[\leadsto \frac{\mathsf{fma}\left(ky, \frac{-1}{6} \cdot \color{blue}{\left(ky \cdot ky\right)}, ky\right)}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                    7. lower-*.f6429.6

                                                      \[\leadsto \frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \color{blue}{\left(ky \cdot ky\right)}, ky\right)}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]
                                                  11. Applied rewrites29.6%

                                                    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]

                                                  if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                                  1. Initial program 90.2%

                                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in kx around 0

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                  4. Step-by-step derivation
                                                    1. lower-sin.f6463.1

                                                      \[\leadsto \color{blue}{\sin th} \]
                                                  5. Applied rewrites63.1%

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                3. Recombined 2 regimes into one program.
                                                4. Add Preprocessing

                                                Alternative 19: 35.1% accurate, 1.0× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                                (FPCore (kx ky th)
                                                 :precision binary64
                                                 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 1e-7)
                                                   (* (fma th (* -0.16666666666666666 (* th th)) th) (/ ky (sin kx)))
                                                   (sin th)))
                                                double code(double kx, double ky, double th) {
                                                	double tmp;
                                                	if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 1e-7) {
                                                		tmp = fma(th, (-0.16666666666666666 * (th * th)), th) * (ky / sin(kx));
                                                	} else {
                                                		tmp = sin(th);
                                                	}
                                                	return tmp;
                                                }
                                                
                                                function code(kx, ky, th)
                                                	tmp = 0.0
                                                	if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 1e-7)
                                                		tmp = Float64(fma(th, Float64(-0.16666666666666666 * Float64(th * th)), th) * Float64(ky / sin(kx)));
                                                	else
                                                		tmp = sin(th);
                                                	end
                                                	return tmp
                                                end
                                                
                                                code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\
                                                \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{ky}{\sin kx}\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;\sin th\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8

                                                  1. Initial program 92.9%

                                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in ky around 0

                                                    \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                                  4. Step-by-step derivation
                                                    1. lower-sin.f6439.8

                                                      \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                                  5. Applied rewrites39.8%

                                                    \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                                                  6. Taylor expanded in th around 0

                                                    \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\left(th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)\right)} \]
                                                  7. Step-by-step derivation
                                                    1. +-commutativeN/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \left(th \cdot \color{blue}{\left(\frac{-1}{6} \cdot {th}^{2} + 1\right)}\right) \]
                                                    2. distribute-lft-inN/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\left(th \cdot \left(\frac{-1}{6} \cdot {th}^{2}\right) + th \cdot 1\right)} \]
                                                    3. *-rgt-identityN/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \left(th \cdot \left(\frac{-1}{6} \cdot {th}^{2}\right) + \color{blue}{th}\right) \]
                                                    4. lower-fma.f64N/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
                                                    5. lower-*.f64N/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
                                                    6. unpow2N/A

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
                                                    7. lower-*.f6430.3

                                                      \[\leadsto \frac{\sin ky}{\sin kx} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
                                                  8. Applied rewrites30.3%

                                                    \[\leadsto \frac{\sin ky}{\sin kx} \cdot \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]
                                                  9. Taylor expanded in ky around 0

                                                    \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                  10. Step-by-step derivation
                                                    1. lower-/.f64N/A

                                                      \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
                                                    2. lower-sin.f6429.6

                                                      \[\leadsto \frac{ky}{\color{blue}{\sin kx}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]
                                                  11. Applied rewrites29.6%

                                                    \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]

                                                  if 9.9999999999999995e-8 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                                  1. Initial program 90.2%

                                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in kx around 0

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                  4. Step-by-step derivation
                                                    1. lower-sin.f6463.1

                                                      \[\leadsto \color{blue}{\sin th} \]
                                                  5. Applied rewrites63.1%

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                3. Recombined 2 regimes into one program.
                                                4. Final simplification41.2%

                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
                                                5. Add Preprocessing

                                                Alternative 20: 16.0% accurate, 1.0× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-308}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(th, \left(th \cdot th\right) \cdot \mathsf{fma}\left(0.008333333333333333, th \cdot th, -0.16666666666666666\right), th\right)\\ \end{array} \end{array} \]
                                                (FPCore (kx ky th)
                                                 :precision binary64
                                                 (if (<=
                                                      (*
                                                       (sin th)
                                                       (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
                                                      1e-308)
                                                   (* -0.16666666666666666 (* th (* th th)))
                                                   (fma
                                                    th
                                                    (* (* th th) (fma 0.008333333333333333 (* th th) -0.16666666666666666))
                                                    th)))
                                                double code(double kx, double ky, double th) {
                                                	double tmp;
                                                	if ((sin(th) * (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0))))) <= 1e-308) {
                                                		tmp = -0.16666666666666666 * (th * (th * th));
                                                	} else {
                                                		tmp = fma(th, ((th * th) * fma(0.008333333333333333, (th * th), -0.16666666666666666)), th);
                                                	}
                                                	return tmp;
                                                }
                                                
                                                function code(kx, ky, th)
                                                	tmp = 0.0
                                                	if (Float64(sin(th) * Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))) <= 1e-308)
                                                		tmp = Float64(-0.16666666666666666 * Float64(th * Float64(th * th)));
                                                	else
                                                		tmp = fma(th, Float64(Float64(th * th) * fma(0.008333333333333333, Float64(th * th), -0.16666666666666666)), th);
                                                	end
                                                	return tmp
                                                end
                                                
                                                code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-308], N[(-0.16666666666666666 * N[(th * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(th * N[(N[(th * th), $MachinePrecision] * N[(0.008333333333333333 * N[(th * th), $MachinePrecision] + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-308}:\\
                                                \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;\mathsf{fma}\left(th, \left(th \cdot th\right) \cdot \mathsf{fma}\left(0.008333333333333333, th \cdot th, -0.16666666666666666\right), th\right)\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if (*.f64 (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) (sin.f64 th)) < 9.9999999999999991e-309

                                                  1. Initial program 93.9%

                                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in kx around 0

                                                    \[\leadsto \color{blue}{\sin th} \]
                                                  4. Step-by-step derivation
                                                    1. lower-sin.f6422.2

                                                      \[\leadsto \color{blue}{\sin th} \]
                                                  5. Applied rewrites22.2%

                                                    \[\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.7%

                                                      \[\leadsto \mathsf{fma}\left(th, \color{blue}{-0.16666666666666666 \cdot \left(th \cdot th\right)}, th\right) \]
                                                    2. Taylor expanded in th around inf

                                                      \[\leadsto \frac{-1}{6} \cdot {th}^{\color{blue}{3}} \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites25.1%

                                                        \[\leadsto -0.16666666666666666 \cdot \left(th \cdot \color{blue}{\left(th \cdot th\right)}\right) \]

                                                      if 9.9999999999999991e-309 < (*.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 89.9%

                                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                      2. Add Preprocessing
                                                      3. Taylor expanded in kx around 0

                                                        \[\leadsto \color{blue}{\sin th} \]
                                                      4. Step-by-step derivation
                                                        1. lower-sin.f6427.3

                                                          \[\leadsto \color{blue}{\sin th} \]
                                                      5. Applied rewrites27.3%

                                                        \[\leadsto \color{blue}{\sin th} \]
                                                      6. Taylor expanded in th around 0

                                                        \[\leadsto th \cdot \color{blue}{\left(1 + {th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right)\right)} \]
                                                      7. Step-by-step derivation
                                                        1. Applied rewrites15.3%

                                                          \[\leadsto \mathsf{fma}\left(th, \color{blue}{\left(th \cdot th\right) \cdot \mathsf{fma}\left(0.008333333333333333, th \cdot th, -0.16666666666666666\right)}, th\right) \]
                                                      8. Recombined 2 regimes into one program.
                                                      9. Final simplification20.3%

                                                        \[\leadsto \begin{array}{l} \mathbf{if}\;\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 10^{-308}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(th, \left(th \cdot th\right) \cdot \mathsf{fma}\left(0.008333333333333333, th \cdot th, -0.16666666666666666\right), th\right)\\ \end{array} \]
                                                      10. Add Preprocessing

                                                      Alternative 21: 98.6% accurate, 1.0× speedup?

                                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-36}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}\\ \end{array} \end{array} \]
                                                      (FPCore (kx ky th)
                                                       :precision binary64
                                                       (if (<= (pow (sin kx) 2.0) 2e-36)
                                                         (*
                                                          (sin th)
                                                          (/
                                                           (sin ky)
                                                           (hypot (sin ky) (fma kx (* -0.16666666666666666 (* kx kx)) kx))))
                                                         (*
                                                          (sin th)
                                                          (/
                                                           (sin ky)
                                                           (sqrt
                                                            (fma (- 1.0 (cos (+ kx kx))) 0.5 (+ 0.5 (* -0.5 (cos (+ ky ky))))))))))
                                                      double code(double kx, double ky, double th) {
                                                      	double tmp;
                                                      	if (pow(sin(kx), 2.0) <= 2e-36) {
                                                      		tmp = sin(th) * (sin(ky) / hypot(sin(ky), fma(kx, (-0.16666666666666666 * (kx * kx)), kx)));
                                                      	} else {
                                                      		tmp = sin(th) * (sin(ky) / sqrt(fma((1.0 - cos((kx + kx))), 0.5, (0.5 + (-0.5 * cos((ky + ky)))))));
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      function code(kx, ky, th)
                                                      	tmp = 0.0
                                                      	if ((sin(kx) ^ 2.0) <= 2e-36)
                                                      		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), fma(kx, Float64(-0.16666666666666666 * Float64(kx * kx)), kx))));
                                                      	else
                                                      		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(1.0 - cos(Float64(kx + kx))), 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(ky + ky))))))));
                                                      	end
                                                      	return tmp
                                                      end
                                                      
                                                      code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 2e-36], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(kx * N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision]), $MachinePrecision] + kx), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                      
                                                      \begin{array}{l}
                                                      
                                                      \\
                                                      \begin{array}{l}
                                                      \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-36}:\\
                                                      \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\
                                                      
                                                      \mathbf{else}:\\
                                                      \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}\\
                                                      
                                                      
                                                      \end{array}
                                                      \end{array}
                                                      
                                                      Derivation
                                                      1. Split input into 2 regimes
                                                      2. if (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 1.9999999999999999e-36

                                                        1. Initial program 85.1%

                                                          \[\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, kx \cdot \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2} + 1\right)}\right)} \cdot \sin th \]
                                                          2. distribute-lft-inN/A

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(\frac{-1}{6} \cdot {kx}^{2}\right) + kx \cdot 1}\right)} \cdot \sin th \]
                                                          3. *-rgt-identityN/A

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \left(\frac{-1}{6} \cdot {kx}^{2}\right) + \color{blue}{kx}\right)} \cdot \sin th \]
                                                          4. lower-fma.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, \frac{-1}{6} \cdot {kx}^{2}, kx\right)}\right)} \cdot \sin th \]
                                                          5. lower-*.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, \color{blue}{\frac{-1}{6} \cdot {kx}^{2}}, kx\right)\right)} \cdot \sin th \]
                                                          6. unpow2N/A

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \color{blue}{\left(kx \cdot kx\right)}, kx\right)\right)} \cdot \sin th \]
                                                          7. lower-*.f6499.9

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \color{blue}{\left(kx \cdot kx\right)}, kx\right)\right)} \cdot \sin th \]
                                                        7. Applied rewrites99.9%

                                                          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)}\right)} \cdot \sin th \]

                                                        if 1.9999999999999999e-36 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

                                                        1. Initial program 99.5%

                                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                        2. Add Preprocessing
                                                        3. Step-by-step derivation
                                                          1. lift-+.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                                                          2. lift-pow.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2}} + {\sin ky}^{2}}} \cdot \sin th \]
                                                          3. unpow2N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
                                                          4. lift-sin.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
                                                          5. lift-sin.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\sin kx \cdot \color{blue}{\sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
                                                          6. sin-multN/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(kx - kx\right) - \cos \left(kx + kx\right)}{2}} + {\sin ky}^{2}}} \cdot \sin th \]
                                                          7. div-invN/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(kx - kx\right) - \cos \left(kx + kx\right)\right) \cdot \frac{1}{2}} + {\sin ky}^{2}}} \cdot \sin th \]
                                                          8. metadata-evalN/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(kx - kx\right) - \cos \left(kx + kx\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin ky}^{2}}} \cdot \sin th \]
                                                          9. lower-fma.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(kx - kx\right) - \cos \left(kx + kx\right), \frac{1}{2}, {\sin ky}^{2}\right)}}} \cdot \sin th \]
                                                          10. count-2N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(kx - kx\right) - \cos \color{blue}{\left(2 \cdot kx\right)}, \frac{1}{2}, {\sin ky}^{2}\right)}} \cdot \sin th \]
                                                          11. cos-diffN/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos kx \cdot \cos kx + \sin kx \cdot \sin kx\right)} - \cos \left(2 \cdot kx\right), \frac{1}{2}, {\sin ky}^{2}\right)}} \cdot \sin th \]
                                                          12. cos-sin-sumN/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot kx\right), \frac{1}{2}, {\sin ky}^{2}\right)}} \cdot \sin th \]
                                                          13. lower--.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot kx\right)}, \frac{1}{2}, {\sin ky}^{2}\right)}} \cdot \sin th \]
                                                          14. count-2N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(kx + kx\right)}, \frac{1}{2}, {\sin ky}^{2}\right)}} \cdot \sin th \]
                                                          15. lower-cos.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(kx + kx\right)}, \frac{1}{2}, {\sin ky}^{2}\right)}} \cdot \sin th \]
                                                          16. lower-+.f6498.6

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(kx + kx\right)}, 0.5, {\sin ky}^{2}\right)}} \cdot \sin th \]
                                                          17. lift-pow.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
                                                          18. unpow2N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
                                                          19. lift-sin.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
                                                          20. lift-sin.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
                                                          21. sqr-sin-aN/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)}\right)}} \cdot \sin th \]
                                                          22. cancel-sign-sub-invN/A

                                                            \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \cos \left(2 \cdot ky\right)}\right)}} \cdot \sin th \]
                                                        4. Applied rewrites98.6%

                                                          \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}} \cdot \sin th \]
                                                      3. Recombined 2 regimes into one program.
                                                      4. Final simplification99.3%

                                                        \[\leadsto \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-36}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}\\ \end{array} \]
                                                      5. Add Preprocessing

                                                      Alternative 22: 99.5% accurate, 1.0× speedup?

                                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, \mathsf{fma}\left(\cos \left(ky + ky\right), -0.5, 0.5\right)\right)}}\\ \end{array} \end{array} \]
                                                      (FPCore (kx ky th)
                                                       :precision binary64
                                                       (if (<= (pow (sin kx) 2.0) 2e-9)
                                                         (*
                                                          (sin th)
                                                          (/
                                                           (sin ky)
                                                           (hypot (sin ky) (fma kx (* -0.16666666666666666 (* kx kx)) kx))))
                                                         (*
                                                          (sin ky)
                                                          (/
                                                           (sin th)
                                                           (sqrt
                                                            (fma (- 1.0 (cos (+ kx kx))) 0.5 (fma (cos (+ ky ky)) -0.5 0.5)))))))
                                                      double code(double kx, double ky, double th) {
                                                      	double tmp;
                                                      	if (pow(sin(kx), 2.0) <= 2e-9) {
                                                      		tmp = sin(th) * (sin(ky) / hypot(sin(ky), fma(kx, (-0.16666666666666666 * (kx * kx)), kx)));
                                                      	} else {
                                                      		tmp = sin(ky) * (sin(th) / sqrt(fma((1.0 - cos((kx + kx))), 0.5, fma(cos((ky + ky)), -0.5, 0.5))));
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      function code(kx, ky, th)
                                                      	tmp = 0.0
                                                      	if ((sin(kx) ^ 2.0) <= 2e-9)
                                                      		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), fma(kx, Float64(-0.16666666666666666 * Float64(kx * kx)), kx))));
                                                      	else
                                                      		tmp = Float64(sin(ky) * Float64(sin(th) / sqrt(fma(Float64(1.0 - cos(Float64(kx + kx))), 0.5, fma(cos(Float64(ky + ky)), -0.5, 0.5)))));
                                                      	end
                                                      	return tmp
                                                      end
                                                      
                                                      code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 2e-9], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(kx * N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision]), $MachinePrecision] + kx), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                      
                                                      \begin{array}{l}
                                                      
                                                      \\
                                                      \begin{array}{l}
                                                      \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-9}:\\
                                                      \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\
                                                      
                                                      \mathbf{else}:\\
                                                      \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, \mathsf{fma}\left(\cos \left(ky + ky\right), -0.5, 0.5\right)\right)}}\\
                                                      
                                                      
                                                      \end{array}
                                                      \end{array}
                                                      
                                                      Derivation
                                                      1. Split input into 2 regimes
                                                      2. if (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 2.00000000000000012e-9

                                                        1. Initial program 85.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.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, kx \cdot \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2} + 1\right)}\right)} \cdot \sin th \]
                                                          2. distribute-lft-inN/A

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(\frac{-1}{6} \cdot {kx}^{2}\right) + kx \cdot 1}\right)} \cdot \sin th \]
                                                          3. *-rgt-identityN/A

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \left(\frac{-1}{6} \cdot {kx}^{2}\right) + \color{blue}{kx}\right)} \cdot \sin th \]
                                                          4. lower-fma.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, \frac{-1}{6} \cdot {kx}^{2}, kx\right)}\right)} \cdot \sin th \]
                                                          5. lower-*.f64N/A

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, \color{blue}{\frac{-1}{6} \cdot {kx}^{2}}, kx\right)\right)} \cdot \sin th \]
                                                          6. unpow2N/A

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \color{blue}{\left(kx \cdot kx\right)}, kx\right)\right)} \cdot \sin th \]
                                                          7. lower-*.f6499.9

                                                            \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \color{blue}{\left(kx \cdot kx\right)}, kx\right)\right)} \cdot \sin th \]
                                                        7. Applied rewrites99.9%

                                                          \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)}\right)} \cdot \sin th \]

                                                        if 2.00000000000000012e-9 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

                                                        1. Initial program 99.5%

                                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                        2. Add Preprocessing
                                                        3. Step-by-step derivation
                                                          1. 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 rewrites98.5%

                                                          \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                                        5. Step-by-step derivation
                                                          1. lift-+.f64N/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(ky + ky\right)}\right)}} \cdot \sin ky \]
                                                          2. +-commutativeN/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{\frac{-1}{2} \cdot \cos \left(ky + ky\right) + \frac{1}{2}}\right)}} \cdot \sin ky \]
                                                          3. lift-*.f64N/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{\frac{-1}{2} \cdot \cos \left(ky + ky\right)} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          4. *-commutativeN/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{\cos \left(ky + ky\right) \cdot \frac{-1}{2}} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          5. lift-+.f64N/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \color{blue}{\left(ky + ky\right)} \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          6. flip-+N/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \color{blue}{\left(\frac{ky \cdot ky - ky \cdot ky}{ky - ky}\right)} \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          7. lift-*.f64N/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \left(\frac{\color{blue}{ky \cdot ky} - ky \cdot ky}{ky - ky}\right) \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          8. lift-*.f64N/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \left(\frac{ky \cdot ky - \color{blue}{ky \cdot ky}}{ky - ky}\right) \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          9. +-inversesN/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \left(\frac{\color{blue}{0}}{ky - ky}\right) \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          10. +-inversesN/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \left(\frac{\color{blue}{kx \cdot kx - kx \cdot kx}}{ky - ky}\right) \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          11. lift-*.f64N/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \left(\frac{\color{blue}{kx \cdot kx} - kx \cdot kx}{ky - ky}\right) \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          12. lift-*.f64N/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \left(\frac{kx \cdot kx - \color{blue}{kx \cdot kx}}{ky - ky}\right) \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          13. +-inversesN/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \left(\frac{kx \cdot kx - kx \cdot kx}{\color{blue}{0}}\right) \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          14. +-inversesN/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \left(\frac{kx \cdot kx - kx \cdot kx}{\color{blue}{kx - kx}}\right) \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          15. flip-+N/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \color{blue}{\left(kx + kx\right)} \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          16. lift-+.f64N/A

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \cos \color{blue}{\left(kx + kx\right)} \cdot \frac{-1}{2} + \frac{1}{2}\right)}} \cdot \sin ky \]
                                                          17. lower-fma.f6433.6

                                                            \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, \color{blue}{\mathsf{fma}\left(\cos \left(kx + kx\right), -0.5, 0.5\right)}\right)}} \cdot \sin ky \]
                                                        6. Applied rewrites98.5%

                                                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, \color{blue}{\mathsf{fma}\left(\cos \left(ky + ky\right), -0.5, 0.5\right)}\right)}} \cdot \sin ky \]
                                                      3. Recombined 2 regimes into one program.
                                                      4. Final simplification99.2%

                                                        \[\leadsto \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, \mathsf{fma}\left(\cos \left(ky + ky\right), -0.5, 0.5\right)\right)}}\\ \end{array} \]
                                                      5. Add Preprocessing

                                                      Alternative 23: 30.8% accurate, 1.0× speedup?

                                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2.15 \cdot 10^{-44}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                                      (FPCore (kx ky th)
                                                       :precision binary64
                                                       (if (<=
                                                            (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))
                                                            2.15e-44)
                                                         (* -0.16666666666666666 (* th (* th th)))
                                                         (sin th)))
                                                      double code(double kx, double ky, double th) {
                                                      	double tmp;
                                                      	if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 2.15e-44) {
                                                      		tmp = -0.16666666666666666 * (th * (th * th));
                                                      	} else {
                                                      		tmp = sin(th);
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      real(8) function code(kx, ky, th)
                                                          real(8), intent (in) :: kx
                                                          real(8), intent (in) :: ky
                                                          real(8), intent (in) :: th
                                                          real(8) :: tmp
                                                          if ((sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 2.15d-44) then
                                                              tmp = (-0.16666666666666666d0) * (th * (th * th))
                                                          else
                                                              tmp = sin(th)
                                                          end if
                                                          code = tmp
                                                      end function
                                                      
                                                      public static double code(double kx, double ky, double th) {
                                                      	double tmp;
                                                      	if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 2.15e-44) {
                                                      		tmp = -0.16666666666666666 * (th * (th * th));
                                                      	} else {
                                                      		tmp = Math.sin(th);
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      def code(kx, ky, th):
                                                      	tmp = 0
                                                      	if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 2.15e-44:
                                                      		tmp = -0.16666666666666666 * (th * (th * th))
                                                      	else:
                                                      		tmp = math.sin(th)
                                                      	return tmp
                                                      
                                                      function code(kx, ky, th)
                                                      	tmp = 0.0
                                                      	if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2.15e-44)
                                                      		tmp = Float64(-0.16666666666666666 * Float64(th * Float64(th * th)));
                                                      	else
                                                      		tmp = sin(th);
                                                      	end
                                                      	return tmp
                                                      end
                                                      
                                                      function tmp_2 = code(kx, ky, th)
                                                      	tmp = 0.0;
                                                      	if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2.15e-44)
                                                      		tmp = -0.16666666666666666 * (th * (th * th));
                                                      	else
                                                      		tmp = sin(th);
                                                      	end
                                                      	tmp_2 = tmp;
                                                      end
                                                      
                                                      code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.15e-44], N[(-0.16666666666666666 * N[(th * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
                                                      
                                                      \begin{array}{l}
                                                      
                                                      \\
                                                      \begin{array}{l}
                                                      \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2.15 \cdot 10^{-44}:\\
                                                      \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\
                                                      
                                                      \mathbf{else}:\\
                                                      \;\;\;\;\sin th\\
                                                      
                                                      
                                                      \end{array}
                                                      \end{array}
                                                      
                                                      Derivation
                                                      1. Split input into 2 regimes
                                                      2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2.15000000000000007e-44

                                                        1. Initial program 92.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.f644.1

                                                            \[\leadsto \color{blue}{\sin th} \]
                                                        5. Applied rewrites4.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 rewrites4.1%

                                                            \[\leadsto \mathsf{fma}\left(th, \color{blue}{-0.16666666666666666 \cdot \left(th \cdot th\right)}, th\right) \]
                                                          2. Taylor expanded in th around inf

                                                            \[\leadsto \frac{-1}{6} \cdot {th}^{\color{blue}{3}} \]
                                                          3. Step-by-step derivation
                                                            1. Applied rewrites21.2%

                                                              \[\leadsto -0.16666666666666666 \cdot \left(th \cdot \color{blue}{\left(th \cdot th\right)}\right) \]

                                                            if 2.15000000000000007e-44 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                                            1. Initial program 90.6%

                                                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                            2. Add Preprocessing
                                                            3. Taylor expanded in kx around 0

                                                              \[\leadsto \color{blue}{\sin th} \]
                                                            4. Step-by-step derivation
                                                              1. lower-sin.f6460.8

                                                                \[\leadsto \color{blue}{\sin th} \]
                                                            5. Applied rewrites60.8%

                                                              \[\leadsto \color{blue}{\sin th} \]
                                                          4. Recombined 2 regimes into one program.
                                                          5. Add Preprocessing

                                                          Alternative 24: 21.1% accurate, 1.2× speedup?

                                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2.15 \cdot 10^{-44}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;th \cdot \mathsf{fma}\left(th, th \cdot -0.16666666666666666, 1\right)\\ \end{array} \end{array} \]
                                                          (FPCore (kx ky th)
                                                           :precision binary64
                                                           (if (<=
                                                                (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))
                                                                2.15e-44)
                                                             (* -0.16666666666666666 (* th (* th th)))
                                                             (* th (fma th (* th -0.16666666666666666) 1.0))))
                                                          double code(double kx, double ky, double th) {
                                                          	double tmp;
                                                          	if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 2.15e-44) {
                                                          		tmp = -0.16666666666666666 * (th * (th * th));
                                                          	} else {
                                                          		tmp = th * fma(th, (th * -0.16666666666666666), 1.0);
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          function code(kx, ky, th)
                                                          	tmp = 0.0
                                                          	if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 2.15e-44)
                                                          		tmp = Float64(-0.16666666666666666 * Float64(th * Float64(th * th)));
                                                          	else
                                                          		tmp = Float64(th * fma(th, Float64(th * -0.16666666666666666), 1.0));
                                                          	end
                                                          	return tmp
                                                          end
                                                          
                                                          code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.15e-44], N[(-0.16666666666666666 * N[(th * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(th * N[(th * N[(th * -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
                                                          
                                                          \begin{array}{l}
                                                          
                                                          \\
                                                          \begin{array}{l}
                                                          \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2.15 \cdot 10^{-44}:\\
                                                          \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;th \cdot \mathsf{fma}\left(th, th \cdot -0.16666666666666666, 1\right)\\
                                                          
                                                          
                                                          \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))))) < 2.15000000000000007e-44

                                                            1. Initial program 92.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.f644.1

                                                                \[\leadsto \color{blue}{\sin th} \]
                                                            5. Applied rewrites4.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 rewrites4.1%

                                                                \[\leadsto \mathsf{fma}\left(th, \color{blue}{-0.16666666666666666 \cdot \left(th \cdot th\right)}, th\right) \]
                                                              2. Taylor expanded in th around inf

                                                                \[\leadsto \frac{-1}{6} \cdot {th}^{\color{blue}{3}} \]
                                                              3. Step-by-step derivation
                                                                1. Applied rewrites21.2%

                                                                  \[\leadsto -0.16666666666666666 \cdot \left(th \cdot \color{blue}{\left(th \cdot th\right)}\right) \]

                                                                if 2.15000000000000007e-44 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

                                                                1. Initial program 90.6%

                                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                2. Add Preprocessing
                                                                3. Taylor expanded in kx around 0

                                                                  \[\leadsto \color{blue}{\sin th} \]
                                                                4. Step-by-step derivation
                                                                  1. lower-sin.f6460.8

                                                                    \[\leadsto \color{blue}{\sin th} \]
                                                                5. Applied rewrites60.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 rewrites30.5%

                                                                    \[\leadsto \mathsf{fma}\left(th, \color{blue}{-0.16666666666666666 \cdot \left(th \cdot th\right)}, th\right) \]
                                                                  2. Step-by-step derivation
                                                                    1. Applied rewrites30.5%

                                                                      \[\leadsto \mathsf{fma}\left(th, th \cdot -0.16666666666666666, 1\right) \cdot th \]
                                                                  3. Recombined 2 regimes into one program.
                                                                  4. Final simplification24.6%

                                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 2.15 \cdot 10^{-44}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;th \cdot \mathsf{fma}\left(th, th \cdot -0.16666666666666666, 1\right)\\ \end{array} \]
                                                                  5. Add Preprocessing

                                                                  Alternative 25: 52.1% accurate, 1.8× speedup?

                                                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 1.12 \cdot 10^{-157}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right), \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\ \mathbf{elif}\;ky \leq 0.0055:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, ky \cdot ky\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\ \end{array} \end{array} \]
                                                                  (FPCore (kx ky th)
                                                                   :precision binary64
                                                                   (if (<= ky 1.12e-157)
                                                                     (*
                                                                      (sin th)
                                                                      (/
                                                                       (sin ky)
                                                                       (hypot
                                                                        (fma ky (* -0.16666666666666666 (* ky ky)) ky)
                                                                        (fma kx (* -0.16666666666666666 (* kx kx)) kx))))
                                                                     (if (<= ky 0.0055)
                                                                       (*
                                                                        (sin ky)
                                                                        (/ (sin th) (sqrt (fma (- 1.0 (cos (+ kx kx))) 0.5 (* ky ky)))))
                                                                       (* (sin th) (/ (sin ky) (sqrt (fma -0.5 (cos (* ky -2.0)) 0.5)))))))
                                                                  double code(double kx, double ky, double th) {
                                                                  	double tmp;
                                                                  	if (ky <= 1.12e-157) {
                                                                  		tmp = sin(th) * (sin(ky) / hypot(fma(ky, (-0.16666666666666666 * (ky * ky)), ky), fma(kx, (-0.16666666666666666 * (kx * kx)), kx)));
                                                                  	} else if (ky <= 0.0055) {
                                                                  		tmp = sin(ky) * (sin(th) / sqrt(fma((1.0 - cos((kx + kx))), 0.5, (ky * ky))));
                                                                  	} else {
                                                                  		tmp = sin(th) * (sin(ky) / sqrt(fma(-0.5, cos((ky * -2.0)), 0.5)));
                                                                  	}
                                                                  	return tmp;
                                                                  }
                                                                  
                                                                  function code(kx, ky, th)
                                                                  	tmp = 0.0
                                                                  	if (ky <= 1.12e-157)
                                                                  		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(fma(ky, Float64(-0.16666666666666666 * Float64(ky * ky)), ky), fma(kx, Float64(-0.16666666666666666 * Float64(kx * kx)), kx))));
                                                                  	elseif (ky <= 0.0055)
                                                                  		tmp = Float64(sin(ky) * Float64(sin(th) / sqrt(fma(Float64(1.0 - cos(Float64(kx + kx))), 0.5, Float64(ky * ky)))));
                                                                  	else
                                                                  		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(-0.5, cos(Float64(ky * -2.0)), 0.5))));
                                                                  	end
                                                                  	return tmp
                                                                  end
                                                                  
                                                                  code[kx_, ky_, th_] := If[LessEqual[ky, 1.12e-157], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(ky * N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] + ky), $MachinePrecision] ^ 2 + N[(kx * N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision]), $MachinePrecision] + kx), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 0.0055], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(ky * ky), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(-0.5 * N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                                                                  
                                                                  \begin{array}{l}
                                                                  
                                                                  \\
                                                                  \begin{array}{l}
                                                                  \mathbf{if}\;ky \leq 1.12 \cdot 10^{-157}:\\
                                                                  \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right), \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\
                                                                  
                                                                  \mathbf{elif}\;ky \leq 0.0055:\\
                                                                  \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, ky \cdot ky\right)}}\\
                                                                  
                                                                  \mathbf{else}:\\
                                                                  \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\
                                                                  
                                                                  
                                                                  \end{array}
                                                                  \end{array}
                                                                  
                                                                  Derivation
                                                                  1. Split input into 3 regimes
                                                                  2. if ky < 1.12000000000000001e-157

                                                                    1. Initial program 87.8%

                                                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                    2. Add Preprocessing
                                                                    3. Step-by-step derivation
                                                                      1. lift-sqrt.f64N/A

                                                                        \[\leadsto \frac{\sin ky}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                                                                      2. lift-+.f64N/A

                                                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
                                                                      3. +-commutativeN/A

                                                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
                                                                      4. lift-pow.f64N/A

                                                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
                                                                      5. unpow2N/A

                                                                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
                                                                      6. lift-pow.f64N/A

                                                                        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{{\sin kx}^{2}}}} \cdot \sin th \]
                                                                      7. unpow2N/A

                                                                        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
                                                                      8. lower-hypot.f6499.7

                                                                        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                                                    4. Applied rewrites99.7%

                                                                      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
                                                                    5. Taylor expanded in 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, kx \cdot \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2} + 1\right)}\right)} \cdot \sin th \]
                                                                      2. distribute-lft-inN/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(\frac{-1}{6} \cdot {kx}^{2}\right) + kx \cdot 1}\right)} \cdot \sin th \]
                                                                      3. *-rgt-identityN/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx \cdot \left(\frac{-1}{6} \cdot {kx}^{2}\right) + \color{blue}{kx}\right)} \cdot \sin th \]
                                                                      4. lower-fma.f64N/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, \frac{-1}{6} \cdot {kx}^{2}, kx\right)}\right)} \cdot \sin th \]
                                                                      5. lower-*.f64N/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, \color{blue}{\frac{-1}{6} \cdot {kx}^{2}}, kx\right)\right)} \cdot \sin th \]
                                                                      6. unpow2N/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \color{blue}{\left(kx \cdot kx\right)}, kx\right)\right)} \cdot \sin th \]
                                                                      7. lower-*.f6467.9

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \color{blue}{\left(kx \cdot kx\right)}, kx\right)\right)} \cdot \sin th \]
                                                                    7. Applied rewrites67.9%

                                                                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{\mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)}\right)} \cdot \sin th \]
                                                                    8. 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)}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                                                                    9. Step-by-step derivation
                                                                      1. +-commutativeN/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(ky \cdot \color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2} + 1\right)}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                                                                      2. distribute-lft-inN/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{ky \cdot \left(\frac{-1}{6} \cdot {ky}^{2}\right) + ky \cdot 1}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                                                                      3. *-rgt-identityN/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(ky \cdot \left(\frac{-1}{6} \cdot {ky}^{2}\right) + \color{blue}{ky}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                                                                      4. lower-fma.f64N/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\mathsf{fma}\left(ky, \frac{-1}{6} \cdot {ky}^{2}, ky\right)}, \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                                                                      5. *-commutativeN/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\mathsf{fma}\left(ky, \color{blue}{{ky}^{2} \cdot \frac{-1}{6}}, ky\right), \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                                                                      6. lower-*.f64N/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\mathsf{fma}\left(ky, \color{blue}{{ky}^{2} \cdot \frac{-1}{6}}, ky\right), \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                                                                      7. unpow2N/A

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\mathsf{fma}\left(ky, \color{blue}{\left(ky \cdot ky\right)} \cdot \frac{-1}{6}, ky\right), \mathsf{fma}\left(kx, \frac{-1}{6} \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                                                                      8. lower-*.f6447.8

                                                                        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\mathsf{fma}\left(ky, \color{blue}{\left(ky \cdot ky\right)} \cdot -0.16666666666666666, ky\right), \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]
                                                                    10. Applied rewrites47.8%

                                                                      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\color{blue}{\mathsf{fma}\left(ky, \left(ky \cdot ky\right) \cdot -0.16666666666666666, ky\right)}, \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)} \cdot \sin th \]

                                                                    if 1.12000000000000001e-157 < ky < 0.0054999999999999997

                                                                    1. Initial program 99.6%

                                                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                    2. Add Preprocessing
                                                                    3. Step-by-step derivation
                                                                      1. lift-*.f64N/A

                                                                        \[\leadsto \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 rewrites60.8%

                                                                      \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                                                    5. Taylor expanded in ky around 0

                                                                      \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{{ky}^{2}}\right)}} \cdot \sin ky \]
                                                                    6. Step-by-step derivation
                                                                      1. unpow2N/A

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{ky \cdot ky}\right)}} \cdot \sin ky \]
                                                                      2. lower-*.f6493.5

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, \color{blue}{ky \cdot ky}\right)}} \cdot \sin ky \]
                                                                    7. Applied rewrites93.5%

                                                                      \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, \color{blue}{ky \cdot ky}\right)}} \cdot \sin ky \]

                                                                    if 0.0054999999999999997 < ky

                                                                    1. Initial program 99.7%

                                                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                    2. Add Preprocessing
                                                                    3. Step-by-step derivation
                                                                      1. 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 rewrites97.4%

                                                                      \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                                                    5. Taylor expanded in kx around 0

                                                                      \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)}}} \cdot \sin ky \]
                                                                    6. Step-by-step derivation
                                                                      1. +-commutativeN/A

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2}}}} \cdot \sin ky \]
                                                                      2. metadata-evalN/A

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right) + \frac{1}{2}}} \cdot \sin ky \]
                                                                      3. distribute-lft-neg-inN/A

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)} + \frac{1}{2}}} \cdot \sin ky \]
                                                                      4. lower-fma.f64N/A

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right), \frac{1}{2}\right)}}} \cdot \sin ky \]
                                                                      5. cos-negN/A

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot ky\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                                                                      6. lower-cos.f64N/A

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot ky\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                                                                      7. *-commutativeN/A

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(ky \cdot -2\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                                                                      8. lower-*.f6463.9

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(ky \cdot -2\right)}, 0.5\right)}} \cdot \sin ky \]
                                                                    7. Applied rewrites63.9%

                                                                      \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}} \cdot \sin ky \]
                                                                    8. Step-by-step derivation
                                                                      1. lift-*.f64N/A

                                                                        \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(ky \cdot -2\right), \frac{1}{2}\right)}} \cdot \sin ky} \]
                                                                      2. lift-/.f64N/A

                                                                        \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(ky \cdot -2\right), \frac{1}{2}\right)}}} \cdot \sin ky \]
                                                                      3. associate-*l/N/A

                                                                        \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(ky \cdot -2\right), \frac{1}{2}\right)}}} \]
                                                                      4. associate-/l*N/A

                                                                        \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(ky \cdot -2\right), \frac{1}{2}\right)}}} \]
                                                                    9. Applied rewrites64.0%

                                                                      \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}} \]
                                                                  3. Recombined 3 regimes into one program.
                                                                  4. Final simplification56.9%

                                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 1.12 \cdot 10^{-157}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right), \mathsf{fma}\left(kx, -0.16666666666666666 \cdot \left(kx \cdot kx\right), kx\right)\right)}\\ \mathbf{elif}\;ky \leq 0.0055:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, ky \cdot ky\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\ \end{array} \]
                                                                  5. Add Preprocessing

                                                                  Alternative 26: 45.3% accurate, 1.8× speedup?

                                                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 3.8 \cdot 10^{-186}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{elif}\;ky \leq 0.0055:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, ky \cdot ky\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\ \end{array} \end{array} \]
                                                                  (FPCore (kx ky th)
                                                                   :precision binary64
                                                                   (if (<= ky 3.8e-186)
                                                                     (* ky (/ (sin th) (sin kx)))
                                                                     (if (<= ky 0.0055)
                                                                       (*
                                                                        (sin ky)
                                                                        (/ (sin th) (sqrt (fma (- 1.0 (cos (+ kx kx))) 0.5 (* ky ky)))))
                                                                       (* (sin th) (/ (sin ky) (sqrt (fma -0.5 (cos (* ky -2.0)) 0.5)))))))
                                                                  double code(double kx, double ky, double th) {
                                                                  	double tmp;
                                                                  	if (ky <= 3.8e-186) {
                                                                  		tmp = ky * (sin(th) / sin(kx));
                                                                  	} else if (ky <= 0.0055) {
                                                                  		tmp = sin(ky) * (sin(th) / sqrt(fma((1.0 - cos((kx + kx))), 0.5, (ky * ky))));
                                                                  	} else {
                                                                  		tmp = sin(th) * (sin(ky) / sqrt(fma(-0.5, cos((ky * -2.0)), 0.5)));
                                                                  	}
                                                                  	return tmp;
                                                                  }
                                                                  
                                                                  function code(kx, ky, th)
                                                                  	tmp = 0.0
                                                                  	if (ky <= 3.8e-186)
                                                                  		tmp = Float64(ky * Float64(sin(th) / sin(kx)));
                                                                  	elseif (ky <= 0.0055)
                                                                  		tmp = Float64(sin(ky) * Float64(sin(th) / sqrt(fma(Float64(1.0 - cos(Float64(kx + kx))), 0.5, Float64(ky * ky)))));
                                                                  	else
                                                                  		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(-0.5, cos(Float64(ky * -2.0)), 0.5))));
                                                                  	end
                                                                  	return tmp
                                                                  end
                                                                  
                                                                  code[kx_, ky_, th_] := If[LessEqual[ky, 3.8e-186], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 0.0055], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(ky * ky), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(-0.5 * N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                                                                  
                                                                  \begin{array}{l}
                                                                  
                                                                  \\
                                                                  \begin{array}{l}
                                                                  \mathbf{if}\;ky \leq 3.8 \cdot 10^{-186}:\\
                                                                  \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
                                                                  
                                                                  \mathbf{elif}\;ky \leq 0.0055:\\
                                                                  \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, ky \cdot ky\right)}}\\
                                                                  
                                                                  \mathbf{else}:\\
                                                                  \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\
                                                                  
                                                                  
                                                                  \end{array}
                                                                  \end{array}
                                                                  
                                                                  Derivation
                                                                  1. Split input into 3 regimes
                                                                  2. if ky < 3.79999999999999974e-186

                                                                    1. Initial program 89.1%

                                                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                    2. Add Preprocessing
                                                                    3. Taylor expanded in 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. lower-*.f64N/A

                                                                        \[\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)} \]
                                                                      2. distribute-lft-inN/A

                                                                        \[\leadsto ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right)\right)} + \frac{\sin th}{\sin kx}\right) \]
                                                                      3. *-commutativeN/A

                                                                        \[\leadsto ky \cdot \left(\left(\color{blue}{\left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right)\right) + \frac{\sin th}{\sin kx}\right) \]
                                                                      4. associate-+r+N/A

                                                                        \[\leadsto ky \cdot \color{blue}{\left(\left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2} + \left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right) + \frac{\sin th}{\sin kx}\right)\right)} \]
                                                                      5. +-commutativeN/A

                                                                        \[\leadsto ky \cdot \color{blue}{\left(\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \frac{\sin th}{\sin kx}\right) + \frac{\sin th}{\sin kx}\right) + \left(\frac{-1}{2} \cdot \frac{\sin th}{{\sin kx}^{3}}\right) \cdot {ky}^{2}\right)} \]
                                                                    5. Applied rewrites28.1%

                                                                      \[\leadsto \color{blue}{ky \cdot \mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right), \frac{\sin th}{\sin kx}, \frac{\left(ky \cdot ky\right) \cdot \left(-0.5 \cdot \sin th\right)}{{\sin kx}^{3}}\right)} \]
                                                                    6. Taylor expanded in ky around 0

                                                                      \[\leadsto ky \cdot \frac{\sin th}{\color{blue}{\sin kx}} \]
                                                                    7. Step-by-step derivation
                                                                      1. Applied rewrites35.5%

                                                                        \[\leadsto ky \cdot \frac{\sin th}{\color{blue}{\sin kx}} \]

                                                                      if 3.79999999999999974e-186 < ky < 0.0054999999999999997

                                                                      1. Initial program 92.1%

                                                                        \[\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 rewrites58.0%

                                                                        \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                                                      5. Taylor expanded in ky around 0

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{{ky}^{2}}\right)}} \cdot \sin ky \]
                                                                      6. Step-by-step derivation
                                                                        1. unpow2N/A

                                                                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \color{blue}{ky \cdot ky}\right)}} \cdot \sin ky \]
                                                                        2. lower-*.f6486.8

                                                                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, \color{blue}{ky \cdot ky}\right)}} \cdot \sin ky \]
                                                                      7. Applied rewrites86.8%

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, \color{blue}{ky \cdot ky}\right)}} \cdot \sin ky \]

                                                                      if 0.0054999999999999997 < ky

                                                                      1. Initial program 99.7%

                                                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                      2. Add Preprocessing
                                                                      3. Step-by-step derivation
                                                                        1. 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 rewrites97.4%

                                                                        \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \sin ky} \]
                                                                      5. Taylor expanded in kx around 0

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot ky\right)}}} \cdot \sin ky \]
                                                                      6. Step-by-step derivation
                                                                        1. +-commutativeN/A

                                                                          \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot ky\right) + \frac{1}{2}}}} \cdot \sin ky \]
                                                                        2. metadata-evalN/A

                                                                          \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right) + \frac{1}{2}}} \cdot \sin ky \]
                                                                        3. distribute-lft-neg-inN/A

                                                                          \[\leadsto \frac{\sin th}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)} + \frac{1}{2}}} \cdot \sin ky \]
                                                                        4. lower-fma.f64N/A

                                                                          \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right), \frac{1}{2}\right)}}} \cdot \sin ky \]
                                                                        5. cos-negN/A

                                                                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot ky\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                                                                        6. lower-cos.f64N/A

                                                                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot ky\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                                                                        7. *-commutativeN/A

                                                                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(ky \cdot -2\right)}, \frac{1}{2}\right)}} \cdot \sin ky \]
                                                                        8. lower-*.f6463.9

                                                                          \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(ky \cdot -2\right)}, 0.5\right)}} \cdot \sin ky \]
                                                                      7. Applied rewrites63.9%

                                                                        \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}} \cdot \sin ky \]
                                                                      8. Step-by-step derivation
                                                                        1. lift-*.f64N/A

                                                                          \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(ky \cdot -2\right), \frac{1}{2}\right)}} \cdot \sin ky} \]
                                                                        2. lift-/.f64N/A

                                                                          \[\leadsto \color{blue}{\frac{\sin th}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(ky \cdot -2\right), \frac{1}{2}\right)}}} \cdot \sin ky \]
                                                                        3. associate-*l/N/A

                                                                          \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(ky \cdot -2\right), \frac{1}{2}\right)}}} \]
                                                                        4. associate-/l*N/A

                                                                          \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(ky \cdot -2\right), \frac{1}{2}\right)}}} \]
                                                                      9. Applied rewrites64.0%

                                                                        \[\leadsto \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}} \]
                                                                    8. Recombined 3 regimes into one program.
                                                                    9. Final simplification49.1%

                                                                      \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 3.8 \cdot 10^{-186}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{elif}\;ky \leq 0.0055:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, ky \cdot ky\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\ \end{array} \]
                                                                    10. Add Preprocessing

                                                                    Alternative 27: 11.2% accurate, 39.5× speedup?

                                                                    \[\begin{array}{l} \\ -0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right) \end{array} \]
                                                                    (FPCore (kx ky th)
                                                                     :precision binary64
                                                                     (* -0.16666666666666666 (* th (* th th))))
                                                                    double code(double kx, double ky, double th) {
                                                                    	return -0.16666666666666666 * (th * (th * th));
                                                                    }
                                                                    
                                                                    real(8) function code(kx, ky, th)
                                                                        real(8), intent (in) :: kx
                                                                        real(8), intent (in) :: ky
                                                                        real(8), intent (in) :: th
                                                                        code = (-0.16666666666666666d0) * (th * (th * th))
                                                                    end function
                                                                    
                                                                    public static double code(double kx, double ky, double th) {
                                                                    	return -0.16666666666666666 * (th * (th * th));
                                                                    }
                                                                    
                                                                    def code(kx, ky, th):
                                                                    	return -0.16666666666666666 * (th * (th * th))
                                                                    
                                                                    function code(kx, ky, th)
                                                                    	return Float64(-0.16666666666666666 * Float64(th * Float64(th * th)))
                                                                    end
                                                                    
                                                                    function tmp = code(kx, ky, th)
                                                                    	tmp = -0.16666666666666666 * (th * (th * th));
                                                                    end
                                                                    
                                                                    code[kx_, ky_, th_] := N[(-0.16666666666666666 * N[(th * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                                                                    
                                                                    \begin{array}{l}
                                                                    
                                                                    \\
                                                                    -0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)
                                                                    \end{array}
                                                                    
                                                                    Derivation
                                                                    1. Initial program 92.0%

                                                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                    2. Add Preprocessing
                                                                    3. Taylor expanded in kx around 0

                                                                      \[\leadsto \color{blue}{\sin th} \]
                                                                    4. Step-by-step derivation
                                                                      1. lower-sin.f6424.7

                                                                        \[\leadsto \color{blue}{\sin th} \]
                                                                    5. Applied rewrites24.7%

                                                                      \[\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.7%

                                                                        \[\leadsto \mathsf{fma}\left(th, \color{blue}{-0.16666666666666666 \cdot \left(th \cdot th\right)}, th\right) \]
                                                                      2. Taylor expanded in th around inf

                                                                        \[\leadsto \frac{-1}{6} \cdot {th}^{\color{blue}{3}} \]
                                                                      3. Step-by-step derivation
                                                                        1. Applied rewrites14.8%

                                                                          \[\leadsto -0.16666666666666666 \cdot \left(th \cdot \color{blue}{\left(th \cdot th\right)}\right) \]
                                                                        2. Add Preprocessing

                                                                        Reproduce

                                                                        ?
                                                                        herbie shell --seed 2024223 
                                                                        (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)))