Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.2% → 99.7%
Time: 17.8s
Alternatives: 34
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 34 alternatives:

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

Initial Program: 94.2% 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 93.6%

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

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

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;t\_2 \leq -0.01:\\
\;\;\;\;\frac{\sin ky}{t\_3} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, -0.16666666666666666 \cdot \left(ky \cdot ky\right), ky\right)}{t\_3}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -1 or 0.99811092769088416 < (/.f64 (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 84.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, 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-*.f64100.0

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

      \[\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 kx around inf

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

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

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

      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, \color{blue}{kx \cdot kx}, kx\right)\right)} \cdot \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))))) < -0.0100000000000000002

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0100000000000000002 < (/.f64 (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.9999999999999999e-7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.9999999999999999e-7 < (/.f64 (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.99811092769088416

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(th \cdot \sin ky\right) \cdot \sqrt{\frac{1}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right) + \color{blue}{\left(\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)\right)}}} \]
      10. 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 ky\right), \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)\right)}}} \]
    7. Simplified66.5%

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

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

Alternative 3: 99.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\ \;\;\;\;\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 \left(\sin ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}\right)\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (pow (sin kx) 2.0) 1e-12)
   (*
    (sin th)
    (/
     (sin ky)
     (hypot (sin ky) (fma kx (* -0.16666666666666666 (* kx kx)) kx))))
   (*
    (sin th)
    (*
     (sin ky)
     (sqrt
      (/
       1.0
       (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) <= 1e-12) {
		tmp = sin(th) * (sin(ky) / hypot(sin(ky), fma(kx, (-0.16666666666666666 * (kx * kx)), kx)));
	} else {
		tmp = sin(th) * (sin(ky) * sqrt((1.0 / 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) <= 1e-12)
		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(Float64(1.0 / 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], 1e-12], 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[(1.0 / 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]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\
\;\;\;\;\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 \left(\sin ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}\right)\\


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

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
    5. Taylor expanded in 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. Simplified99.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 9.9999999999999998e-13 < (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. Applied egg-rr99.4%

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

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

Alternative 4: 99.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\ \;\;\;\;\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}:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \left(\sin ky \cdot \sin th\right)\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (pow (sin kx) 2.0) 1e-12)
   (*
    (sin th)
    (/
     (sin ky)
     (hypot (sin ky) (fma kx (* -0.16666666666666666 (* kx kx)) kx))))
   (*
    (sqrt
     (/
      1.0
      (fma (- 1.0 (cos (+ kx kx))) 0.5 (+ 0.5 (* -0.5 (cos (+ ky ky)))))))
    (* (sin ky) (sin th)))))
double code(double kx, double ky, double th) {
	double tmp;
	if (pow(sin(kx), 2.0) <= 1e-12) {
		tmp = sin(th) * (sin(ky) / hypot(sin(ky), fma(kx, (-0.16666666666666666 * (kx * kx)), kx)));
	} else {
		tmp = sqrt((1.0 / fma((1.0 - cos((kx + kx))), 0.5, (0.5 + (-0.5 * cos((ky + ky))))))) * (sin(ky) * sin(th));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if ((sin(kx) ^ 2.0) <= 1e-12)
		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), fma(kx, Float64(-0.16666666666666666 * Float64(kx * kx)), kx))));
	else
		tmp = Float64(sqrt(Float64(1.0 / fma(Float64(1.0 - cos(Float64(kx + kx))), 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(ky + ky))))))) * Float64(sin(ky) * sin(th)));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 1e-12], 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[Sqrt[N[(1.0 / 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] * N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\
\;\;\;\;\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}:\\
\;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}} \cdot \left(\sin ky \cdot \sin th\right)\\


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

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
    5. Taylor expanded in 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. Simplified99.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 9.9999999999999998e-13 < (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. Applied egg-rr99.3%

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

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

Alternative 5: 99.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\ \;\;\;\;\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(ky + ky\right), 0.5, 0.5 + \cos \left(kx + kx\right) \cdot -0.5\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (pow (sin kx) 2.0) 1e-12)
   (*
    (sin th)
    (/
     (sin ky)
     (hypot (sin ky) (fma kx (* -0.16666666666666666 (* kx kx)) kx))))
   (*
    (sin th)
    (/
     (sin ky)
     (sqrt
      (fma (- 1.0 (cos (+ ky ky))) 0.5 (+ 0.5 (* (cos (+ kx kx)) -0.5))))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (pow(sin(kx), 2.0) <= 1e-12) {
		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((ky + ky))), 0.5, (0.5 + (cos((kx + kx)) * -0.5)))));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if ((sin(kx) ^ 2.0) <= 1e-12)
		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(ky + ky))), 0.5, Float64(0.5 + Float64(cos(Float64(kx + kx)) * -0.5))))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 1e-12], 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[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.5 + N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\
\;\;\;\;\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(ky + ky\right), 0.5, 0.5 + \cos \left(kx + kx\right) \cdot -0.5\right)}}\\


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

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
    5. Taylor expanded in 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. Simplified99.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 9.9999999999999998e-13 < (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-sin.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. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\ \;\;\;\;\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(ky + ky\right), 0.5, 0.5 + \cos \left(kx + kx\right) \cdot -0.5\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 99.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\ \;\;\;\;\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(ky + ky\right), 0.5, 0.5\right) - \cos \left(kx + kx\right) \cdot 0.5}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (pow (sin kx) 2.0) 1e-12)
   (*
    (sin th)
    (/
     (sin ky)
     (hypot (sin ky) (fma kx (* -0.16666666666666666 (* kx kx)) kx))))
   (*
    (sin th)
    (/
     (sin ky)
     (sqrt
      (- (fma (- 1.0 (cos (+ ky ky))) 0.5 0.5) (* (cos (+ kx kx)) 0.5)))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (pow(sin(kx), 2.0) <= 1e-12) {
		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((ky + ky))), 0.5, 0.5) - (cos((kx + kx)) * 0.5))));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if ((sin(kx) ^ 2.0) <= 1e-12)
		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(Float64(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, 0.5) - Float64(cos(Float64(kx + kx)) * 0.5)))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 1e-12], 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[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] - N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\
\;\;\;\;\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(ky + ky\right), 0.5, 0.5\right) - \cos \left(kx + kx\right) \cdot 0.5}}\\


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

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
    5. Taylor expanded in 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. Simplified99.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 9.9999999999999998e-13 < (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-sin.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. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\ \;\;\;\;\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(ky + ky\right), 0.5, 0.5\right) - \cos \left(kx + kx\right) \cdot 0.5}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 99.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\ \;\;\;\;\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\right) - 0.5 \cdot \cos \left(ky + ky\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (pow (sin kx) 2.0) 1e-12)
   (*
    (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) <= 1e-12) {
		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) <= 1e-12)
		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(Float64(fma(Float64(1.0 - cos(Float64(kx + kx))), 0.5, 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], 1e-12], 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[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] - N[(0.5 * N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\
\;\;\;\;\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\right) - 0.5 \cdot \cos \left(ky + ky\right)}}\\


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

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
    5. Taylor expanded in 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. Simplified99.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 9.9999999999999998e-13 < (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-sin.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. lift-sin.f64N/A

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\ \;\;\;\;\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\right) - 0.5 \cdot \cos \left(ky + ky\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 34.1% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\
\;\;\;\;\sin th \cdot \frac{1}{kx \cdot \mathsf{fma}\left(-0.3333333333333333, \frac{\left(kx \cdot kx\right) \cdot \sqrt{0.5}}{ky \cdot \sqrt{2}}, \sqrt{0.5} \cdot \frac{\sqrt{2}}{ky}\right)}\\

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


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

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999998e-13 < (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. Applied egg-rr99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 34.1% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 10^{-12}:\\
\;\;\;\;\sin th \cdot \frac{1}{kx \cdot \mathsf{fma}\left(-0.3333333333333333, \frac{\left(kx \cdot kx\right) \cdot \sqrt{0.5}}{ky \cdot \sqrt{2}}, \sqrt{0.5} \cdot \frac{\sqrt{2}}{ky}\right)}\\

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


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

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999998e-13 < (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. Applied egg-rr99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 69.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 0.86:\\ \;\;\;\;\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{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}{\sin ky}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= kx 0.86)
   (*
    (sin th)
    (/
     (sin ky)
     (hypot (sin ky) (fma kx (* -0.16666666666666666 (* kx kx)) kx))))
   (*
    (sin th)
    (/ 1.0 (/ (* (sqrt (- 1.0 (cos (* kx -2.0)))) (sqrt 0.5)) (sin ky))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (kx <= 0.86) {
		tmp = sin(th) * (sin(ky) / hypot(sin(ky), fma(kx, (-0.16666666666666666 * (kx * kx)), kx)));
	} else {
		tmp = sin(th) * (1.0 / ((sqrt((1.0 - cos((kx * -2.0)))) * sqrt(0.5)) / sin(ky)));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if (kx <= 0.86)
		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(1.0 / Float64(Float64(sqrt(Float64(1.0 - cos(Float64(kx * -2.0)))) * sqrt(0.5)) / sin(ky))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[kx, 0.86], 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[(1.0 / N[(N[(N[Sqrt[N[(1.0 - N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.86:\\
\;\;\;\;\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{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}{\sin ky}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if kx < 0.859999999999999987

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)} \cdot \sin th \]
    6. Step-by-step derivation
      1. +-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-*.f6473.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. Simplified73.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 0.859999999999999987 < kx

    1. Initial program 99.5%

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      5. lift-*.f64N/A

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

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      7. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      8. flip-+N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      9. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      11. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      12. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      13. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      14. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      15. flip-+N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      16. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      17. lower-fma.f6433.7

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
    5. Applied egg-rr99.2%

      \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
    6. Taylor expanded in ky around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 0.86:\\ \;\;\;\;\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{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}{\sin ky}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 69.6% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.86:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(kx, kx \cdot kx, kx\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if kx < 0.859999999999999987

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)} \cdot \sin th \]
    6. Step-by-step derivation
      1. +-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-*.f6473.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. Simplified73.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 kx around inf

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

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

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

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

    if 0.859999999999999987 < kx

    1. Initial program 99.5%

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      5. lift-*.f64N/A

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

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      7. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      8. flip-+N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      9. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      11. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      12. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      13. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      14. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      15. flip-+N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      16. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      17. lower-fma.f6433.7

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
    5. Applied egg-rr99.2%

      \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
    6. Taylor expanded in ky around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 21.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 0.01:\\ \;\;\;\;\sin th \cdot \frac{1}{kx \cdot \mathsf{fma}\left(-0.3333333333333333, \frac{\left(kx \cdot kx\right) \cdot \sqrt{0.5}}{ky \cdot \sqrt{2}}, \sqrt{0.5} \cdot \frac{\sqrt{2}}{ky}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(ky \cdot \frac{th}{\sqrt{0.5}}\right)\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (pow (sin kx) 2.0) 0.01)
   (*
    (sin th)
    (/
     1.0
     (*
      kx
      (fma
       -0.3333333333333333
       (/ (* (* kx kx) (sqrt 0.5)) (* ky (sqrt 2.0)))
       (* (sqrt 0.5) (/ (sqrt 2.0) ky))))))
   (* (sqrt (/ 1.0 (- 1.0 (cos (* kx -2.0))))) (* ky (/ th (sqrt 0.5))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (pow(sin(kx), 2.0) <= 0.01) {
		tmp = sin(th) * (1.0 / (kx * fma(-0.3333333333333333, (((kx * kx) * sqrt(0.5)) / (ky * sqrt(2.0))), (sqrt(0.5) * (sqrt(2.0) / ky)))));
	} else {
		tmp = sqrt((1.0 / (1.0 - cos((kx * -2.0))))) * (ky * (th / sqrt(0.5)));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if ((sin(kx) ^ 2.0) <= 0.01)
		tmp = Float64(sin(th) * Float64(1.0 / Float64(kx * fma(-0.3333333333333333, Float64(Float64(Float64(kx * kx) * sqrt(0.5)) / Float64(ky * sqrt(2.0))), Float64(sqrt(0.5) * Float64(sqrt(2.0) / ky))))));
	else
		tmp = Float64(sqrt(Float64(1.0 / Float64(1.0 - cos(Float64(kx * -2.0))))) * Float64(ky * Float64(th / sqrt(0.5))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 0.01], N[(N[Sin[th], $MachinePrecision] * N[(1.0 / N[(kx * N[(-0.3333333333333333 * N[(N[(N[(kx * kx), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] / N[(ky * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 0.01:\\
\;\;\;\;\sin th \cdot \frac{1}{kx \cdot \mathsf{fma}\left(-0.3333333333333333, \frac{\left(kx \cdot kx\right) \cdot \sqrt{0.5}}{ky \cdot \sqrt{2}}, \sqrt{0.5} \cdot \frac{\sqrt{2}}{ky}\right)}\\

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


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

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\left(kx \cdot kx\right) \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}}, \sqrt{\frac{1}{2}} \cdot \color{blue}{\frac{\sqrt{2}}{ky}}\right)} \cdot \sin th \]
      14. lower-sqrt.f6419.6

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

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

    if 0.0100000000000000002 < (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. Applied egg-rr99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 55.2% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.86:\\
\;\;\;\;\sin th \cdot \frac{1}{\frac{\sqrt{\mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, 0.044444444444444446, -0.3333333333333333\right), 1\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}}{\sin ky}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if kx < 0.859999999999999987

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.859999999999999987 < kx

    1. Initial program 99.5%

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      5. lift-*.f64N/A

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

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      7. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      8. flip-+N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      9. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      11. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      12. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      13. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      14. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      15. flip-+N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      16. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      17. lower-fma.f6433.7

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
    5. Applied egg-rr99.2%

      \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
    6. Taylor expanded in ky around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 21.5% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 0.01:\\
\;\;\;\;\frac{1}{\frac{\frac{\sqrt{2} \cdot \left(kx \cdot \sqrt{0.5}\right)}{ky}}{\sin th}}\\

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


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

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{\frac{\left(kx \cdot \sqrt{0.5}\right) \cdot \color{blue}{\sqrt{2}}}{ky}}{\sin th}} \]
    11. Simplified19.5%

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

    if 0.0100000000000000002 < (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. Applied egg-rr99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 36.4% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_1 := \cos \left(kx \cdot -2\right)\\
\mathbf{if}\;ky \leq 3.5 \cdot 10^{-183}:\\
\;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, {ky}^{6}, -0.16666666666666666\right), ky\right)}{kx}\\

\mathbf{elif}\;ky \leq 3.5 \cdot 10^{-161}:\\
\;\;\;\;\frac{1}{\sqrt{1 - t\_1} \cdot \frac{\sqrt{0.5}}{ky \cdot \sin th}}\\

\mathbf{elif}\;ky \leq 2.9 \cdot 10^{-92}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{elif}\;ky \leq 0.0048:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, t\_1, \mathsf{fma}\left(ky, ky, 0.5\right)\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if ky < 3.49999999999999991e-183

    1. Initial program 91.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 \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)\right)} \cdot \sin th \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{120}, {ky}^{6}, \frac{-1}{6}\right)}, ky\right)}{kx} \cdot \sin th \]
      11. lower-pow.f6425.3

        \[\leadsto \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, \color{blue}{{ky}^{6}}, -0.16666666666666666\right), ky\right)}{kx} \cdot \sin th \]
    11. Simplified25.3%

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

    if 3.49999999999999991e-183 < ky < 3.5000000000000002e-161

    1. Initial program 75.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.5000000000000002e-161 < ky < 2.89999999999999985e-92

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.89999999999999985e-92 < ky < 0.00479999999999999958

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 21.5% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 0.01:\\
\;\;\;\;\sin th \cdot \frac{1}{\frac{\sqrt{2} \cdot \left(kx \cdot \sqrt{0.5}\right)}{ky}}\\

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


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

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{\left(kx \cdot \sqrt{0.5}\right) \cdot \color{blue}{\sqrt{2}}}{ky}} \cdot \sin th \]
    9. Simplified19.5%

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

    if 0.0100000000000000002 < (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. Applied egg-rr99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 55.2% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.86:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if kx < 0.859999999999999987

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]

    if 0.859999999999999987 < kx

    1. Initial program 99.5%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Applied egg-rr99.2%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \color{blue}{\left(ky + ky\right)}\right)}}{\sin ky}} \cdot \sin th \]
      2. lift-cos.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \color{blue}{\cos \left(ky + ky\right)}\right)}}{\sin ky}} \cdot \sin th \]
      3. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \frac{1}{2} + \color{blue}{\frac{-1}{2} \cdot \cos \left(ky + ky\right)}\right)}}{\sin ky}} \cdot \sin th \]
      4. +-commutativeN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      5. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      7. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      8. flip-+N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      9. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      11. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      12. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      13. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      14. +-inversesN/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      15. flip-+N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      16. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
      17. lower-fma.f6433.7

        \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
    5. Applied egg-rr99.2%

      \[\leadsto \frac{1}{\frac{\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)}}{\sin ky}} \cdot \sin th \]
    6. Taylor expanded in ky around 0

      \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}}{\sin ky}} \cdot \sin th \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}}{\sin ky}} \cdot \sin th \]
      2. lower-*.f64N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}}{\sin ky}} \cdot \sin th \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}}{\sin ky}} \cdot \sin th \]
      4. metadata-evalN/A

        \[\leadsto \frac{1}{\frac{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}{\sin ky}} \cdot \sin th \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}}{\sin ky}} \cdot \sin th \]
      6. lower--.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \sqrt{\frac{1}{2}}}{\sin ky}} \cdot \sin th \]
      7. cos-negN/A

        \[\leadsto \frac{1}{\frac{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}}{\sin ky}} \cdot \sin th \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \sqrt{\frac{1}{2}}}{\sin ky}} \cdot \sin th \]
      9. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}}{\sin ky}} \cdot \sin th \]
      10. lower-*.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}}{\sin ky}} \cdot \sin th \]
      11. lower-sqrt.f6466.7

        \[\leadsto \frac{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\sqrt{0.5}}}{\sin ky}} \cdot \sin th \]
    8. Simplified66.7%

      \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}}{\sin ky}} \cdot \sin th \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 0.86:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}{\sin ky}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 21.4% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 0.01:\\ \;\;\;\;\sin th \cdot \frac{1}{\frac{\sqrt{2} \cdot \left(kx \cdot \sqrt{0.5}\right)}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (pow (sin kx) 2.0) 0.01)
   (* (sin th) (/ 1.0 (/ (* (sqrt 2.0) (* kx (sqrt 0.5))) ky)))
   (*
    (fma th (* -0.16666666666666666 (* th th)) th)
    (* ky (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5)))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (pow(sin(kx), 2.0) <= 0.01) {
		tmp = sin(th) * (1.0 / ((sqrt(2.0) * (kx * sqrt(0.5))) / ky));
	} else {
		tmp = fma(th, (-0.16666666666666666 * (th * th)), th) * (ky * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5))));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if ((sin(kx) ^ 2.0) <= 0.01)
		tmp = Float64(sin(th) * Float64(1.0 / Float64(Float64(sqrt(2.0) * Float64(kx * sqrt(0.5))) / ky)));
	else
		tmp = Float64(fma(th, Float64(-0.16666666666666666 * Float64(th * th)), th) * Float64(ky * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5)))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 0.01], N[(N[Sin[th], $MachinePrecision] * N[(1.0 / N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(kx * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision] * N[(ky * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 0.01:\\
\;\;\;\;\sin th \cdot \frac{1}{\frac{\sqrt{2} \cdot \left(kx \cdot \sqrt{0.5}\right)}{ky}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 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)) < 0.0100000000000000002

    1. Initial program 87.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Applied egg-rr57.6%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
    4. Taylor expanded in ky around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin th \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      2. lower-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      4. metadata-evalN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      6. lower--.f64N/A

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      7. cos-negN/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      9. *-commutativeN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      10. lower-*.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      11. lower-/.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      12. lower-sqrt.f644.1

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\color{blue}{\sqrt{0.5}}}{ky}} \cdot \sin th \]
    6. Simplified4.1%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky}}} \cdot \sin th \]
    7. Taylor expanded in kx around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{kx \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}{ky}}} \cdot \sin th \]
    8. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{kx \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}{ky}}} \cdot \sin th \]
      2. associate-*r*N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\left(kx \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{2}}}{ky}} \cdot \sin th \]
      3. lower-*.f64N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\left(kx \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{2}}}{ky}} \cdot \sin th \]
      4. lower-*.f64N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\left(kx \cdot \sqrt{\frac{1}{2}}\right)} \cdot \sqrt{2}}{ky}} \cdot \sin th \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\left(kx \cdot \color{blue}{\sqrt{\frac{1}{2}}}\right) \cdot \sqrt{2}}{ky}} \cdot \sin th \]
      6. lower-sqrt.f6419.5

        \[\leadsto \frac{1}{\frac{\left(kx \cdot \sqrt{0.5}\right) \cdot \color{blue}{\sqrt{2}}}{ky}} \cdot \sin th \]
    9. Simplified19.5%

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(kx \cdot \sqrt{0.5}\right) \cdot \sqrt{2}}{ky}}} \cdot \sin th \]

    if 0.0100000000000000002 < (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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6499.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr99.4%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in th around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\left(th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
      6. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
      7. lower-*.f6453.8

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
    7. Simplified53.8%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]
    8. Taylor expanded in ky around 0

      \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}\right)} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}\right)} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      2. lower-sqrt.f64N/A

        \[\leadsto \left(ky \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}}\right) \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      3. lower-/.f64N/A

        \[\leadsto \left(ky \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}}\right) \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      4. +-commutativeN/A

        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}}\right) \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      5. metadata-evalN/A

        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}}\right) \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      6. distribute-lft-neg-inN/A

        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}}\right) \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}}\right) \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      8. cos-negN/A

        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}}\right) \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      9. lower-cos.f64N/A

        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}}\right) \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      10. *-commutativeN/A

        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}}\right) \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      11. lower-*.f6430.5

        \[\leadsto \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}}\right) \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]
    10. Simplified30.5%

      \[\leadsto \color{blue}{\left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification25.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\sin kx}^{2} \leq 0.01:\\ \;\;\;\;\sin th \cdot \frac{1}{\frac{\sqrt{2} \cdot \left(kx \cdot \sqrt{0.5}\right)}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \left(ky \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 36.3% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := ky \cdot \sin th\\ t_2 := 1 - \cos \left(kx \cdot -2\right)\\ \mathbf{if}\;ky \leq 3.5 \cdot 10^{-183}:\\ \;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, {ky}^{6}, -0.16666666666666666\right), ky\right)}{kx}\\ \mathbf{elif}\;ky \leq 3.5 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{\sqrt{t\_2} \cdot \frac{\sqrt{0.5}}{t\_1}}\\ \mathbf{elif}\;ky \leq 2.9 \cdot 10^{-92}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;ky \leq 8.5 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{\frac{1}{t\_2}} \cdot \left(t\_1 \cdot \sqrt{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (* ky (sin th))) (t_2 (- 1.0 (cos (* kx -2.0)))))
   (if (<= ky 3.5e-183)
     (*
      (sin th)
      (/
       (fma
        ky
        (*
         (pow ky 6.0)
         (fma 0.008333333333333333 (pow ky 6.0) -0.16666666666666666))
        ky)
       kx))
     (if (<= ky 3.5e-161)
       (/ 1.0 (* (sqrt t_2) (/ (sqrt 0.5) t_1)))
       (if (<= ky 2.9e-92)
         (* (sin th) (/ (sin ky) (sqrt (fma (* 2.0 (* ky ky)) 0.5 (* kx kx)))))
         (if (<= ky 8.5e-5)
           (* (sqrt (/ 1.0 t_2)) (* t_1 (sqrt 2.0)))
           (*
            (sin th)
            (/ (sin ky) (sqrt (* 0.5 (- 1.0 (cos (* ky -2.0)))))))))))))
double code(double kx, double ky, double th) {
	double t_1 = ky * sin(th);
	double t_2 = 1.0 - cos((kx * -2.0));
	double tmp;
	if (ky <= 3.5e-183) {
		tmp = sin(th) * (fma(ky, (pow(ky, 6.0) * fma(0.008333333333333333, pow(ky, 6.0), -0.16666666666666666)), ky) / kx);
	} else if (ky <= 3.5e-161) {
		tmp = 1.0 / (sqrt(t_2) * (sqrt(0.5) / t_1));
	} else if (ky <= 2.9e-92) {
		tmp = sin(th) * (sin(ky) / sqrt(fma((2.0 * (ky * ky)), 0.5, (kx * kx))));
	} else if (ky <= 8.5e-5) {
		tmp = sqrt((1.0 / t_2)) * (t_1 * sqrt(2.0));
	} else {
		tmp = sin(th) * (sin(ky) / sqrt((0.5 * (1.0 - cos((ky * -2.0))))));
	}
	return tmp;
}
function code(kx, ky, th)
	t_1 = Float64(ky * sin(th))
	t_2 = Float64(1.0 - cos(Float64(kx * -2.0)))
	tmp = 0.0
	if (ky <= 3.5e-183)
		tmp = Float64(sin(th) * Float64(fma(ky, Float64((ky ^ 6.0) * fma(0.008333333333333333, (ky ^ 6.0), -0.16666666666666666)), ky) / kx));
	elseif (ky <= 3.5e-161)
		tmp = Float64(1.0 / Float64(sqrt(t_2) * Float64(sqrt(0.5) / t_1)));
	elseif (ky <= 2.9e-92)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(2.0 * Float64(ky * ky)), 0.5, Float64(kx * kx)))));
	elseif (ky <= 8.5e-5)
		tmp = Float64(sqrt(Float64(1.0 / t_2)) * Float64(t_1 * sqrt(2.0)));
	else
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(ky * -2.0)))))));
	end
	return tmp
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ky, 3.5e-183], N[(N[Sin[th], $MachinePrecision] * N[(N[(ky * N[(N[Power[ky, 6.0], $MachinePrecision] * N[(0.008333333333333333 * N[Power[ky, 6.0], $MachinePrecision] + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + ky), $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 3.5e-161], N[(1.0 / N[(N[Sqrt[t$95$2], $MachinePrecision] * N[(N[Sqrt[0.5], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 2.9e-92], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(2.0 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 8.5e-5], N[(N[Sqrt[N[(1.0 / t$95$2), $MachinePrecision]], $MachinePrecision] * N[(t$95$1 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 * N[(1.0 - N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := ky \cdot \sin th\\
t_2 := 1 - \cos \left(kx \cdot -2\right)\\
\mathbf{if}\;ky \leq 3.5 \cdot 10^{-183}:\\
\;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, {ky}^{6}, -0.16666666666666666\right), ky\right)}{kx}\\

\mathbf{elif}\;ky \leq 3.5 \cdot 10^{-161}:\\
\;\;\;\;\frac{1}{\sqrt{t\_2} \cdot \frac{\sqrt{0.5}}{t\_1}}\\

\mathbf{elif}\;ky \leq 2.9 \cdot 10^{-92}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{elif}\;ky \leq 8.5 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{\frac{1}{t\_2}} \cdot \left(t\_1 \cdot \sqrt{2}\right)\\

\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if ky < 3.49999999999999991e-183

    1. Initial program 91.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 \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)\right)} \cdot \sin th \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)\right)} \cdot \sin th \]
      2. +-commutativeN/A

        \[\leadsto \left(ky \cdot \color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)}\right) \cdot \sin th \]
      3. distribute-lft-inN/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right) + {ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)} + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) \cdot \sin th \]
      4. associate-+l+N/A

        \[\leadsto \left(ky \cdot \color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right) + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)}\right) \cdot \sin th \]
      5. associate-*r*N/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \frac{-1}{6}\right) \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}} + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right) \cdot \sin th \]
      6. *-commutativeN/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2}\right)} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right) \cdot \sin th \]
    5. Simplified8.4%

      \[\leadsto \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right)} \cdot \sin th \]
    6. Taylor expanded in kx around 0

      \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
    7. Step-by-step derivation
      1. lower-sqrt.f64N/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      2. lower-/.f64N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\color{blue}{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      3. cube-multN/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{\color{blue}{kx \cdot \left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      4. unpow2N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{{kx}^{2}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      5. lower-*.f64N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{\color{blue}{kx \cdot {kx}^{2}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      6. unpow2N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{\left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      7. lower-*.f6413.3

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{\left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
    8. Simplified13.3%

      \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{kx \cdot \left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
    9. Taylor expanded in kx around inf

      \[\leadsto \color{blue}{\frac{ky \cdot \left(1 + {ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right)\right)}{kx}} \cdot \sin th \]
    10. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{ky \cdot \left(1 + {ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right)\right)}{kx}} \cdot \sin th \]
      2. +-commutativeN/A

        \[\leadsto \frac{ky \cdot \color{blue}{\left({ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right) + 1\right)}}{kx} \cdot \sin th \]
      3. distribute-lft-inN/A

        \[\leadsto \frac{\color{blue}{ky \cdot \left({ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right)\right) + ky \cdot 1}}{kx} \cdot \sin th \]
      4. *-rgt-identityN/A

        \[\leadsto \frac{ky \cdot \left({ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right)\right) + \color{blue}{ky}}{kx} \cdot \sin th \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky, {ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right), ky\right)}}{kx} \cdot \sin th \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{{ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right)}, ky\right)}{kx} \cdot \sin th \]
      7. lower-pow.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{{ky}^{6}} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right), ky\right)}{kx} \cdot \sin th \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \color{blue}{\left(\frac{1}{120} \cdot {ky}^{6} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)\right)}, ky\right)}{kx} \cdot \sin th \]
      9. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} + \color{blue}{\frac{-1}{6}}\right), ky\right)}{kx} \cdot \sin th \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{120}, {ky}^{6}, \frac{-1}{6}\right)}, ky\right)}{kx} \cdot \sin th \]
      11. lower-pow.f6425.3

        \[\leadsto \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, \color{blue}{{ky}^{6}}, -0.16666666666666666\right), ky\right)}{kx} \cdot \sin th \]
    11. Simplified25.3%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, {ky}^{6}, -0.16666666666666666\right), ky\right)}{kx}} \cdot \sin th \]

    if 3.49999999999999991e-183 < ky < 3.5000000000000002e-161

    1. Initial program 75.3%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Applied egg-rr62.9%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
    4. Taylor expanded in ky around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin th \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      2. lower-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      4. metadata-evalN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      6. lower--.f64N/A

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      7. cos-negN/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      9. *-commutativeN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      10. lower-*.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      11. lower-/.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      12. lower-sqrt.f6463.0

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\color{blue}{\sqrt{0.5}}}{ky}} \cdot \sin th \]
    6. Simplified63.0%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky}}} \cdot \sin th \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      2. lift-cos.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      3. lift--.f64N/A

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 - \cos \left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      4. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\color{blue}{\sqrt{\frac{1}{2}}}}{ky}} \cdot \sin th \]
      6. lift-/.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      7. lift-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \color{blue}{\sin th} \]
      9. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{1 \cdot \sin th}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \]
      10. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}{1 \cdot \sin th}}} \]
      11. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}{1 \cdot \sin th}}} \]
      12. *-lft-identityN/A

        \[\leadsto \frac{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}{\color{blue}{\sin th}}} \]
      13. lower-/.f6463.0

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky}}{\sin th}}} \]
    8. Applied egg-rr62.9%

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\sqrt{\left(1 - \cos \left(kx \cdot -2\right)\right) \cdot 0.5}}{ky}}{\sin th}}} \]
    9. Taylor expanded in kx around inf

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}}} \]
    10. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th}} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{\frac{1}{2}}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{\color{blue}{ky \cdot \sin th}} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}} \]
      5. lower-sin.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \color{blue}{\sin th}} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}} \]
      6. cos-negN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot kx\right)}}} \]
      8. metadata-evalN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(\color{blue}{2} \cdot kx\right)}} \]
      9. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}}} \]
      10. metadata-evalN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)}} \]
      11. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \]
      12. lower--.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \]
      13. cos-negN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \]
      14. lower-cos.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \]
      16. lower-*.f6463.1

        \[\leadsto \frac{1}{\frac{\sqrt{0.5}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \]
    11. Simplified63.1%

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{0.5}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(kx \cdot -2\right)}}} \]

    if 3.5000000000000002e-161 < ky < 2.89999999999999985e-92

    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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6464.6

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr55.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
      2. lower-*.f6438.9

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    7. Simplified38.9%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    8. Taylor expanded in ky around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      3. lower-*.f6473.9

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]
    10. Simplified73.9%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot \left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]

    if 2.89999999999999985e-92 < ky < 8.500000000000001e-5

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Applied egg-rr73.0%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
    4. 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)}}} \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right)} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      4. lower-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{1}{1 - \cos \left(2 \cdot kx\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      5. metadata-evalN/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      6. distribute-lft-neg-inN/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      7. lower--.f64N/A

        \[\leadsto \sqrt{\frac{1}{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      8. cos-negN/A

        \[\leadsto \sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      9. lower-cos.f64N/A

        \[\leadsto \sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      12. associate-*r*N/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \color{blue}{\left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \color{blue}{\left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right)} \]
      14. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(\color{blue}{\left(ky \cdot \sin th\right)} \cdot \sqrt{2}\right) \]
      15. lower-sin.f64N/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(\left(ky \cdot \color{blue}{\sin th}\right) \cdot \sqrt{2}\right) \]
      16. lower-sqrt.f6472.1

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(\left(ky \cdot \sin th\right) \cdot \color{blue}{\sqrt{2}}\right) \]
    6. Simplified72.1%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right)} \]

    if 8.500000000000001e-5 < ky

    1. Initial program 99.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6499.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr99.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin th \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin th \]
      2. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot ky\right)\right)}} \cdot \sin th \]
      3. distribute-lft-neg-inN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot ky\right)\right)}\right)}} \cdot \sin th \]
      4. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right)\right)}}} \cdot \sin th \]
      5. cos-negN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \left(1 - \color{blue}{\cos \left(-2 \cdot ky\right)}\right)}} \cdot \sin th \]
      6. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \left(1 - \color{blue}{\cos \left(-2 \cdot ky\right)}\right)}} \cdot \sin th \]
      7. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \color{blue}{\left(ky \cdot -2\right)}\right)}} \cdot \sin th \]
      8. lower-*.f6455.4

        \[\leadsto \frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \color{blue}{\left(ky \cdot -2\right)}\right)}} \cdot \sin th \]
    7. Simplified55.4%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}} \cdot \sin th \]
  3. Recombined 5 regimes into one program.
  4. Final simplification37.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 3.5 \cdot 10^{-183}:\\ \;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, {ky}^{6}, -0.16666666666666666\right), ky\right)}{kx}\\ \mathbf{elif}\;ky \leq 3.5 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky \cdot \sin th}}\\ \mathbf{elif}\;ky \leq 2.9 \cdot 10^{-92}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;ky \leq 8.5 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky \cdot -2\right)\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 36.3% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := ky \cdot \sin th\\ t_2 := 1 - \cos \left(kx \cdot -2\right)\\ \mathbf{if}\;ky \leq 3.5 \cdot 10^{-183}:\\ \;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, {ky}^{6}, -0.16666666666666666\right), ky\right)}{kx}\\ \mathbf{elif}\;ky \leq 3.5 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{\sqrt{t\_2} \cdot \frac{\sqrt{0.5}}{t\_1}}\\ \mathbf{elif}\;ky \leq 2.9 \cdot 10^{-92}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;ky \leq 8.5 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{\frac{1}{t\_2}} \cdot \left(t\_1 \cdot \sqrt{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\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
 (let* ((t_1 (* ky (sin th))) (t_2 (- 1.0 (cos (* kx -2.0)))))
   (if (<= ky 3.5e-183)
     (*
      (sin th)
      (/
       (fma
        ky
        (*
         (pow ky 6.0)
         (fma 0.008333333333333333 (pow ky 6.0) -0.16666666666666666))
        ky)
       kx))
     (if (<= ky 3.5e-161)
       (/ 1.0 (* (sqrt t_2) (/ (sqrt 0.5) t_1)))
       (if (<= ky 2.9e-92)
         (* (sin th) (/ (sin ky) (sqrt (fma (* 2.0 (* ky ky)) 0.5 (* kx kx)))))
         (if (<= ky 8.5e-5)
           (* (sqrt (/ 1.0 t_2)) (* t_1 (sqrt 2.0)))
           (*
            (sin ky)
            (/ (sin th) (sqrt (fma -0.5 (cos (* ky -2.0)) 0.5))))))))))
double code(double kx, double ky, double th) {
	double t_1 = ky * sin(th);
	double t_2 = 1.0 - cos((kx * -2.0));
	double tmp;
	if (ky <= 3.5e-183) {
		tmp = sin(th) * (fma(ky, (pow(ky, 6.0) * fma(0.008333333333333333, pow(ky, 6.0), -0.16666666666666666)), ky) / kx);
	} else if (ky <= 3.5e-161) {
		tmp = 1.0 / (sqrt(t_2) * (sqrt(0.5) / t_1));
	} else if (ky <= 2.9e-92) {
		tmp = sin(th) * (sin(ky) / sqrt(fma((2.0 * (ky * ky)), 0.5, (kx * kx))));
	} else if (ky <= 8.5e-5) {
		tmp = sqrt((1.0 / t_2)) * (t_1 * sqrt(2.0));
	} else {
		tmp = sin(ky) * (sin(th) / sqrt(fma(-0.5, cos((ky * -2.0)), 0.5)));
	}
	return tmp;
}
function code(kx, ky, th)
	t_1 = Float64(ky * sin(th))
	t_2 = Float64(1.0 - cos(Float64(kx * -2.0)))
	tmp = 0.0
	if (ky <= 3.5e-183)
		tmp = Float64(sin(th) * Float64(fma(ky, Float64((ky ^ 6.0) * fma(0.008333333333333333, (ky ^ 6.0), -0.16666666666666666)), ky) / kx));
	elseif (ky <= 3.5e-161)
		tmp = Float64(1.0 / Float64(sqrt(t_2) * Float64(sqrt(0.5) / t_1)));
	elseif (ky <= 2.9e-92)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(2.0 * Float64(ky * ky)), 0.5, Float64(kx * kx)))));
	elseif (ky <= 8.5e-5)
		tmp = Float64(sqrt(Float64(1.0 / t_2)) * Float64(t_1 * sqrt(2.0)));
	else
		tmp = Float64(sin(ky) * Float64(sin(th) / sqrt(fma(-0.5, cos(Float64(ky * -2.0)), 0.5))));
	end
	return tmp
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ky, 3.5e-183], N[(N[Sin[th], $MachinePrecision] * N[(N[(ky * N[(N[Power[ky, 6.0], $MachinePrecision] * N[(0.008333333333333333 * N[Power[ky, 6.0], $MachinePrecision] + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + ky), $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 3.5e-161], N[(1.0 / N[(N[Sqrt[t$95$2], $MachinePrecision] * N[(N[Sqrt[0.5], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 2.9e-92], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(2.0 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 8.5e-5], N[(N[Sqrt[N[(1.0 / t$95$2), $MachinePrecision]], $MachinePrecision] * N[(t$95$1 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $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}
t_1 := ky \cdot \sin th\\
t_2 := 1 - \cos \left(kx \cdot -2\right)\\
\mathbf{if}\;ky \leq 3.5 \cdot 10^{-183}:\\
\;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, {ky}^{6}, -0.16666666666666666\right), ky\right)}{kx}\\

\mathbf{elif}\;ky \leq 3.5 \cdot 10^{-161}:\\
\;\;\;\;\frac{1}{\sqrt{t\_2} \cdot \frac{\sqrt{0.5}}{t\_1}}\\

\mathbf{elif}\;ky \leq 2.9 \cdot 10^{-92}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{elif}\;ky \leq 8.5 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{\frac{1}{t\_2}} \cdot \left(t\_1 \cdot \sqrt{2}\right)\\

\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if ky < 3.49999999999999991e-183

    1. Initial program 91.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 \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)\right)} \cdot \sin th \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)\right)} \cdot \sin th \]
      2. +-commutativeN/A

        \[\leadsto \left(ky \cdot \color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)}\right) \cdot \sin th \]
      3. distribute-lft-inN/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right) + {ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)} + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) \cdot \sin th \]
      4. associate-+l+N/A

        \[\leadsto \left(ky \cdot \color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right) + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)}\right) \cdot \sin th \]
      5. associate-*r*N/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \frac{-1}{6}\right) \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}} + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right) \cdot \sin th \]
      6. *-commutativeN/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2}\right)} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right) \cdot \sin th \]
    5. Simplified8.4%

      \[\leadsto \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right)} \cdot \sin th \]
    6. Taylor expanded in kx around 0

      \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
    7. Step-by-step derivation
      1. lower-sqrt.f64N/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      2. lower-/.f64N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\color{blue}{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      3. cube-multN/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{\color{blue}{kx \cdot \left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      4. unpow2N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{{kx}^{2}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      5. lower-*.f64N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{\color{blue}{kx \cdot {kx}^{2}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      6. unpow2N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{\left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      7. lower-*.f6413.3

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{\left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
    8. Simplified13.3%

      \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{kx \cdot \left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
    9. Taylor expanded in kx around inf

      \[\leadsto \color{blue}{\frac{ky \cdot \left(1 + {ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right)\right)}{kx}} \cdot \sin th \]
    10. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{ky \cdot \left(1 + {ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right)\right)}{kx}} \cdot \sin th \]
      2. +-commutativeN/A

        \[\leadsto \frac{ky \cdot \color{blue}{\left({ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right) + 1\right)}}{kx} \cdot \sin th \]
      3. distribute-lft-inN/A

        \[\leadsto \frac{\color{blue}{ky \cdot \left({ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right)\right) + ky \cdot 1}}{kx} \cdot \sin th \]
      4. *-rgt-identityN/A

        \[\leadsto \frac{ky \cdot \left({ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right)\right) + \color{blue}{ky}}{kx} \cdot \sin th \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(ky, {ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right), ky\right)}}{kx} \cdot \sin th \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{{ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right)}, ky\right)}{kx} \cdot \sin th \]
      7. lower-pow.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(ky, \color{blue}{{ky}^{6}} \cdot \left(\frac{1}{120} \cdot {ky}^{6} - \frac{1}{6}\right), ky\right)}{kx} \cdot \sin th \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \color{blue}{\left(\frac{1}{120} \cdot {ky}^{6} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)\right)}, ky\right)}{kx} \cdot \sin th \]
      9. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \left(\frac{1}{120} \cdot {ky}^{6} + \color{blue}{\frac{-1}{6}}\right), ky\right)}{kx} \cdot \sin th \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{120}, {ky}^{6}, \frac{-1}{6}\right)}, ky\right)}{kx} \cdot \sin th \]
      11. lower-pow.f6425.3

        \[\leadsto \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, \color{blue}{{ky}^{6}}, -0.16666666666666666\right), ky\right)}{kx} \cdot \sin th \]
    11. Simplified25.3%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, {ky}^{6}, -0.16666666666666666\right), ky\right)}{kx}} \cdot \sin th \]

    if 3.49999999999999991e-183 < ky < 3.5000000000000002e-161

    1. Initial program 75.3%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Applied egg-rr62.9%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
    4. Taylor expanded in ky around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin th \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      2. lower-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      4. metadata-evalN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      6. lower--.f64N/A

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      7. cos-negN/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      9. *-commutativeN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      10. lower-*.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      11. lower-/.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      12. lower-sqrt.f6463.0

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\color{blue}{\sqrt{0.5}}}{ky}} \cdot \sin th \]
    6. Simplified63.0%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky}}} \cdot \sin th \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      2. lift-cos.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      3. lift--.f64N/A

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 - \cos \left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      4. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\color{blue}{\sqrt{\frac{1}{2}}}}{ky}} \cdot \sin th \]
      6. lift-/.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      7. lift-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \color{blue}{\sin th} \]
      9. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{1 \cdot \sin th}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \]
      10. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}{1 \cdot \sin th}}} \]
      11. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}{1 \cdot \sin th}}} \]
      12. *-lft-identityN/A

        \[\leadsto \frac{1}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}{\color{blue}{\sin th}}} \]
      13. lower-/.f6463.0

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky}}{\sin th}}} \]
    8. Applied egg-rr62.9%

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\sqrt{\left(1 - \cos \left(kx \cdot -2\right)\right) \cdot 0.5}}{ky}}{\sin th}}} \]
    9. Taylor expanded in kx around inf

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}}} \]
    10. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th}} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{\frac{1}{2}}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{\color{blue}{ky \cdot \sin th}} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}} \]
      5. lower-sin.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \color{blue}{\sin th}} \cdot \sqrt{1 - \cos \left(-2 \cdot kx\right)}} \]
      6. cos-negN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot kx\right)}}} \]
      8. metadata-evalN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(\color{blue}{2} \cdot kx\right)}} \]
      9. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}}} \]
      10. metadata-evalN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)}} \]
      11. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \]
      12. lower--.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \]
      13. cos-negN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \]
      14. lower-cos.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\sqrt{\frac{1}{2}}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \]
      16. lower-*.f6463.1

        \[\leadsto \frac{1}{\frac{\sqrt{0.5}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \]
    11. Simplified63.1%

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{0.5}}{ky \cdot \sin th} \cdot \sqrt{1 - \cos \left(kx \cdot -2\right)}}} \]

    if 3.5000000000000002e-161 < ky < 2.89999999999999985e-92

    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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6464.6

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr55.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
      2. lower-*.f6438.9

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    7. Simplified38.9%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    8. Taylor expanded in ky around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      3. lower-*.f6473.9

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]
    10. Simplified73.9%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot \left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]

    if 2.89999999999999985e-92 < ky < 8.500000000000001e-5

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Applied egg-rr73.0%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
    4. 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)}}} \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right)} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      4. lower-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{1}{1 - \cos \left(2 \cdot kx\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      5. metadata-evalN/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      6. distribute-lft-neg-inN/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      7. lower--.f64N/A

        \[\leadsto \sqrt{\frac{1}{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      8. cos-negN/A

        \[\leadsto \sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      9. lower-cos.f64N/A

        \[\leadsto \sqrt{\frac{1}{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \color{blue}{\left(kx \cdot -2\right)}}} \cdot \left(ky \cdot \left(\sin th \cdot \sqrt{2}\right)\right) \]
      12. associate-*r*N/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \color{blue}{\left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \color{blue}{\left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right)} \]
      14. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(\color{blue}{\left(ky \cdot \sin th\right)} \cdot \sqrt{2}\right) \]
      15. lower-sin.f64N/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(\left(ky \cdot \color{blue}{\sin th}\right) \cdot \sqrt{2}\right) \]
      16. lower-sqrt.f6472.1

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(\left(ky \cdot \sin th\right) \cdot \color{blue}{\sqrt{2}}\right) \]
    6. Simplified72.1%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right)} \]

    if 8.500000000000001e-5 < ky

    1. Initial program 99.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Applied egg-rr99.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} \]
    4. 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 \]
    5. 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-*.f6455.3

        \[\leadsto \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(ky \cdot -2\right)}, 0.5\right)}} \cdot \sin ky \]
    6. Simplified55.3%

      \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}} \cdot \sin ky \]
  3. Recombined 5 regimes into one program.
  4. Final simplification37.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 3.5 \cdot 10^{-183}:\\ \;\;\;\;\sin th \cdot \frac{\mathsf{fma}\left(ky, {ky}^{6} \cdot \mathsf{fma}\left(0.008333333333333333, {ky}^{6}, -0.16666666666666666\right), ky\right)}{kx}\\ \mathbf{elif}\;ky \leq 3.5 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky \cdot \sin th}}\\ \mathbf{elif}\;ky \leq 2.9 \cdot 10^{-92}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;ky \leq 8.5 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(\left(ky \cdot \sin th\right) \cdot \sqrt{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 21: 38.1% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;kx \leq 0.86:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, -0.0031746031746031746, 0.044444444444444446\right), -0.3333333333333333\right), 1\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= kx 5e-201)
   (* (sin th) (/ (sin ky) (sqrt (fma (* 2.0 (* ky ky)) 0.5 (* kx kx)))))
   (if (<= kx 0.86)
     (*
      (fma th (* -0.16666666666666666 (* th th)) th)
      (/
       (sin ky)
       (sqrt
        (fma
         (- 1.0 (cos (+ ky ky)))
         0.5
         (*
          (* kx kx)
          (fma
           (* kx kx)
           (fma
            (* kx kx)
            (fma (* kx kx) -0.0031746031746031746 0.044444444444444446)
            -0.3333333333333333)
           1.0))))))
     (* (sin th) (/ (sin ky) (sqrt (fma -0.5 (cos (* kx -2.0)) 0.5)))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (kx <= 5e-201) {
		tmp = sin(th) * (sin(ky) / sqrt(fma((2.0 * (ky * ky)), 0.5, (kx * kx))));
	} else if (kx <= 0.86) {
		tmp = fma(th, (-0.16666666666666666 * (th * th)), th) * (sin(ky) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((kx * kx) * fma((kx * kx), fma((kx * kx), fma((kx * kx), -0.0031746031746031746, 0.044444444444444446), -0.3333333333333333), 1.0)))));
	} else {
		tmp = sin(th) * (sin(ky) / sqrt(fma(-0.5, cos((kx * -2.0)), 0.5)));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if (kx <= 5e-201)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(2.0 * Float64(ky * ky)), 0.5, Float64(kx * kx)))));
	elseif (kx <= 0.86)
		tmp = Float64(fma(th, Float64(-0.16666666666666666 * Float64(th * th)), th) * Float64(sin(ky) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(kx * kx) * fma(Float64(kx * kx), fma(Float64(kx * kx), fma(Float64(kx * kx), -0.0031746031746031746, 0.044444444444444446), -0.3333333333333333), 1.0))))));
	else
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[kx, 5e-201], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(2.0 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 0.86], N[(N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * -0.0031746031746031746 + 0.044444444444444446), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{elif}\;kx \leq 0.86:\\
\;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, -0.0031746031746031746, 0.044444444444444446\right), -0.3333333333333333\right), 1\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if kx < 4.9999999999999999e-201

    1. Initial program 91.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6483.4

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr75.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
      2. lower-*.f6450.2

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    7. Simplified50.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    8. Taylor expanded in ky around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      3. lower-*.f6427.7

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]
    10. Simplified27.7%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot \left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]

    if 4.9999999999999999e-201 < kx < 0.859999999999999987

    1. Initial program 90.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6485.8

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr54.0%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in th around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\left(th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
      6. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
      7. lower-*.f6432.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
    7. Simplified32.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]
    8. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left({kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}\right)\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left({kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}\right)\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + {kx}^{2} \cdot \left({kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}\right)\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      3. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + {kx}^{2} \cdot \left({kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}\right)\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      4. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\left({kx}^{2} \cdot \left({kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}\right) + 1\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, {kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}, 1\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      6. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, {kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      7. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, {kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      8. sub-negN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{{kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      9. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, {kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) + \color{blue}{\frac{-1}{3}}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}, \frac{-1}{3}\right)}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      11. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      13. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \color{blue}{\frac{-1}{315} \cdot {kx}^{2} + \frac{2}{45}}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      14. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \color{blue}{{kx}^{2} \cdot \frac{-1}{315}} + \frac{2}{45}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      15. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{-1}{315}, \frac{2}{45}\right)}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{-1}{315}, \frac{2}{45}\right), \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      17. lower-*.f6451.3

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(\color{blue}{kx \cdot kx}, -0.0031746031746031746, 0.044444444444444446\right), -0.3333333333333333\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]
    10. Simplified51.3%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{\left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, -0.0031746031746031746, 0.044444444444444446\right), -0.3333333333333333\right), 1\right)}\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]

    if 0.859999999999999987 < kx

    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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6499.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr99.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in ky around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \cdot \sin th \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \cdot \sin th \]
      2. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \cdot \sin th \]
      3. distribute-lft-neg-inN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \cdot \sin th \]
      4. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \cdot \sin th \]
      5. cos-negN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin th \]
      6. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \cdot \sin th \]
      7. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \cdot \sin th \]
      8. lower-*.f6466.6

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \cdot \sin th \]
    7. Simplified66.6%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \cdot \sin th \]
  3. Recombined 3 regimes into one program.
  4. Final simplification42.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;kx \leq 0.86:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, -0.0031746031746031746, 0.044444444444444446\right), -0.3333333333333333\right), 1\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 22: 55.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 0.86:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{0.5 \cdot \left(1 - \cos \left(kx \cdot -2\right)\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= kx 0.86)
   (* (sin th) (/ (sin ky) (sqrt (fma (- 1.0 (cos (+ ky ky))) 0.5 (* kx kx)))))
   (* (sin ky) (/ (sin th) (sqrt (* 0.5 (- 1.0 (cos (* kx -2.0)))))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (kx <= 0.86) {
		tmp = sin(th) * (sin(ky) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, (kx * kx))));
	} else {
		tmp = sin(ky) * (sin(th) / sqrt((0.5 * (1.0 - cos((kx * -2.0))))));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if (kx <= 0.86)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(kx * kx)))));
	else
		tmp = Float64(sin(ky) * Float64(sin(th) / sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(kx * -2.0)))))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[kx, 0.86], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(0.5 * N[(1.0 - N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.86:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{0.5 \cdot \left(1 - \cos \left(kx \cdot -2\right)\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if kx < 0.859999999999999987

    1. Initial program 91.4%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6483.9

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr70.7%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
      2. lower-*.f6458.2

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    7. Simplified58.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]

    if 0.859999999999999987 < kx

    1. Initial program 99.5%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Applied egg-rr99.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} \]
    4. Taylor expanded in ky around 0

      \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)}}} \cdot \sin ky \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot kx\right)\right)}}} \cdot \sin ky \]
      2. metadata-evalN/A

        \[\leadsto \frac{\sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)\right)}} \cdot \sin ky \]
      3. distribute-lft-neg-inN/A

        \[\leadsto \frac{\sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}\right)}} \cdot \sin ky \]
      4. lower--.f64N/A

        \[\leadsto \frac{\sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)\right)}}} \cdot \sin ky \]
      5. cos-negN/A

        \[\leadsto \frac{\sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \color{blue}{\cos \left(-2 \cdot kx\right)}\right)}} \cdot \sin ky \]
      6. lower-cos.f64N/A

        \[\leadsto \frac{\sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \color{blue}{\cos \left(-2 \cdot kx\right)}\right)}} \cdot \sin ky \]
      7. *-commutativeN/A

        \[\leadsto \frac{\sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \color{blue}{\left(kx \cdot -2\right)}\right)}} \cdot \sin ky \]
      8. lower-*.f6466.6

        \[\leadsto \frac{\sin th}{\sqrt{0.5 \cdot \left(1 - \cos \color{blue}{\left(kx \cdot -2\right)}\right)}} \cdot \sin ky \]
    6. Simplified66.6%

      \[\leadsto \frac{\sin th}{\sqrt{\color{blue}{0.5 \cdot \left(1 - \cos \left(kx \cdot -2\right)\right)}}} \cdot \sin ky \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 0.86:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sqrt{0.5 \cdot \left(1 - \cos \left(kx \cdot -2\right)\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 23: 35.9% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;kx \leq 0.86:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, -0.0031746031746031746, 0.044444444444444446\right), -0.3333333333333333\right), 1\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= kx 5e-201)
   (* (sin th) (/ (sin ky) (sqrt (fma (* 2.0 (* ky ky)) 0.5 (* kx kx)))))
   (if (<= kx 0.86)
     (*
      (fma th (* -0.16666666666666666 (* th th)) th)
      (/
       (sin ky)
       (sqrt
        (fma
         (- 1.0 (cos (+ ky ky)))
         0.5
         (*
          (* kx kx)
          (fma
           (* kx kx)
           (fma
            (* kx kx)
            (fma (* kx kx) -0.0031746031746031746 0.044444444444444446)
            -0.3333333333333333)
           1.0))))))
     (* (* ky (sin th)) (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5)))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (kx <= 5e-201) {
		tmp = sin(th) * (sin(ky) / sqrt(fma((2.0 * (ky * ky)), 0.5, (kx * kx))));
	} else if (kx <= 0.86) {
		tmp = fma(th, (-0.16666666666666666 * (th * th)), th) * (sin(ky) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((kx * kx) * fma((kx * kx), fma((kx * kx), fma((kx * kx), -0.0031746031746031746, 0.044444444444444446), -0.3333333333333333), 1.0)))));
	} else {
		tmp = (ky * sin(th)) * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5)));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if (kx <= 5e-201)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(2.0 * Float64(ky * ky)), 0.5, Float64(kx * kx)))));
	elseif (kx <= 0.86)
		tmp = Float64(fma(th, Float64(-0.16666666666666666 * Float64(th * th)), th) * Float64(sin(ky) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(kx * kx) * fma(Float64(kx * kx), fma(Float64(kx * kx), fma(Float64(kx * kx), -0.0031746031746031746, 0.044444444444444446), -0.3333333333333333), 1.0))))));
	else
		tmp = Float64(Float64(ky * sin(th)) * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[kx, 5e-201], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(2.0 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 0.86], N[(N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * -0.0031746031746031746 + 0.044444444444444446), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{elif}\;kx \leq 0.86:\\
\;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, -0.0031746031746031746, 0.044444444444444446\right), -0.3333333333333333\right), 1\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if kx < 4.9999999999999999e-201

    1. Initial program 91.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6483.4

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr75.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
      2. lower-*.f6450.2

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    7. Simplified50.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    8. Taylor expanded in ky around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      3. lower-*.f6427.7

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]
    10. Simplified27.7%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot \left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]

    if 4.9999999999999999e-201 < kx < 0.859999999999999987

    1. Initial program 90.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6485.8

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr54.0%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in th around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\left(th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
      6. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
      7. lower-*.f6432.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
    7. Simplified32.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]
    8. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left({kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}\right)\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left({kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}\right)\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + {kx}^{2} \cdot \left({kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}\right)\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      3. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + {kx}^{2} \cdot \left({kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}\right)\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      4. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\left({kx}^{2} \cdot \left({kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}\right) + 1\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, {kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}, 1\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      6. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, {kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      7. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, {kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) - \frac{1}{3}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      8. sub-negN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{{kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      9. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, {kx}^{2} \cdot \left(\frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}\right) + \color{blue}{\frac{-1}{3}}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}, \frac{-1}{3}\right)}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      11. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{2}{45} + \frac{-1}{315} \cdot {kx}^{2}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      13. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \color{blue}{\frac{-1}{315} \cdot {kx}^{2} + \frac{2}{45}}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      14. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \color{blue}{{kx}^{2} \cdot \frac{-1}{315}} + \frac{2}{45}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      15. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{-1}{315}, \frac{2}{45}\right)}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{-1}{315}, \frac{2}{45}\right), \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      17. lower-*.f6451.3

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(\color{blue}{kx \cdot kx}, -0.0031746031746031746, 0.044444444444444446\right), -0.3333333333333333\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]
    10. Simplified51.3%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{\left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, -0.0031746031746031746, 0.044444444444444446\right), -0.3333333333333333\right), 1\right)}\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]

    if 0.859999999999999987 < kx

    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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6499.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr99.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in ky around 0

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      3. lower-sin.f64N/A

        \[\leadsto \left(ky \cdot \color{blue}{\sin th}\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      5. lower-/.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      6. +-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \]
      7. metadata-evalN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \]
      9. lower-fma.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \]
      10. cos-negN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      11. lower-cos.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      12. *-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \]
      13. lower-*.f6459.6

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \]
    7. Simplified59.6%

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification40.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;kx \leq 0.86:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, -0.0031746031746031746, 0.044444444444444446\right), -0.3333333333333333\right), 1\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 24: 35.9% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;kx \leq 0.86:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, 0.044444444444444446, -0.3333333333333333\right), 1\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= kx 5e-201)
   (* (sin th) (/ (sin ky) (sqrt (fma (* 2.0 (* ky ky)) 0.5 (* kx kx)))))
   (if (<= kx 0.86)
     (*
      (fma th (* -0.16666666666666666 (* th th)) th)
      (/
       (sin ky)
       (sqrt
        (fma
         (- 1.0 (cos (+ ky ky)))
         0.5
         (*
          (* kx kx)
          (fma
           (* kx kx)
           (fma (* kx kx) 0.044444444444444446 -0.3333333333333333)
           1.0))))))
     (* (* ky (sin th)) (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5)))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (kx <= 5e-201) {
		tmp = sin(th) * (sin(ky) / sqrt(fma((2.0 * (ky * ky)), 0.5, (kx * kx))));
	} else if (kx <= 0.86) {
		tmp = fma(th, (-0.16666666666666666 * (th * th)), th) * (sin(ky) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((kx * kx) * fma((kx * kx), fma((kx * kx), 0.044444444444444446, -0.3333333333333333), 1.0)))));
	} else {
		tmp = (ky * sin(th)) * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5)));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if (kx <= 5e-201)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(2.0 * Float64(ky * ky)), 0.5, Float64(kx * kx)))));
	elseif (kx <= 0.86)
		tmp = Float64(fma(th, Float64(-0.16666666666666666 * Float64(th * th)), th) * Float64(sin(ky) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(kx * kx) * fma(Float64(kx * kx), fma(Float64(kx * kx), 0.044444444444444446, -0.3333333333333333), 1.0))))));
	else
		tmp = Float64(Float64(ky * sin(th)) * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[kx, 5e-201], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(2.0 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 0.86], N[(N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * 0.044444444444444446 + -0.3333333333333333), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{elif}\;kx \leq 0.86:\\
\;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, 0.044444444444444446, -0.3333333333333333\right), 1\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if kx < 4.9999999999999999e-201

    1. Initial program 91.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6483.4

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr75.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
      2. lower-*.f6450.2

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    7. Simplified50.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    8. Taylor expanded in ky around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      3. lower-*.f6427.7

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]
    10. Simplified27.7%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot \left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]

    if 4.9999999999999999e-201 < kx < 0.859999999999999987

    1. Initial program 90.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6485.8

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr54.0%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in th around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\left(th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
      6. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
      7. lower-*.f6432.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
    7. Simplified32.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]
    8. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      3. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + {kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right)\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      4. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\left({kx}^{2} \cdot \left(\frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}\right) + 1\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}, 1\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      6. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      7. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{2}{45} \cdot {kx}^{2} - \frac{1}{3}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      8. sub-negN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\frac{2}{45} \cdot {kx}^{2} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      9. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{{kx}^{2} \cdot \frac{2}{45}} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      10. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, {kx}^{2} \cdot \frac{2}{45} + \color{blue}{\frac{-1}{3}}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{2}{45}, \frac{-1}{3}\right)}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      12. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{2}{45}, \frac{-1}{3}\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      13. lower-*.f6451.3

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(\color{blue}{kx \cdot kx}, 0.044444444444444446, -0.3333333333333333\right), 1\right)\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]
    10. Simplified51.3%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{\left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, 0.044444444444444446, -0.3333333333333333\right), 1\right)}\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]

    if 0.859999999999999987 < kx

    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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6499.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr99.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in ky around 0

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      3. lower-sin.f64N/A

        \[\leadsto \left(ky \cdot \color{blue}{\sin th}\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      5. lower-/.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      6. +-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \]
      7. metadata-evalN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \]
      9. lower-fma.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \]
      10. cos-negN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      11. lower-cos.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      12. *-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \]
      13. lower-*.f6459.6

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \]
    7. Simplified59.6%

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification40.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;kx \leq 0.86:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, \mathsf{fma}\left(kx \cdot kx, 0.044444444444444446, -0.3333333333333333\right), 1\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 25: 35.9% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;kx \leq 0.86:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= kx 5e-201)
   (* (sin th) (/ (sin ky) (sqrt (fma (* 2.0 (* ky ky)) 0.5 (* kx kx)))))
   (if (<= kx 0.86)
     (*
      (fma th (* -0.16666666666666666 (* th th)) th)
      (/
       (sin ky)
       (sqrt
        (fma
         (- 1.0 (cos (+ ky ky)))
         0.5
         (* (* kx kx) (fma (* kx kx) -0.3333333333333333 1.0))))))
     (* (* ky (sin th)) (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5)))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (kx <= 5e-201) {
		tmp = sin(th) * (sin(ky) / sqrt(fma((2.0 * (ky * ky)), 0.5, (kx * kx))));
	} else if (kx <= 0.86) {
		tmp = fma(th, (-0.16666666666666666 * (th * th)), th) * (sin(ky) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((kx * kx) * fma((kx * kx), -0.3333333333333333, 1.0)))));
	} else {
		tmp = (ky * sin(th)) * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5)));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if (kx <= 5e-201)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(2.0 * Float64(ky * ky)), 0.5, Float64(kx * kx)))));
	elseif (kx <= 0.86)
		tmp = Float64(fma(th, Float64(-0.16666666666666666 * Float64(th * th)), th) * Float64(sin(ky) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(kx * kx) * fma(Float64(kx * kx), -0.3333333333333333, 1.0))))));
	else
		tmp = Float64(Float64(ky * sin(th)) * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[kx, 5e-201], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(2.0 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 0.86], N[(N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(kx * kx), $MachinePrecision] * N[(N[(kx * kx), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{elif}\;kx \leq 0.86:\\
\;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if kx < 4.9999999999999999e-201

    1. Initial program 91.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6483.4

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr75.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
      2. lower-*.f6450.2

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    7. Simplified50.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    8. Taylor expanded in ky around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      3. lower-*.f6427.7

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]
    10. Simplified27.7%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot \left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]

    if 4.9999999999999999e-201 < kx < 0.859999999999999987

    1. Initial program 90.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6485.8

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr54.0%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in th around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\left(th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
      6. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
      7. lower-*.f6432.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
    7. Simplified32.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]
    8. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      3. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{\left(kx \cdot kx\right)} \cdot \left(1 + \frac{-1}{3} \cdot {kx}^{2}\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      4. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\left(\frac{-1}{3} \cdot {kx}^{2} + 1\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      5. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \left(\color{blue}{{kx}^{2} \cdot \frac{-1}{3}} + 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \color{blue}{\mathsf{fma}\left({kx}^{2}, \frac{-1}{3}, 1\right)}\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, \frac{-1}{3}, 1\right)\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \left(th \cdot th\right), th\right) \]
      8. lower-*.f6451.3

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(\color{blue}{kx \cdot kx}, -0.3333333333333333, 1\right)\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]
    10. Simplified51.3%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{\left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)}\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \]

    if 0.859999999999999987 < kx

    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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6499.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr99.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in ky around 0

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      3. lower-sin.f64N/A

        \[\leadsto \left(ky \cdot \color{blue}{\sin th}\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      5. lower-/.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      6. +-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \]
      7. metadata-evalN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \]
      9. lower-fma.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \]
      10. cos-negN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      11. lower-cos.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      12. *-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \]
      13. lower-*.f6459.6

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \]
    7. Simplified59.6%

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification40.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;kx \leq 0.86:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(kx \cdot kx\right) \cdot \mathsf{fma}\left(kx \cdot kx, -0.3333333333333333, 1\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 26: 35.9% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;kx \leq 0.86:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= kx 5e-201)
   (* (sin th) (/ (sin ky) (sqrt (fma (* 2.0 (* ky ky)) 0.5 (* kx kx)))))
   (if (<= kx 0.86)
     (*
      (fma th (* -0.16666666666666666 (* th th)) th)
      (/ (sin ky) (sqrt (fma (- 1.0 (cos (+ ky ky))) 0.5 (* kx kx)))))
     (* (* ky (sin th)) (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5)))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (kx <= 5e-201) {
		tmp = sin(th) * (sin(ky) / sqrt(fma((2.0 * (ky * ky)), 0.5, (kx * kx))));
	} else if (kx <= 0.86) {
		tmp = fma(th, (-0.16666666666666666 * (th * th)), th) * (sin(ky) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, (kx * kx))));
	} else {
		tmp = (ky * sin(th)) * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5)));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if (kx <= 5e-201)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(2.0 * Float64(ky * ky)), 0.5, Float64(kx * kx)))));
	elseif (kx <= 0.86)
		tmp = Float64(fma(th, Float64(-0.16666666666666666 * Float64(th * th)), th) * Float64(sin(ky) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(kx * kx)))));
	else
		tmp = Float64(Float64(ky * sin(th)) * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[kx, 5e-201], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(2.0 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 0.86], N[(N[(th * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{elif}\;kx \leq 0.86:\\
\;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{else}:\\
\;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if kx < 4.9999999999999999e-201

    1. Initial program 91.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6483.4

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr75.5%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
      2. lower-*.f6450.2

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    7. Simplified50.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    8. Taylor expanded in ky around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      3. lower-*.f6427.7

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]
    10. Simplified27.7%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot \left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]

    if 4.9999999999999999e-201 < kx < 0.859999999999999987

    1. Initial program 90.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6485.8

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr54.0%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
      2. lower-*.f6485.6

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    7. Simplified85.6%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    8. Taylor expanded in th around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, kx \cdot kx\right)}} \cdot \color{blue}{\left(th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, kx \cdot kx\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, kx \cdot kx\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, kx \cdot kx\right)}} \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}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, kx \cdot kx\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, \frac{-1}{6} \cdot {th}^{2}, th\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, kx \cdot kx\right)}} \cdot \mathsf{fma}\left(th, \color{blue}{\frac{-1}{6} \cdot {th}^{2}}, th\right) \]
      6. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, kx \cdot kx\right)}} \cdot \mathsf{fma}\left(th, \frac{-1}{6} \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
      7. lower-*.f6451.3

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}} \cdot \mathsf{fma}\left(th, -0.16666666666666666 \cdot \color{blue}{\left(th \cdot th\right)}, th\right) \]
    10. Simplified51.3%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}} \cdot \color{blue}{\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right)} \]

    if 0.859999999999999987 < kx

    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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6499.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr99.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in ky around 0

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      3. lower-sin.f64N/A

        \[\leadsto \left(ky \cdot \color{blue}{\sin th}\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      5. lower-/.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      6. +-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \]
      7. metadata-evalN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \]
      9. lower-fma.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \]
      10. cos-negN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      11. lower-cos.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      12. *-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \]
      13. lower-*.f6459.6

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \]
    7. Simplified59.6%

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification40.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 5 \cdot 10^{-201}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{elif}\;kx \leq 0.86:\\ \;\;\;\;\mathsf{fma}\left(th, -0.16666666666666666 \cdot \left(th \cdot th\right), th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 27: 37.2% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 0.86:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= kx 0.86)
   (* (sin th) (/ (sin ky) (sqrt (fma (* 2.0 (* ky ky)) 0.5 (* kx kx)))))
   (* (* ky (sin th)) (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (kx <= 0.86) {
		tmp = sin(th) * (sin(ky) / sqrt(fma((2.0 * (ky * ky)), 0.5, (kx * kx))));
	} else {
		tmp = (ky * sin(th)) * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5)));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if (kx <= 0.86)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(fma(Float64(2.0 * Float64(ky * ky)), 0.5, Float64(kx * kx)))));
	else
		tmp = Float64(Float64(ky * sin(th)) * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[kx, 0.86], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(2.0 * N[(ky * ky), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(kx * kx), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.86:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\

\mathbf{else}:\\
\;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if kx < 0.859999999999999987

    1. Initial program 91.4%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6483.9

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr70.7%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{kx}^{2}}\right)}} \cdot \sin th \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
      2. lower-*.f6458.2

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    7. Simplified58.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \color{blue}{kx \cdot kx}\right)}} \cdot \sin th \]
    8. Taylor expanded in ky around 0

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot {ky}^{2}}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, \frac{1}{2}, kx \cdot kx\right)}} \cdot \sin th \]
      3. lower-*.f6430.8

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \color{blue}{\left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]
    10. Simplified30.8%

      \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{2 \cdot \left(ky \cdot ky\right)}, 0.5, kx \cdot kx\right)}} \cdot \sin th \]

    if 0.859999999999999987 < kx

    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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6499.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr99.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in ky around 0

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      3. lower-sin.f64N/A

        \[\leadsto \left(ky \cdot \color{blue}{\sin th}\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      5. lower-/.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      6. +-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \]
      7. metadata-evalN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \]
      9. lower-fma.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \]
      10. cos-negN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      11. lower-cos.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      12. *-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \]
      13. lower-*.f6459.6

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \]
    7. Simplified59.6%

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification38.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 0.86:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(2 \cdot \left(ky \cdot ky\right), 0.5, kx \cdot kx\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 28: 25.3% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 0.0027:\\ \;\;\;\;\sin th \cdot \frac{1}{kx \cdot \mathsf{fma}\left(-0.3333333333333333, \frac{\left(kx \cdot kx\right) \cdot \sqrt{0.5}}{ky \cdot \sqrt{2}}, \sqrt{0.5} \cdot \frac{\sqrt{2}}{ky}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= kx 0.0027)
   (*
    (sin th)
    (/
     1.0
     (*
      kx
      (fma
       -0.3333333333333333
       (/ (* (* kx kx) (sqrt 0.5)) (* ky (sqrt 2.0)))
       (* (sqrt 0.5) (/ (sqrt 2.0) ky))))))
   (* (* ky (sin th)) (sqrt (/ 1.0 (fma -0.5 (cos (* kx -2.0)) 0.5))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (kx <= 0.0027) {
		tmp = sin(th) * (1.0 / (kx * fma(-0.3333333333333333, (((kx * kx) * sqrt(0.5)) / (ky * sqrt(2.0))), (sqrt(0.5) * (sqrt(2.0) / ky)))));
	} else {
		tmp = (ky * sin(th)) * sqrt((1.0 / fma(-0.5, cos((kx * -2.0)), 0.5)));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if (kx <= 0.0027)
		tmp = Float64(sin(th) * Float64(1.0 / Float64(kx * fma(-0.3333333333333333, Float64(Float64(Float64(kx * kx) * sqrt(0.5)) / Float64(ky * sqrt(2.0))), Float64(sqrt(0.5) * Float64(sqrt(2.0) / ky))))));
	else
		tmp = Float64(Float64(ky * sin(th)) * sqrt(Float64(1.0 / fma(-0.5, cos(Float64(kx * -2.0)), 0.5))));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[kx, 0.0027], N[(N[Sin[th], $MachinePrecision] * N[(1.0 / N[(kx * N[(-0.3333333333333333 * N[(N[(N[(kx * kx), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] / N[(ky * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(-0.5 * N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.0027:\\
\;\;\;\;\sin th \cdot \frac{1}{kx \cdot \mathsf{fma}\left(-0.3333333333333333, \frac{\left(kx \cdot kx\right) \cdot \sqrt{0.5}}{ky \cdot \sqrt{2}}, \sqrt{0.5} \cdot \frac{\sqrt{2}}{ky}\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if kx < 0.0027000000000000001

    1. Initial program 91.4%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Applied egg-rr70.6%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
    4. Taylor expanded in ky around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin th \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      2. lower-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      4. metadata-evalN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      6. lower--.f64N/A

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      7. cos-negN/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      9. *-commutativeN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      10. lower-*.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      11. lower-/.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      12. lower-sqrt.f6416.9

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\color{blue}{\sqrt{0.5}}}{ky}} \cdot \sin th \]
    6. Simplified16.9%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky}}} \cdot \sin th \]
    7. Taylor expanded in kx around 0

      \[\leadsto \frac{1}{\color{blue}{kx \cdot \left(\frac{-1}{3} \cdot \frac{{kx}^{2} \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}} + \frac{\sqrt{\frac{1}{2}} \cdot \sqrt{2}}{ky}\right)}} \cdot \sin th \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{kx \cdot \left(\frac{-1}{3} \cdot \frac{{kx}^{2} \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}} + \frac{\sqrt{\frac{1}{2}} \cdot \sqrt{2}}{ky}\right)}} \cdot \sin th \]
      2. lower-fma.f64N/A

        \[\leadsto \frac{1}{kx \cdot \color{blue}{\mathsf{fma}\left(\frac{-1}{3}, \frac{{kx}^{2} \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}}, \frac{\sqrt{\frac{1}{2}} \cdot \sqrt{2}}{ky}\right)}} \cdot \sin th \]
      3. lower-/.f64N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \color{blue}{\frac{{kx}^{2} \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}}}, \frac{\sqrt{\frac{1}{2}} \cdot \sqrt{2}}{ky}\right)} \cdot \sin th \]
      4. lower-*.f64N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\color{blue}{{kx}^{2} \cdot \sqrt{\frac{1}{2}}}}{ky \cdot \sqrt{2}}, \frac{\sqrt{\frac{1}{2}} \cdot \sqrt{2}}{ky}\right)} \cdot \sin th \]
      5. unpow2N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\color{blue}{\left(kx \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}}, \frac{\sqrt{\frac{1}{2}} \cdot \sqrt{2}}{ky}\right)} \cdot \sin th \]
      6. lower-*.f64N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\color{blue}{\left(kx \cdot kx\right)} \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}}, \frac{\sqrt{\frac{1}{2}} \cdot \sqrt{2}}{ky}\right)} \cdot \sin th \]
      7. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\left(kx \cdot kx\right) \cdot \color{blue}{\sqrt{\frac{1}{2}}}}{ky \cdot \sqrt{2}}, \frac{\sqrt{\frac{1}{2}} \cdot \sqrt{2}}{ky}\right)} \cdot \sin th \]
      8. lower-*.f64N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\left(kx \cdot kx\right) \cdot \sqrt{\frac{1}{2}}}{\color{blue}{ky \cdot \sqrt{2}}}, \frac{\sqrt{\frac{1}{2}} \cdot \sqrt{2}}{ky}\right)} \cdot \sin th \]
      9. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\left(kx \cdot kx\right) \cdot \sqrt{\frac{1}{2}}}{ky \cdot \color{blue}{\sqrt{2}}}, \frac{\sqrt{\frac{1}{2}} \cdot \sqrt{2}}{ky}\right)} \cdot \sin th \]
      10. associate-/l*N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\left(kx \cdot kx\right) \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}}, \color{blue}{\sqrt{\frac{1}{2}} \cdot \frac{\sqrt{2}}{ky}}\right)} \cdot \sin th \]
      11. lower-*.f64N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\left(kx \cdot kx\right) \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}}, \color{blue}{\sqrt{\frac{1}{2}} \cdot \frac{\sqrt{2}}{ky}}\right)} \cdot \sin th \]
      12. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\left(kx \cdot kx\right) \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}}, \color{blue}{\sqrt{\frac{1}{2}}} \cdot \frac{\sqrt{2}}{ky}\right)} \cdot \sin th \]
      13. lower-/.f64N/A

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(\frac{-1}{3}, \frac{\left(kx \cdot kx\right) \cdot \sqrt{\frac{1}{2}}}{ky \cdot \sqrt{2}}, \sqrt{\frac{1}{2}} \cdot \color{blue}{\frac{\sqrt{2}}{ky}}\right)} \cdot \sin th \]
      14. lower-sqrt.f6420.4

        \[\leadsto \frac{1}{kx \cdot \mathsf{fma}\left(-0.3333333333333333, \frac{\left(kx \cdot kx\right) \cdot \sqrt{0.5}}{ky \cdot \sqrt{2}}, \sqrt{0.5} \cdot \frac{\color{blue}{\sqrt{2}}}{ky}\right)} \cdot \sin th \]
    9. Simplified20.4%

      \[\leadsto \frac{1}{\color{blue}{kx \cdot \mathsf{fma}\left(-0.3333333333333333, \frac{\left(kx \cdot kx\right) \cdot \sqrt{0.5}}{ky \cdot \sqrt{2}}, \sqrt{0.5} \cdot \frac{\sqrt{2}}{ky}\right)}} \cdot \sin th \]

    if 0.0027000000000000001 < kx

    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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky + {\sin kx}^{2}}} \cdot \sin th \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      10. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      11. div-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}}} \cdot \sin th \]
      14. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(ky - ky\right) - \cos \color{blue}{\left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      15. cos-diffN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\cos ky \cdot \cos ky + \sin ky \cdot \sin ky\right)} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      16. cos-sin-sumN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1} - \cos \left(2 \cdot ky\right), \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      17. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(\color{blue}{1 - \cos \left(2 \cdot ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      18. count-2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      19. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \color{blue}{\cos \left(ky + ky\right)}, \frac{1}{2}, {\sin kx}^{2}\right)}} \cdot \sin th \]
      20. lower-+.f6499.5

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \color{blue}{\left(ky + ky\right)}, 0.5, {\sin kx}^{2}\right)}} \cdot \sin th \]
      21. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), \frac{1}{2}, \color{blue}{{\sin kx}^{2}}\right)}} \cdot \sin th \]
    4. Applied egg-rr99.2%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, 0.5 + -0.5 \cdot \cos \left(kx + kx\right)\right)}}} \cdot \sin th \]
    5. Taylor expanded in ky around 0

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \sin th\right)} \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      3. lower-sin.f64N/A

        \[\leadsto \left(ky \cdot \color{blue}{\sin th}\right) \cdot \sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \color{blue}{\sqrt{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      5. lower-/.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\color{blue}{\frac{1}{\frac{1}{2} + \frac{-1}{2} \cdot \cos \left(2 \cdot kx\right)}}} \]
      6. +-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\frac{-1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2}}}} \]
      7. metadata-evalN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right) + \frac{1}{2}}} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\frac{-1}{2} \cdot \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)} + \frac{1}{2}}} \]
      9. lower-fma.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right), \frac{1}{2}\right)}}} \]
      10. cos-negN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      11. lower-cos.f64N/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\cos \left(-2 \cdot kx\right)}, \frac{1}{2}\right)}} \]
      12. *-commutativeN/A

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(kx \cdot -2\right)}, \frac{1}{2}\right)}} \]
      13. lower-*.f6459.6

        \[\leadsto \left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(kx \cdot -2\right)}, 0.5\right)}} \]
    7. Simplified59.6%

      \[\leadsto \color{blue}{\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification31.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 0.0027:\\ \;\;\;\;\sin th \cdot \frac{1}{kx \cdot \mathsf{fma}\left(-0.3333333333333333, \frac{\left(kx \cdot kx\right) \cdot \sqrt{0.5}}{ky \cdot \sqrt{2}}, \sqrt{0.5} \cdot \frac{\sqrt{2}}{ky}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(kx \cdot -2\right), 0.5\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 29: 21.5% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 3.86 \cdot 10^{-91}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \left(\frac{1}{kx} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right)\\ \mathbf{elif}\;ky \leq 3 \cdot 10^{-15}:\\ \;\;\;\;\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(ky \cdot \frac{th}{\sqrt{0.5}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{1}{\sin ky}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= ky 3.86e-91)
   (*
    (sin th)
    (*
     ky
     (*
      (/ 1.0 kx)
      (fma
       ky
       (* ky (fma (* ky ky) 0.008333333333333333 -0.16666666666666666))
       1.0))))
   (if (<= ky 3e-15)
     (* (sqrt (/ 1.0 (- 1.0 (cos (* kx -2.0))))) (* ky (/ th (sqrt 0.5))))
     (* (sin th) (/ 1.0 (sin ky))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (ky <= 3.86e-91) {
		tmp = sin(th) * (ky * ((1.0 / kx) * fma(ky, (ky * fma((ky * ky), 0.008333333333333333, -0.16666666666666666)), 1.0)));
	} else if (ky <= 3e-15) {
		tmp = sqrt((1.0 / (1.0 - cos((kx * -2.0))))) * (ky * (th / sqrt(0.5)));
	} else {
		tmp = sin(th) * (1.0 / sin(ky));
	}
	return tmp;
}
function code(kx, ky, th)
	tmp = 0.0
	if (ky <= 3.86e-91)
		tmp = Float64(sin(th) * Float64(ky * Float64(Float64(1.0 / kx) * fma(ky, Float64(ky * fma(Float64(ky * ky), 0.008333333333333333, -0.16666666666666666)), 1.0))));
	elseif (ky <= 3e-15)
		tmp = Float64(sqrt(Float64(1.0 / Float64(1.0 - cos(Float64(kx * -2.0))))) * Float64(ky * Float64(th / sqrt(0.5))));
	else
		tmp = Float64(sin(th) * Float64(1.0 / sin(ky)));
	end
	return tmp
end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.86e-91], N[(N[Sin[th], $MachinePrecision] * N[(ky * N[(N[(1.0 / kx), $MachinePrecision] * N[(ky * N[(ky * N[(N[(ky * ky), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 3e-15], 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[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(1.0 / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3.86 \cdot 10^{-91}:\\
\;\;\;\;\sin th \cdot \left(ky \cdot \left(\frac{1}{kx} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right)\\

\mathbf{elif}\;ky \leq 3 \cdot 10^{-15}:\\
\;\;\;\;\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(ky \cdot \frac{th}{\sqrt{0.5}}\right)\\

\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{1}{\sin ky}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < 3.86000000000000009e-91

    1. Initial program 91.4%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Taylor expanded in ky around 0

      \[\leadsto \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)\right)} \cdot \sin th \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)\right)} \cdot \sin th \]
      2. +-commutativeN/A

        \[\leadsto \left(ky \cdot \color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)}\right) \cdot \sin th \]
      3. distribute-lft-inN/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right) + {ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)} + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) \cdot \sin th \]
      4. associate-+l+N/A

        \[\leadsto \left(ky \cdot \color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right) + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)}\right) \cdot \sin th \]
      5. associate-*r*N/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \frac{-1}{6}\right) \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}} + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right) \cdot \sin th \]
      6. *-commutativeN/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2}\right)} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right) \cdot \sin th \]
    5. Simplified8.4%

      \[\leadsto \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right)} \cdot \sin th \]
    6. Taylor expanded in kx around 0

      \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
    7. Step-by-step derivation
      1. lower-sqrt.f64N/A

        \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      2. lower-/.f64N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\color{blue}{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      3. cube-multN/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{\color{blue}{kx \cdot \left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      4. unpow2N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{{kx}^{2}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      5. lower-*.f64N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{\color{blue}{kx \cdot {kx}^{2}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      6. unpow2N/A

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{\left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
      7. lower-*.f6413.2

        \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{\left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
    8. Simplified13.2%

      \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{kx \cdot \left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
    9. Taylor expanded in kx around 0

      \[\leadsto \left(ky \cdot \left(\color{blue}{\frac{1}{kx}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
    10. Step-by-step derivation
      1. lower-/.f6426.1

        \[\leadsto \left(ky \cdot \left(\color{blue}{\frac{1}{kx}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
    11. Simplified26.1%

      \[\leadsto \left(ky \cdot \left(\color{blue}{\frac{1}{kx}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]

    if 3.86000000000000009e-91 < ky < 3e-15

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Applied egg-rr75.2%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
    4. Taylor expanded in ky around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin th \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      2. lower-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      4. metadata-evalN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      6. lower--.f64N/A

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      7. cos-negN/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      9. *-commutativeN/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      10. lower-*.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
      11. lower-/.f64N/A

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
      12. lower-sqrt.f6475.1

        \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\color{blue}{\sqrt{0.5}}}{ky}} \cdot \sin th \]
    6. Simplified75.1%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky}}} \cdot \sin th \]
    7. Taylor expanded in th around 0

      \[\leadsto \color{blue}{\frac{ky \cdot th}{\sqrt{\frac{1}{2}}} \cdot \sqrt{\frac{1}{1 - \cos \left(-2 \cdot kx\right)}}} \]
    8. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(-2 \cdot kx\right)}} \cdot \frac{ky \cdot th}{\sqrt{\frac{1}{2}}}} \]
      2. cos-negN/A

        \[\leadsto \sqrt{\frac{1}{1 - \color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}}} \cdot \frac{ky \cdot th}{\sqrt{\frac{1}{2}}} \]
      3. distribute-lft-neg-inN/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot kx\right)}}} \cdot \frac{ky \cdot th}{\sqrt{\frac{1}{2}}} \]
      4. metadata-evalN/A

        \[\leadsto \sqrt{\frac{1}{1 - \cos \left(\color{blue}{2} \cdot kx\right)}} \cdot \frac{ky \cdot th}{\sqrt{\frac{1}{2}}} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(2 \cdot kx\right)}} \cdot \frac{ky \cdot th}{\sqrt{\frac{1}{2}}}} \]
    9. Simplified28.5%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(ky \cdot \frac{th}{\sqrt{0.5}}\right)} \]

    if 3e-15 < 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-sin.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. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\color{blue}{\sin ky}}^{2}}} \cdot \sin th \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      5. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} + {\sin kx}^{2}}} \cdot \sin th \]
      7. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      8. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{{\sin kx}^{2}}}} \cdot \sin th \]
      9. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      10. lower-hypot.f6499.8

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
    4. Applied egg-rr99.8%

      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \sin th \]
    5. Taylor expanded in kx around 0

      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)} \cdot \sin th \]
    6. Step-by-step derivation
      1. +-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-*.f6446.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. Simplified46.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 kx around 0

      \[\leadsto \color{blue}{\frac{1}{\sin ky}} \cdot \sin th \]
    9. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\sin ky}} \cdot \sin th \]
      2. lower-sin.f6420.2

        \[\leadsto \frac{1}{\color{blue}{\sin ky}} \cdot \sin th \]
    10. Simplified20.2%

      \[\leadsto \color{blue}{\frac{1}{\sin ky}} \cdot \sin th \]
  3. Recombined 3 regimes into one program.
  4. Final simplification24.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 3.86 \cdot 10^{-91}:\\ \;\;\;\;\sin th \cdot \left(ky \cdot \left(\frac{1}{kx} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right)\\ \mathbf{elif}\;ky \leq 3 \cdot 10^{-15}:\\ \;\;\;\;\sqrt{\frac{1}{1 - \cos \left(kx \cdot -2\right)}} \cdot \left(ky \cdot \frac{th}{\sqrt{0.5}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{1}{\sin ky}\\ \end{array} \]
  5. Add Preprocessing

Alternative 30: 16.8% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \sin th \cdot \frac{1}{\frac{\sqrt{2} \cdot \left(kx \cdot \sqrt{0.5}\right)}{ky}} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (* (sin th) (/ 1.0 (/ (* (sqrt 2.0) (* kx (sqrt 0.5))) ky))))
double code(double kx, double ky, double th) {
	return sin(th) * (1.0 / ((sqrt(2.0) * (kx * sqrt(0.5))) / ky));
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    code = sin(th) * (1.0d0 / ((sqrt(2.0d0) * (kx * sqrt(0.5d0))) / ky))
end function
public static double code(double kx, double ky, double th) {
	return Math.sin(th) * (1.0 / ((Math.sqrt(2.0) * (kx * Math.sqrt(0.5))) / ky));
}
def code(kx, ky, th):
	return math.sin(th) * (1.0 / ((math.sqrt(2.0) * (kx * math.sqrt(0.5))) / ky))
function code(kx, ky, th)
	return Float64(sin(th) * Float64(1.0 / Float64(Float64(sqrt(2.0) * Float64(kx * sqrt(0.5))) / ky)))
end
function tmp = code(kx, ky, th)
	tmp = sin(th) * (1.0 / ((sqrt(2.0) * (kx * sqrt(0.5))) / ky));
end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] * N[(1.0 / N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(kx * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin th \cdot \frac{1}{\frac{\sqrt{2} \cdot \left(kx \cdot \sqrt{0.5}\right)}{ky}}
\end{array}
Derivation
  1. Initial program 93.6%

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Add Preprocessing
  3. Applied egg-rr78.5%

    \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
  4. Taylor expanded in ky around 0

    \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin th \]
  5. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
    2. lower-*.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
    3. lower-sqrt.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    4. metadata-evalN/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    5. distribute-lft-neg-inN/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    6. lower--.f64N/A

      \[\leadsto \frac{1}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    7. cos-negN/A

      \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    8. lower-cos.f64N/A

      \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    9. *-commutativeN/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    10. lower-*.f64N/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    11. lower-/.f64N/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
    12. lower-sqrt.f6428.6

      \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\color{blue}{\sqrt{0.5}}}{ky}} \cdot \sin th \]
  6. Simplified28.6%

    \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky}}} \cdot \sin th \]
  7. Taylor expanded in kx around 0

    \[\leadsto \frac{1}{\color{blue}{\frac{kx \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}{ky}}} \cdot \sin th \]
  8. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{kx \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}{ky}}} \cdot \sin th \]
    2. associate-*r*N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{\left(kx \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{2}}}{ky}} \cdot \sin th \]
    3. lower-*.f64N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{\left(kx \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{2}}}{ky}} \cdot \sin th \]
    4. lower-*.f64N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{\left(kx \cdot \sqrt{\frac{1}{2}}\right)} \cdot \sqrt{2}}{ky}} \cdot \sin th \]
    5. lower-sqrt.f64N/A

      \[\leadsto \frac{1}{\frac{\left(kx \cdot \color{blue}{\sqrt{\frac{1}{2}}}\right) \cdot \sqrt{2}}{ky}} \cdot \sin th \]
    6. lower-sqrt.f6420.5

      \[\leadsto \frac{1}{\frac{\left(kx \cdot \sqrt{0.5}\right) \cdot \color{blue}{\sqrt{2}}}{ky}} \cdot \sin th \]
  9. Simplified20.5%

    \[\leadsto \frac{1}{\color{blue}{\frac{\left(kx \cdot \sqrt{0.5}\right) \cdot \sqrt{2}}{ky}}} \cdot \sin th \]
  10. Final simplification20.5%

    \[\leadsto \sin th \cdot \frac{1}{\frac{\sqrt{2} \cdot \left(kx \cdot \sqrt{0.5}\right)}{ky}} \]
  11. Add Preprocessing

Alternative 31: 16.1% accurate, 4.2× speedup?

\[\begin{array}{l} \\ \sin th \cdot \left(ky \cdot \left(\frac{1}{kx} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (*
  (sin th)
  (*
   ky
   (*
    (/ 1.0 kx)
    (fma
     ky
     (* ky (fma (* ky ky) 0.008333333333333333 -0.16666666666666666))
     1.0)))))
double code(double kx, double ky, double th) {
	return sin(th) * (ky * ((1.0 / kx) * fma(ky, (ky * fma((ky * ky), 0.008333333333333333, -0.16666666666666666)), 1.0)));
}
function code(kx, ky, th)
	return Float64(sin(th) * Float64(ky * Float64(Float64(1.0 / kx) * fma(ky, Float64(ky * fma(Float64(ky * ky), 0.008333333333333333, -0.16666666666666666)), 1.0))))
end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] * N[(ky * N[(N[(1.0 / kx), $MachinePrecision] * N[(ky * N[(ky * N[(N[(ky * ky), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin th \cdot \left(ky \cdot \left(\frac{1}{kx} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right)
\end{array}
Derivation
  1. Initial program 93.6%

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Add Preprocessing
  3. Taylor expanded in ky around 0

    \[\leadsto \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)\right)} \cdot \sin th \]
  4. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} + {ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)\right)} \cdot \sin th \]
    2. +-commutativeN/A

      \[\leadsto \left(ky \cdot \color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)}\right) \cdot \sin th \]
    3. distribute-lft-inN/A

      \[\leadsto \left(ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right) + {ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right)} + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) \cdot \sin th \]
    4. associate-+l+N/A

      \[\leadsto \left(ky \cdot \color{blue}{\left({ky}^{2} \cdot \left(\frac{-1}{6} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right) + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)}\right) \cdot \sin th \]
    5. associate-*r*N/A

      \[\leadsto \left(ky \cdot \left(\color{blue}{\left({ky}^{2} \cdot \frac{-1}{6}\right) \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}} + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right) \cdot \sin th \]
    6. *-commutativeN/A

      \[\leadsto \left(ky \cdot \left(\color{blue}{\left(\frac{-1}{6} \cdot {ky}^{2}\right)} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}} + \left({ky}^{2} \cdot \left(\frac{1}{120} \cdot \left({ky}^{2} \cdot \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right) + \sqrt{\frac{1}{{\sin kx}^{5}}}\right)\right)\right) \cdot \sin th \]
  5. Simplified6.8%

    \[\leadsto \color{blue}{\left(ky \cdot \left(\sqrt{\frac{1}{{\sin kx}^{5}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right)} \cdot \sin th \]
  6. Taylor expanded in kx around 0

    \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
  7. Step-by-step derivation
    1. lower-sqrt.f64N/A

      \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
    2. lower-/.f64N/A

      \[\leadsto \left(ky \cdot \left(\sqrt{\color{blue}{\frac{1}{{kx}^{3}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
    3. cube-multN/A

      \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{\color{blue}{kx \cdot \left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
    4. unpow2N/A

      \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{{kx}^{2}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
    5. lower-*.f64N/A

      \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{\color{blue}{kx \cdot {kx}^{2}}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
    6. unpow2N/A

      \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{\left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
    7. lower-*.f6410.2

      \[\leadsto \left(ky \cdot \left(\sqrt{\frac{1}{kx \cdot \color{blue}{\left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
  8. Simplified10.2%

    \[\leadsto \left(ky \cdot \left(\color{blue}{\sqrt{\frac{1}{kx \cdot \left(kx \cdot kx\right)}}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
  9. Taylor expanded in kx around 0

    \[\leadsto \left(ky \cdot \left(\color{blue}{\frac{1}{kx}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, \frac{1}{120}, \frac{-1}{6}\right), 1\right)\right)\right) \cdot \sin th \]
  10. Step-by-step derivation
    1. lower-/.f6419.9

      \[\leadsto \left(ky \cdot \left(\color{blue}{\frac{1}{kx}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
  11. Simplified19.9%

    \[\leadsto \left(ky \cdot \left(\color{blue}{\frac{1}{kx}} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \cdot \sin th \]
  12. Final simplification19.9%

    \[\leadsto \sin th \cdot \left(ky \cdot \left(\frac{1}{kx} \cdot \mathsf{fma}\left(ky, ky \cdot \mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right) \]
  13. Add Preprocessing

Alternative 32: 16.0% accurate, 5.4× speedup?

\[\begin{array}{l} \\ \frac{ky \cdot \sin th}{kx} \end{array} \]
(FPCore (kx ky th) :precision binary64 (/ (* ky (sin th)) kx))
double code(double kx, double ky, double th) {
	return (ky * sin(th)) / kx;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    code = (ky * sin(th)) / kx
end function
public static double code(double kx, double ky, double th) {
	return (ky * Math.sin(th)) / kx;
}
def code(kx, ky, th):
	return (ky * math.sin(th)) / kx
function code(kx, ky, th)
	return Float64(Float64(ky * sin(th)) / kx)
end
function tmp = code(kx, ky, th)
	tmp = (ky * sin(th)) / kx;
end
code[kx_, ky_, th_] := N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / kx), $MachinePrecision]
\begin{array}{l}

\\
\frac{ky \cdot \sin th}{kx}
\end{array}
Derivation
  1. Initial program 93.6%

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Add Preprocessing
  3. Applied egg-rr78.5%

    \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
  4. Taylor expanded in ky around 0

    \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin th \]
  5. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
    2. lower-*.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
    3. lower-sqrt.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    4. metadata-evalN/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    5. distribute-lft-neg-inN/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    6. lower--.f64N/A

      \[\leadsto \frac{1}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    7. cos-negN/A

      \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    8. lower-cos.f64N/A

      \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    9. *-commutativeN/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    10. lower-*.f64N/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    11. lower-/.f64N/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
    12. lower-sqrt.f6428.6

      \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\color{blue}{\sqrt{0.5}}}{ky}} \cdot \sin th \]
  6. Simplified28.6%

    \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky}}} \cdot \sin th \]
  7. Taylor expanded in kx around 0

    \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{kx}} \]
  8. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{kx}} \]
    2. lower-*.f64N/A

      \[\leadsto \frac{\color{blue}{ky \cdot \sin th}}{kx} \]
    3. lower-sin.f6419.5

      \[\leadsto \frac{ky \cdot \color{blue}{\sin th}}{kx} \]
  9. Simplified19.5%

    \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{kx}} \]
  10. Add Preprocessing

Alternative 33: 8.1% accurate, 5.4× speedup?

\[\begin{array}{l} \\ \sin th \cdot \frac{1}{kx} \end{array} \]
(FPCore (kx ky th) :precision binary64 (* (sin th) (/ 1.0 kx)))
double code(double kx, double ky, double th) {
	return sin(th) * (1.0 / kx);
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    code = sin(th) * (1.0d0 / kx)
end function
public static double code(double kx, double ky, double th) {
	return Math.sin(th) * (1.0 / kx);
}
def code(kx, ky, th):
	return math.sin(th) * (1.0 / kx)
function code(kx, ky, th)
	return Float64(sin(th) * Float64(1.0 / kx))
end
function tmp = code(kx, ky, th)
	tmp = sin(th) * (1.0 / kx);
end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] * N[(1.0 / kx), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin th \cdot \frac{1}{kx}
\end{array}
Derivation
  1. Initial program 93.6%

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Add Preprocessing
  3. Applied egg-rr78.5%

    \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky}}} \cdot \sin th \]
  4. Taylor expanded in ky around 0

    \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky} \cdot \sqrt{1 - \cos \left(2 \cdot kx\right)}}} \cdot \sin th \]
  5. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
    2. lower-*.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
    3. lower-sqrt.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    4. metadata-evalN/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot kx\right)} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    5. distribute-lft-neg-inN/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    6. lower--.f64N/A

      \[\leadsto \frac{1}{\sqrt{\color{blue}{1 - \cos \left(\mathsf{neg}\left(-2 \cdot kx\right)\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    7. cos-negN/A

      \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    8. lower-cos.f64N/A

      \[\leadsto \frac{1}{\sqrt{1 - \color{blue}{\cos \left(-2 \cdot kx\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    9. *-commutativeN/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    10. lower-*.f64N/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \frac{\sqrt{\frac{1}{2}}}{ky}} \cdot \sin th \]
    11. lower-/.f64N/A

      \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \color{blue}{\frac{\sqrt{\frac{1}{2}}}{ky}}} \cdot \sin th \]
    12. lower-sqrt.f6428.6

      \[\leadsto \frac{1}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\color{blue}{\sqrt{0.5}}}{ky}} \cdot \sin th \]
  6. Simplified28.6%

    \[\leadsto \frac{1}{\color{blue}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \frac{\sqrt{0.5}}{ky}}} \cdot \sin th \]
  7. Taylor expanded in kx around 0

    \[\leadsto \color{blue}{\frac{1}{kx}} \cdot \sin th \]
  8. Step-by-step derivation
    1. lower-/.f6410.4

      \[\leadsto \color{blue}{\frac{1}{kx}} \cdot \sin th \]
  9. Simplified10.4%

    \[\leadsto \color{blue}{\frac{1}{kx}} \cdot \sin th \]
  10. Final simplification10.4%

    \[\leadsto \sin th \cdot \frac{1}{kx} \]
  11. Add Preprocessing

Alternative 34: 3.4% accurate, 37.2× speedup?

\[\begin{array}{l} \\ \frac{th}{ky \cdot ky} \end{array} \]
(FPCore (kx ky th) :precision binary64 (/ th (* ky ky)))
double code(double kx, double ky, double th) {
	return th / (ky * ky);
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    code = th / (ky * ky)
end function
public static double code(double kx, double ky, double th) {
	return th / (ky * ky);
}
def code(kx, ky, th):
	return th / (ky * ky)
function code(kx, ky, th)
	return Float64(th / Float64(ky * ky))
end
function tmp = code(kx, ky, th)
	tmp = th / (ky * ky);
end
code[kx_, ky_, th_] := N[(th / N[(ky * ky), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{th}{ky \cdot ky}
\end{array}
Derivation
  1. Initial program 93.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}{\frac{\sin th}{{\sin ky}^{3}}} \]
  4. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\sin th}{{\sin ky}^{3}}} \]
    2. lower-sin.f64N/A

      \[\leadsto \frac{\color{blue}{\sin th}}{{\sin ky}^{3}} \]
    3. lower-pow.f64N/A

      \[\leadsto \frac{\sin th}{\color{blue}{{\sin ky}^{3}}} \]
    4. lower-sin.f6410.7

      \[\leadsto \frac{\sin th}{{\color{blue}{\sin ky}}^{3}} \]
  5. Simplified10.7%

    \[\leadsto \color{blue}{\frac{\sin th}{{\sin ky}^{3}}} \]
  6. Taylor expanded in ky around 0

    \[\leadsto \frac{\sin th}{\color{blue}{{ky}^{2}}} \]
  7. Step-by-step derivation
    1. unpow2N/A

      \[\leadsto \frac{\sin th}{\color{blue}{ky \cdot ky}} \]
    2. lower-*.f643.4

      \[\leadsto \frac{\sin th}{\color{blue}{ky \cdot ky}} \]
  8. Simplified3.4%

    \[\leadsto \frac{\sin th}{\color{blue}{ky \cdot ky}} \]
  9. Taylor expanded in th around 0

    \[\leadsto \color{blue}{\frac{th}{{ky}^{3}}} \]
  10. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{th}{{ky}^{3}}} \]
    2. cube-multN/A

      \[\leadsto \frac{th}{\color{blue}{ky \cdot \left(ky \cdot ky\right)}} \]
    3. unpow2N/A

      \[\leadsto \frac{th}{ky \cdot \color{blue}{{ky}^{2}}} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{th}{\color{blue}{ky \cdot {ky}^{2}}} \]
    5. unpow2N/A

      \[\leadsto \frac{th}{ky \cdot \color{blue}{\left(ky \cdot ky\right)}} \]
    6. lower-*.f643.4

      \[\leadsto \frac{th}{ky \cdot \color{blue}{\left(ky \cdot ky\right)}} \]
  11. Simplified3.4%

    \[\leadsto \color{blue}{\frac{th}{ky \cdot \left(ky \cdot ky\right)}} \]
  12. Taylor expanded in th around 0

    \[\leadsto \color{blue}{\frac{th}{{ky}^{2}}} \]
  13. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{th}{{ky}^{2}}} \]
    2. unpow2N/A

      \[\leadsto \frac{th}{\color{blue}{ky \cdot ky}} \]
    3. lower-*.f643.4

      \[\leadsto \frac{th}{\color{blue}{ky \cdot ky}} \]
  14. Simplified3.4%

    \[\leadsto \color{blue}{\frac{th}{ky \cdot ky}} \]
  15. Add Preprocessing

Reproduce

?
herbie shell --seed 2024214 
(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)))