Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.1% → 99.7%
Time: 12.4s
Alternatives: 17
Speedup: 1.4×

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 17 alternatives:

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

Initial Program: 94.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.4× speedup?

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{\sin kx \cdot \sin kx + {\sin ky}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
    2. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
    3. hypot-defineN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
    4. hypot-lowering-hypot.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\sin kx, \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
    5. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
    6. sin-lowering-sin.f6499.6%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
  5. Simplified99.6%

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

Alternative 2: 99.6% accurate, 1.4× speedup?

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

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

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Step-by-step derivation
    1. associate-*l/N/A

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
    6. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
    7. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
    8. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
    9. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
    10. hypot-defineN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
    11. hypot-lowering-hypot.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
    12. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
    13. sin-lowering-sin.f6499.6%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
  3. Simplified99.6%

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

Alternative 3: 67.1% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 0.0069:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \left(th \cdot \left(1 + th \cdot \left(th \cdot -0.16666666666666666\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= th 0.0069)
   (*
    (/ (sin ky) (hypot (sin kx) (sin ky)))
    (* th (+ 1.0 (* th (* th -0.16666666666666666)))))
   (* ky (/ (sin th) (hypot ky (sin kx))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (th <= 0.0069) {
		tmp = (sin(ky) / hypot(sin(kx), sin(ky))) * (th * (1.0 + (th * (th * -0.16666666666666666))));
	} else {
		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
	}
	return tmp;
}
public static double code(double kx, double ky, double th) {
	double tmp;
	if (th <= 0.0069) {
		tmp = (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky))) * (th * (1.0 + (th * (th * -0.16666666666666666))));
	} else {
		tmp = ky * (Math.sin(th) / Math.hypot(ky, Math.sin(kx)));
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if th <= 0.0069:
		tmp = (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) * (th * (1.0 + (th * (th * -0.16666666666666666))))
	else:
		tmp = ky * (math.sin(th) / math.hypot(ky, math.sin(kx)))
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if (th <= 0.0069)
		tmp = Float64(Float64(sin(ky) / hypot(sin(kx), sin(ky))) * Float64(th * Float64(1.0 + Float64(th * Float64(th * -0.16666666666666666)))));
	else
		tmp = Float64(ky * Float64(sin(th) / hypot(ky, sin(kx))));
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if (th <= 0.0069)
		tmp = (sin(ky) / hypot(sin(kx), sin(ky))) * (th * (1.0 + (th * (th * -0.16666666666666666))));
	else
		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[LessEqual[th, 0.0069], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(th * N[(1.0 + N[(th * N[(th * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.0069:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \left(th \cdot \left(1 + th \cdot \left(th \cdot -0.16666666666666666\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if th < 0.0068999999999999999

    1. Initial program 93.4%

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{\sin kx \cdot \sin kx + {\sin ky}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
      3. hypot-defineN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
      4. hypot-lowering-hypot.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\sin kx, \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
      5. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
      6. sin-lowering-sin.f6499.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
    5. Simplified99.7%

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \left(\left(th \cdot th\right) \cdot \frac{-1}{6}\right)\right)\right)\right) \]
      5. associate-*l*N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(th, \color{blue}{\left(th \cdot \frac{-1}{6}\right)}\right)\right)\right)\right) \]
      7. *-lowering-*.f6461.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(th, \mathsf{*.f64}\left(th, \color{blue}{\frac{-1}{6}}\right)\right)\right)\right)\right) \]
    8. Simplified61.8%

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

    if 0.0068999999999999999 < th

    1. Initial program 91.4%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. associate-*l/N/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
      6. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
      7. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
      10. hypot-defineN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
      11. hypot-lowering-hypot.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
      12. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
      13. sin-lowering-sin.f6499.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
    3. Simplified99.4%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\color{blue}{ky}, \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(ky, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
      3. Step-by-step derivation
        1. Simplified75.4%

          \[\leadsto \color{blue}{ky} \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)} \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 4: 67.1% accurate, 1.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 0.0057:\\ \;\;\;\;\sin ky \cdot \frac{th \cdot \left(1 + th \cdot \left(th \cdot -0.16666666666666666\right)\right)}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \end{array} \end{array} \]
      (FPCore (kx ky th)
       :precision binary64
       (if (<= th 0.0057)
         (*
          (sin ky)
          (/
           (* th (+ 1.0 (* th (* th -0.16666666666666666))))
           (hypot (sin ky) (sin kx))))
         (* ky (/ (sin th) (hypot ky (sin kx))))))
      double code(double kx, double ky, double th) {
      	double tmp;
      	if (th <= 0.0057) {
      		tmp = sin(ky) * ((th * (1.0 + (th * (th * -0.16666666666666666)))) / hypot(sin(ky), sin(kx)));
      	} else {
      		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
      	}
      	return tmp;
      }
      
      public static double code(double kx, double ky, double th) {
      	double tmp;
      	if (th <= 0.0057) {
      		tmp = Math.sin(ky) * ((th * (1.0 + (th * (th * -0.16666666666666666)))) / Math.hypot(Math.sin(ky), Math.sin(kx)));
      	} else {
      		tmp = ky * (Math.sin(th) / Math.hypot(ky, Math.sin(kx)));
      	}
      	return tmp;
      }
      
      def code(kx, ky, th):
      	tmp = 0
      	if th <= 0.0057:
      		tmp = math.sin(ky) * ((th * (1.0 + (th * (th * -0.16666666666666666)))) / math.hypot(math.sin(ky), math.sin(kx)))
      	else:
      		tmp = ky * (math.sin(th) / math.hypot(ky, math.sin(kx)))
      	return tmp
      
      function code(kx, ky, th)
      	tmp = 0.0
      	if (th <= 0.0057)
      		tmp = Float64(sin(ky) * Float64(Float64(th * Float64(1.0 + Float64(th * Float64(th * -0.16666666666666666)))) / hypot(sin(ky), sin(kx))));
      	else
      		tmp = Float64(ky * Float64(sin(th) / hypot(ky, sin(kx))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(kx, ky, th)
      	tmp = 0.0;
      	if (th <= 0.0057)
      		tmp = sin(ky) * ((th * (1.0 + (th * (th * -0.16666666666666666)))) / hypot(sin(ky), sin(kx)));
      	else
      		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
      	end
      	tmp_2 = tmp;
      end
      
      code[kx_, ky_, th_] := If[LessEqual[th, 0.0057], N[(N[Sin[ky], $MachinePrecision] * N[(N[(th * N[(1.0 + N[(th * N[(th * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;th \leq 0.0057:\\
      \;\;\;\;\sin ky \cdot \frac{th \cdot \left(1 + th \cdot \left(th \cdot -0.16666666666666666\right)\right)}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if th < 0.0057000000000000002

        1. Initial program 93.4%

          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
        2. Step-by-step derivation
          1. associate-*l/N/A

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
          6. sin-lowering-sin.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
          7. +-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
          8. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
          9. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
          10. hypot-defineN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
          11. hypot-lowering-hypot.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
          12. sin-lowering-sin.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
          13. sin-lowering-sin.f6499.6%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
        3. Simplified99.6%

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot \left(th \cdot th\right)\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
          4. associate-*r*N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \left(\left(\frac{-1}{6} \cdot th\right) \cdot th\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
          5. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(\frac{-1}{6} \cdot th\right), th\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
          6. *-lowering-*.f6461.7%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{6}, th\right), th\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
        7. Simplified61.7%

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

        if 0.0057000000000000002 < th

        1. Initial program 91.4%

          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
        2. Step-by-step derivation
          1. associate-*l/N/A

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
          6. sin-lowering-sin.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
          7. +-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
          8. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
          9. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
          10. hypot-defineN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
          11. hypot-lowering-hypot.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
          12. sin-lowering-sin.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
          13. sin-lowering-sin.f6499.4%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
        3. Simplified99.4%

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\color{blue}{ky}, \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(ky, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
          3. Step-by-step derivation
            1. Simplified75.4%

              \[\leadsto \color{blue}{ky} \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)} \]
          4. Recombined 2 regimes into one program.
          5. Final simplification65.4%

            \[\leadsto \begin{array}{l} \mathbf{if}\;th \leq 0.0057:\\ \;\;\;\;\sin ky \cdot \frac{th \cdot \left(1 + th \cdot \left(th \cdot -0.16666666666666666\right)\right)}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \end{array} \]
          6. Add Preprocessing

          Alternative 5: 62.7% accurate, 1.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.05:\\ \;\;\;\;th \cdot \frac{\frac{1}{\frac{1}{\sin ky}}}{\mathsf{hypot}\left(kx, \sin ky\right)}\\ \mathbf{else}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \end{array} \end{array} \]
          (FPCore (kx ky th)
           :precision binary64
           (if (<= (sin ky) -0.05)
             (* th (/ (/ 1.0 (/ 1.0 (sin ky))) (hypot kx (sin ky))))
             (* ky (/ (sin th) (hypot ky (sin kx))))))
          double code(double kx, double ky, double th) {
          	double tmp;
          	if (sin(ky) <= -0.05) {
          		tmp = th * ((1.0 / (1.0 / sin(ky))) / hypot(kx, sin(ky)));
          	} else {
          		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
          	}
          	return tmp;
          }
          
          public static double code(double kx, double ky, double th) {
          	double tmp;
          	if (Math.sin(ky) <= -0.05) {
          		tmp = th * ((1.0 / (1.0 / Math.sin(ky))) / Math.hypot(kx, Math.sin(ky)));
          	} else {
          		tmp = ky * (Math.sin(th) / Math.hypot(ky, Math.sin(kx)));
          	}
          	return tmp;
          }
          
          def code(kx, ky, th):
          	tmp = 0
          	if math.sin(ky) <= -0.05:
          		tmp = th * ((1.0 / (1.0 / math.sin(ky))) / math.hypot(kx, math.sin(ky)))
          	else:
          		tmp = ky * (math.sin(th) / math.hypot(ky, math.sin(kx)))
          	return tmp
          
          function code(kx, ky, th)
          	tmp = 0.0
          	if (sin(ky) <= -0.05)
          		tmp = Float64(th * Float64(Float64(1.0 / Float64(1.0 / sin(ky))) / hypot(kx, sin(ky))));
          	else
          		tmp = Float64(ky * Float64(sin(th) / hypot(ky, sin(kx))));
          	end
          	return tmp
          end
          
          function tmp_2 = code(kx, ky, th)
          	tmp = 0.0;
          	if (sin(ky) <= -0.05)
          		tmp = th * ((1.0 / (1.0 / sin(ky))) / hypot(kx, sin(ky)));
          	else
          		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
          	end
          	tmp_2 = tmp;
          end
          
          code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(th * N[(N[(1.0 / N[(1.0 / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\sin ky \leq -0.05:\\
          \;\;\;\;th \cdot \frac{\frac{1}{\frac{1}{\sin ky}}}{\mathsf{hypot}\left(kx, \sin ky\right)}\\
          
          \mathbf{else}:\\
          \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (sin.f64 ky) < -0.050000000000000003

            1. Initial program 99.6%

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{\sin kx \cdot \sin kx + {\sin ky}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              2. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              3. hypot-defineN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              4. hypot-lowering-hypot.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\sin kx, \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              5. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              6. sin-lowering-sin.f6499.6%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
            5. Simplified99.6%

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{\sin ky}{1}\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              2. clear-numN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{\frac{1}{\sin ky}}\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              3. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\frac{1}{\sin ky}\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              4. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \sin ky\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              5. sin-lowering-sin.f6499.3%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
            7. Applied egg-rr99.3%

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \color{blue}{th}\right) \]
            9. Step-by-step derivation
              1. Simplified36.7%

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{hypot.f64}\left(\color{blue}{kx}, \mathsf{sin.f64}\left(ky\right)\right)\right), th\right) \]
              3. Step-by-step derivation
                1. Simplified15.0%

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

                if -0.050000000000000003 < (sin.f64 ky)

                1. Initial program 91.0%

                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                2. Step-by-step derivation
                  1. associate-*l/N/A

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

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                  6. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                  7. +-commutativeN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                  8. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                  9. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                  10. hypot-defineN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                  11. hypot-lowering-hypot.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                  12. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                  13. sin-lowering-sin.f6499.6%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                3. Simplified99.6%

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

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\color{blue}{ky}, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                6. Step-by-step derivation
                  1. Simplified78.2%

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

                    \[\leadsto \mathsf{*.f64}\left(\color{blue}{ky}, \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(ky, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  3. Step-by-step derivation
                    1. Simplified83.5%

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

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

                  Alternative 6: 67.1% accurate, 1.7× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 0.00235:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot th\\ \mathbf{else}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \end{array} \end{array} \]
                  (FPCore (kx ky th)
                   :precision binary64
                   (if (<= th 0.00235)
                     (* (/ (sin ky) (hypot (sin kx) (sin ky))) th)
                     (* ky (/ (sin th) (hypot ky (sin kx))))))
                  double code(double kx, double ky, double th) {
                  	double tmp;
                  	if (th <= 0.00235) {
                  		tmp = (sin(ky) / hypot(sin(kx), sin(ky))) * th;
                  	} else {
                  		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
                  	}
                  	return tmp;
                  }
                  
                  public static double code(double kx, double ky, double th) {
                  	double tmp;
                  	if (th <= 0.00235) {
                  		tmp = (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky))) * th;
                  	} else {
                  		tmp = ky * (Math.sin(th) / Math.hypot(ky, Math.sin(kx)));
                  	}
                  	return tmp;
                  }
                  
                  def code(kx, ky, th):
                  	tmp = 0
                  	if th <= 0.00235:
                  		tmp = (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) * th
                  	else:
                  		tmp = ky * (math.sin(th) / math.hypot(ky, math.sin(kx)))
                  	return tmp
                  
                  function code(kx, ky, th)
                  	tmp = 0.0
                  	if (th <= 0.00235)
                  		tmp = Float64(Float64(sin(ky) / hypot(sin(kx), sin(ky))) * th);
                  	else
                  		tmp = Float64(ky * Float64(sin(th) / hypot(ky, sin(kx))));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(kx, ky, th)
                  	tmp = 0.0;
                  	if (th <= 0.00235)
                  		tmp = (sin(ky) / hypot(sin(kx), sin(ky))) * th;
                  	else
                  		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[kx_, ky_, th_] := If[LessEqual[th, 0.00235], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;th \leq 0.00235:\\
                  \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot th\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if th < 0.00235000000000000009

                    1. Initial program 93.4%

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

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

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{\sin kx \cdot \sin kx + {\sin ky}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                      2. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                      3. hypot-defineN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                      4. hypot-lowering-hypot.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\sin kx, \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                      5. sin-lowering-sin.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                      6. sin-lowering-sin.f6499.7%

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                    5. Simplified99.7%

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \color{blue}{th}\right) \]
                    7. Step-by-step derivation
                      1. Simplified62.2%

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

                      if 0.00235000000000000009 < th

                      1. Initial program 91.4%

                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                      2. Step-by-step derivation
                        1. associate-*l/N/A

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

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

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

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

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                        6. sin-lowering-sin.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                        7. +-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                        8. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                        9. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                        10. hypot-defineN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                        11. hypot-lowering-hypot.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                        12. sin-lowering-sin.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                        13. sin-lowering-sin.f6499.4%

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                      3. Simplified99.4%

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

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

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

                          \[\leadsto \mathsf{*.f64}\left(\color{blue}{ky}, \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(ky, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                        3. Step-by-step derivation
                          1. Simplified75.4%

                            \[\leadsto \color{blue}{ky} \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)} \]
                        4. Recombined 2 regimes into one program.
                        5. Add Preprocessing

                        Alternative 7: 67.1% accurate, 1.7× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 0.000122:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \end{array} \end{array} \]
                        (FPCore (kx ky th)
                         :precision binary64
                         (if (<= th 0.000122)
                           (* (sin ky) (/ th (hypot (sin ky) (sin kx))))
                           (* ky (/ (sin th) (hypot ky (sin kx))))))
                        double code(double kx, double ky, double th) {
                        	double tmp;
                        	if (th <= 0.000122) {
                        		tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
                        	} else {
                        		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
                        	}
                        	return tmp;
                        }
                        
                        public static double code(double kx, double ky, double th) {
                        	double tmp;
                        	if (th <= 0.000122) {
                        		tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
                        	} else {
                        		tmp = ky * (Math.sin(th) / Math.hypot(ky, Math.sin(kx)));
                        	}
                        	return tmp;
                        }
                        
                        def code(kx, ky, th):
                        	tmp = 0
                        	if th <= 0.000122:
                        		tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx)))
                        	else:
                        		tmp = ky * (math.sin(th) / math.hypot(ky, math.sin(kx)))
                        	return tmp
                        
                        function code(kx, ky, th)
                        	tmp = 0.0
                        	if (th <= 0.000122)
                        		tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx))));
                        	else
                        		tmp = Float64(ky * Float64(sin(th) / hypot(ky, sin(kx))));
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(kx, ky, th)
                        	tmp = 0.0;
                        	if (th <= 0.000122)
                        		tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
                        	else
                        		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[kx_, ky_, th_] := If[LessEqual[th, 0.000122], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;th \leq 0.000122:\\
                        \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if th < 1.21999999999999997e-4

                          1. Initial program 93.4%

                            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                          2. Step-by-step derivation
                            1. associate-*l/N/A

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

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

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

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                            6. sin-lowering-sin.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                            7. +-commutativeN/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                            8. unpow2N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                            9. unpow2N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                            10. hypot-defineN/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                            11. hypot-lowering-hypot.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                            12. sin-lowering-sin.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                            13. sin-lowering-sin.f6499.6%

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                          3. Simplified99.6%

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

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\color{blue}{th}, \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                          6. Step-by-step derivation
                            1. Simplified62.1%

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

                            if 1.21999999999999997e-4 < th

                            1. Initial program 91.4%

                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                            2. Step-by-step derivation
                              1. associate-*l/N/A

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

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

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

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

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                              6. sin-lowering-sin.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                              7. +-commutativeN/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                              8. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                              9. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                              10. hypot-defineN/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                              11. hypot-lowering-hypot.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                              12. sin-lowering-sin.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                              13. sin-lowering-sin.f6499.4%

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                            3. Simplified99.4%

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

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

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

                                \[\leadsto \mathsf{*.f64}\left(\color{blue}{ky}, \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(ky, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                              3. Step-by-step derivation
                                1. Simplified75.4%

                                  \[\leadsto \color{blue}{ky} \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)} \]
                              4. Recombined 2 regimes into one program.
                              5. Add Preprocessing

                              Alternative 8: 40.4% accurate, 1.7× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin kx \leq 10^{-104}:\\ \;\;\;\;0.5 \cdot \frac{ky \cdot \left(\sin th + \sin th\right)}{ky}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \end{array} \end{array} \]
                              (FPCore (kx ky th)
                               :precision binary64
                               (if (<= (sin kx) 1e-104)
                                 (* 0.5 (/ (* ky (+ (sin th) (sin th))) ky))
                                 (* (sin th) (/ (sin ky) (sin kx)))))
                              double code(double kx, double ky, double th) {
                              	double tmp;
                              	if (sin(kx) <= 1e-104) {
                              		tmp = 0.5 * ((ky * (sin(th) + sin(th))) / ky);
                              	} else {
                              		tmp = sin(th) * (sin(ky) / sin(kx));
                              	}
                              	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) <= 1d-104) then
                                      tmp = 0.5d0 * ((ky * (sin(th) + sin(th))) / ky)
                                  else
                                      tmp = sin(th) * (sin(ky) / sin(kx))
                                  end if
                                  code = tmp
                              end function
                              
                              public static double code(double kx, double ky, double th) {
                              	double tmp;
                              	if (Math.sin(kx) <= 1e-104) {
                              		tmp = 0.5 * ((ky * (Math.sin(th) + Math.sin(th))) / ky);
                              	} else {
                              		tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
                              	}
                              	return tmp;
                              }
                              
                              def code(kx, ky, th):
                              	tmp = 0
                              	if math.sin(kx) <= 1e-104:
                              		tmp = 0.5 * ((ky * (math.sin(th) + math.sin(th))) / ky)
                              	else:
                              		tmp = math.sin(th) * (math.sin(ky) / math.sin(kx))
                              	return tmp
                              
                              function code(kx, ky, th)
                              	tmp = 0.0
                              	if (sin(kx) <= 1e-104)
                              		tmp = Float64(0.5 * Float64(Float64(ky * Float64(sin(th) + sin(th))) / ky));
                              	else
                              		tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx)));
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(kx, ky, th)
                              	tmp = 0.0;
                              	if (sin(kx) <= 1e-104)
                              		tmp = 0.5 * ((ky * (sin(th) + sin(th))) / ky);
                              	else
                              		tmp = sin(th) * (sin(ky) / sin(kx));
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-104], N[(0.5 * N[(N[(ky * N[(N[Sin[th], $MachinePrecision] + N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;\sin kx \leq 10^{-104}:\\
                              \;\;\;\;0.5 \cdot \frac{ky \cdot \left(\sin th + \sin th\right)}{ky}\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if (sin.f64 kx) < 9.99999999999999927e-105

                                1. Initial program 89.9%

                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                2. Step-by-step derivation
                                  1. associate-*l/N/A

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

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

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

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

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                  6. sin-lowering-sin.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                  7. +-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                  8. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                  9. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                  10. hypot-defineN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                  11. hypot-lowering-hypot.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                  12. sin-lowering-sin.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                  13. sin-lowering-sin.f6499.6%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                3. Simplified99.6%

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

                                  \[\leadsto \color{blue}{\sin th} \]
                                6. Step-by-step derivation
                                  1. sin-lowering-sin.f6426.8%

                                    \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                7. Simplified26.8%

                                  \[\leadsto \color{blue}{\sin th} \]
                                8. Step-by-step derivation
                                  1. *-rgt-identityN/A

                                    \[\leadsto \sin th \cdot \color{blue}{1} \]
                                  2. lft-mult-inverseN/A

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

                                    \[\leadsto \left(\sin th \cdot \frac{1}{\sin ky}\right) \cdot \color{blue}{\sin ky} \]
                                  4. div-invN/A

                                    \[\leadsto \frac{\sin th}{\sin ky} \cdot \sin \color{blue}{ky} \]
                                  5. *-commutativeN/A

                                    \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sin ky}} \]
                                  6. associate-*r/N/A

                                    \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sin ky}} \]
                                  7. div-invN/A

                                    \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sin ky}} \]
                                  8. sin-multN/A

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

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

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

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\cos \left(ky - th\right) - \cos \left(ky + th\right)\right), 1\right), \left(\color{blue}{2} \cdot \sin ky\right)\right) \]
                                  12. --lowering--.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\cos \left(ky - th\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                  13. cos-lowering-cos.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\left(ky - th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                  14. --lowering--.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                  15. cos-lowering-cos.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\left(ky + th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                  16. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                  17. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \color{blue}{\sin ky}\right)\right) \]
                                  18. sin-lowering-sin.f6410.8%

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \mathsf{sin.f64}\left(ky\right)\right)\right) \]
                                9. Applied egg-rr10.8%

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

                                  \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot \left(ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right)\right) + \frac{1}{2} \cdot \left(\cos \left(\mathsf{neg}\left(th\right)\right) - \cos th\right)}{ky}} \]
                                11. Step-by-step derivation
                                  1. distribute-lft-outN/A

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

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

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

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right) + \left(\cos \left(\mathsf{neg}\left(th\right)\right) - \cos \left(\mathsf{neg}\left(th\right)\right)\right)}{ky}\right)\right) \]
                                  5. +-inversesN/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right) + 0}{ky}\right)\right) \]
                                  6. /-lowering-/.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right) + 0\right), \color{blue}{ky}\right)\right) \]
                                12. Simplified31.6%

                                  \[\leadsto \color{blue}{0.5 \cdot \frac{ky \cdot \left(\sin th + \sin th\right) + 0}{ky}} \]

                                if 9.99999999999999927e-105 < (sin.f64 kx)

                                1. Initial program 99.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 \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \color{blue}{\sin kx}\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                4. Step-by-step derivation
                                  1. sin-lowering-sin.f6462.2%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                5. Simplified62.2%

                                  \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                              3. Recombined 2 regimes into one program.
                              4. Final simplification41.3%

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

                              Alternative 9: 40.4% accurate, 1.7× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin kx \leq 10^{-104}:\\ \;\;\;\;0.5 \cdot \frac{ky \cdot \left(\sin th + \sin th\right)}{ky}\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\ \end{array} \end{array} \]
                              (FPCore (kx ky th)
                               :precision binary64
                               (if (<= (sin kx) 1e-104)
                                 (* 0.5 (/ (* ky (+ (sin th) (sin th))) ky))
                                 (* (sin ky) (/ (sin th) (sin kx)))))
                              double code(double kx, double ky, double th) {
                              	double tmp;
                              	if (sin(kx) <= 1e-104) {
                              		tmp = 0.5 * ((ky * (sin(th) + sin(th))) / ky);
                              	} else {
                              		tmp = sin(ky) * (sin(th) / sin(kx));
                              	}
                              	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) <= 1d-104) then
                                      tmp = 0.5d0 * ((ky * (sin(th) + sin(th))) / ky)
                                  else
                                      tmp = sin(ky) * (sin(th) / sin(kx))
                                  end if
                                  code = tmp
                              end function
                              
                              public static double code(double kx, double ky, double th) {
                              	double tmp;
                              	if (Math.sin(kx) <= 1e-104) {
                              		tmp = 0.5 * ((ky * (Math.sin(th) + Math.sin(th))) / ky);
                              	} else {
                              		tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
                              	}
                              	return tmp;
                              }
                              
                              def code(kx, ky, th):
                              	tmp = 0
                              	if math.sin(kx) <= 1e-104:
                              		tmp = 0.5 * ((ky * (math.sin(th) + math.sin(th))) / ky)
                              	else:
                              		tmp = math.sin(ky) * (math.sin(th) / math.sin(kx))
                              	return tmp
                              
                              function code(kx, ky, th)
                              	tmp = 0.0
                              	if (sin(kx) <= 1e-104)
                              		tmp = Float64(0.5 * Float64(Float64(ky * Float64(sin(th) + sin(th))) / ky));
                              	else
                              		tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx)));
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(kx, ky, th)
                              	tmp = 0.0;
                              	if (sin(kx) <= 1e-104)
                              		tmp = 0.5 * ((ky * (sin(th) + sin(th))) / ky);
                              	else
                              		tmp = sin(ky) * (sin(th) / sin(kx));
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-104], N[(0.5 * N[(N[(ky * N[(N[Sin[th], $MachinePrecision] + N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;\sin kx \leq 10^{-104}:\\
                              \;\;\;\;0.5 \cdot \frac{ky \cdot \left(\sin th + \sin th\right)}{ky}\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if (sin.f64 kx) < 9.99999999999999927e-105

                                1. Initial program 89.9%

                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                2. Step-by-step derivation
                                  1. associate-*l/N/A

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

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

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

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

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                  6. sin-lowering-sin.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                  7. +-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                  8. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                  9. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                  10. hypot-defineN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                  11. hypot-lowering-hypot.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                  12. sin-lowering-sin.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                  13. sin-lowering-sin.f6499.6%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                3. Simplified99.6%

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

                                  \[\leadsto \color{blue}{\sin th} \]
                                6. Step-by-step derivation
                                  1. sin-lowering-sin.f6426.8%

                                    \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                7. Simplified26.8%

                                  \[\leadsto \color{blue}{\sin th} \]
                                8. Step-by-step derivation
                                  1. *-rgt-identityN/A

                                    \[\leadsto \sin th \cdot \color{blue}{1} \]
                                  2. lft-mult-inverseN/A

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

                                    \[\leadsto \left(\sin th \cdot \frac{1}{\sin ky}\right) \cdot \color{blue}{\sin ky} \]
                                  4. div-invN/A

                                    \[\leadsto \frac{\sin th}{\sin ky} \cdot \sin \color{blue}{ky} \]
                                  5. *-commutativeN/A

                                    \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sin ky}} \]
                                  6. associate-*r/N/A

                                    \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sin ky}} \]
                                  7. div-invN/A

                                    \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sin ky}} \]
                                  8. sin-multN/A

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

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

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

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\cos \left(ky - th\right) - \cos \left(ky + th\right)\right), 1\right), \left(\color{blue}{2} \cdot \sin ky\right)\right) \]
                                  12. --lowering--.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\cos \left(ky - th\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                  13. cos-lowering-cos.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\left(ky - th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                  14. --lowering--.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                  15. cos-lowering-cos.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\left(ky + th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                  16. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                  17. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \color{blue}{\sin ky}\right)\right) \]
                                  18. sin-lowering-sin.f6410.8%

                                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \mathsf{sin.f64}\left(ky\right)\right)\right) \]
                                9. Applied egg-rr10.8%

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

                                  \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot \left(ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right)\right) + \frac{1}{2} \cdot \left(\cos \left(\mathsf{neg}\left(th\right)\right) - \cos th\right)}{ky}} \]
                                11. Step-by-step derivation
                                  1. distribute-lft-outN/A

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

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

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

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right) + \left(\cos \left(\mathsf{neg}\left(th\right)\right) - \cos \left(\mathsf{neg}\left(th\right)\right)\right)}{ky}\right)\right) \]
                                  5. +-inversesN/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right) + 0}{ky}\right)\right) \]
                                  6. /-lowering-/.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right) + 0\right), \color{blue}{ky}\right)\right) \]
                                12. Simplified31.6%

                                  \[\leadsto \color{blue}{0.5 \cdot \frac{ky \cdot \left(\sin th + \sin th\right) + 0}{ky}} \]

                                if 9.99999999999999927e-105 < (sin.f64 kx)

                                1. Initial program 99.4%

                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                2. Step-by-step derivation
                                  1. associate-*l/N/A

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

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

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

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

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                  6. sin-lowering-sin.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                  7. +-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                  8. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                  9. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                  10. hypot-defineN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                  11. hypot-lowering-hypot.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                  12. sin-lowering-sin.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                  13. sin-lowering-sin.f6499.5%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                3. Simplified99.5%

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

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

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\sin kx}\right)\right) \]
                                  2. sin-lowering-sin.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \sin \color{blue}{kx}\right)\right) \]
                                  3. sin-lowering-sin.f6462.2%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{sin.f64}\left(kx\right)\right)\right) \]
                                7. Simplified62.2%

                                  \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sin kx}} \]
                              3. Recombined 2 regimes into one program.
                              4. Final simplification41.3%

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

                              Alternative 10: 62.3% accurate, 2.3× speedup?

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

                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                              2. Step-by-step derivation
                                1. associate-*l/N/A

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

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

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

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

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                6. sin-lowering-sin.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                7. +-commutativeN/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                8. unpow2N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                9. unpow2N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                10. hypot-defineN/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                11. hypot-lowering-hypot.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                12. sin-lowering-sin.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                13. sin-lowering-sin.f6499.6%

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                              3. Simplified99.6%

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

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\color{blue}{ky}, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                              6. Step-by-step derivation
                                1. Simplified62.1%

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

                                  \[\leadsto \mathsf{*.f64}\left(\color{blue}{ky}, \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(ky, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                3. Step-by-step derivation
                                  1. Simplified70.3%

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

                                  Alternative 11: 33.3% accurate, 3.3× speedup?

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

                                    1. Initial program 89.9%

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

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

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{\sin kx \cdot \sin kx + {\sin ky}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                      2. unpow2N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                      3. hypot-defineN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                      4. hypot-lowering-hypot.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\sin kx, \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                      5. sin-lowering-sin.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                      6. sin-lowering-sin.f6499.6%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                    5. Simplified99.6%

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

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \left(\frac{\sin ky}{1}\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                      2. clear-numN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \left(\frac{1}{\frac{1}{\sin ky}}\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                      3. /-lowering-/.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{/.f64}\left(1, \left(\frac{1}{\sin ky}\right)\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                      4. /-lowering-/.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \sin ky\right)\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                      5. sin-lowering-sin.f6499.5%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(ky\right)\right)\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                    7. Applied egg-rr99.5%

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

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

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

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

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

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

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\frac{\mathsf{hypot}\left(\sin kx, \frac{1}{\frac{1}{\sin ky}}\right)}{\sin \color{blue}{ky}}\right)\right) \]
                                      7. remove-double-divN/A

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin ky}\right)\right) \]
                                      8. hypot-defineN/A

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\frac{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}}{\sin \color{blue}{ky}}\right)\right) \]
                                      9. /-lowering-/.f64N/A

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right), \color{blue}{\sin ky}\right)\right) \]
                                    9. Applied egg-rr99.6%

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

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

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\sin kx, \color{blue}{ky}\right)\right) \]
                                      2. sin-lowering-sin.f6433.4%

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(kx\right), ky\right)\right) \]
                                    12. Simplified33.4%

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

                                    if 4.2000000000000002e-97 < ky

                                    1. Initial program 99.7%

                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                    2. Step-by-step derivation
                                      1. associate-*l/N/A

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

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

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

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

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                      6. sin-lowering-sin.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                      7. +-commutativeN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                      8. unpow2N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                      9. unpow2N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                      10. hypot-defineN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                      11. hypot-lowering-hypot.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                      12. sin-lowering-sin.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                      13. sin-lowering-sin.f6499.6%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                    3. Simplified99.6%

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

                                      \[\leadsto \color{blue}{\sin th} \]
                                    6. Step-by-step derivation
                                      1. sin-lowering-sin.f6436.0%

                                        \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                    7. Simplified36.0%

                                      \[\leadsto \color{blue}{\sin th} \]
                                    8. Step-by-step derivation
                                      1. *-rgt-identityN/A

                                        \[\leadsto \sin th \cdot \color{blue}{1} \]
                                      2. lft-mult-inverseN/A

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

                                        \[\leadsto \left(\sin th \cdot \frac{1}{\sin ky}\right) \cdot \color{blue}{\sin ky} \]
                                      4. div-invN/A

                                        \[\leadsto \frac{\sin th}{\sin ky} \cdot \sin \color{blue}{ky} \]
                                      5. *-commutativeN/A

                                        \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sin ky}} \]
                                      6. associate-*r/N/A

                                        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sin ky}} \]
                                      7. div-invN/A

                                        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sin ky}} \]
                                      8. sin-multN/A

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

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

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

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\cos \left(ky - th\right) - \cos \left(ky + th\right)\right), 1\right), \left(\color{blue}{2} \cdot \sin ky\right)\right) \]
                                      12. --lowering--.f64N/A

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\cos \left(ky - th\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                      13. cos-lowering-cos.f64N/A

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\left(ky - th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                      14. --lowering--.f64N/A

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                      15. cos-lowering-cos.f64N/A

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\left(ky + th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                      16. +-lowering-+.f64N/A

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                      17. *-lowering-*.f64N/A

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \color{blue}{\sin ky}\right)\right) \]
                                      18. sin-lowering-sin.f6410.1%

                                        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \mathsf{sin.f64}\left(ky\right)\right)\right) \]
                                    9. Applied egg-rr10.1%

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

                                      \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot \left(ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right)\right) + \frac{1}{2} \cdot \left(\cos \left(\mathsf{neg}\left(th\right)\right) - \cos th\right)}{ky}} \]
                                    11. Step-by-step derivation
                                      1. distribute-lft-outN/A

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

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

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

                                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right) + \left(\cos \left(\mathsf{neg}\left(th\right)\right) - \cos \left(\mathsf{neg}\left(th\right)\right)\right)}{ky}\right)\right) \]
                                      5. +-inversesN/A

                                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right) + 0}{ky}\right)\right) \]
                                      6. /-lowering-/.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(ky \cdot \left(\sin th - \sin \left(\mathsf{neg}\left(th\right)\right)\right) + 0\right), \color{blue}{ky}\right)\right) \]
                                    12. Simplified40.5%

                                      \[\leadsto \color{blue}{0.5 \cdot \frac{ky \cdot \left(\sin th + \sin th\right) + 0}{ky}} \]
                                  3. Recombined 2 regimes into one program.
                                  4. Final simplification35.6%

                                    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 4.2 \cdot 10^{-97}:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{ky \cdot \left(\sin th + \sin th\right)}{ky}\\ \end{array} \]
                                  5. Add Preprocessing

                                  Alternative 12: 30.2% accurate, 3.4× speedup?

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

                                    1. Initial program 89.4%

                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                    2. Step-by-step derivation
                                      1. associate-*l/N/A

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

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

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

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

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                      6. sin-lowering-sin.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                      7. +-commutativeN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                      8. unpow2N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                      9. unpow2N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                      10. hypot-defineN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                      11. hypot-lowering-hypot.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                      12. sin-lowering-sin.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                      13. sin-lowering-sin.f6499.6%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                    3. Simplified99.6%

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

                                      \[\leadsto \color{blue}{\sin th} \]
                                    6. Step-by-step derivation
                                      1. sin-lowering-sin.f6427.8%

                                        \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                    7. Simplified27.8%

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

                                    if 1.65000000000000001e-104 < kx

                                    1. Initial program 99.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 \mathsf{*.f64}\left(\color{blue}{\left(\frac{ky}{\sin kx}\right)}, \mathsf{sin.f64}\left(th\right)\right) \]
                                    4. Step-by-step derivation
                                      1. /-lowering-/.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(ky, \sin kx\right), \mathsf{sin.f64}\left(\color{blue}{th}\right)\right) \]
                                      2. sin-lowering-sin.f6442.4%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(ky, \mathsf{sin.f64}\left(kx\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                    5. Simplified42.4%

                                      \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot \sin th \]
                                  3. Recombined 2 regimes into one program.
                                  4. Final simplification32.9%

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

                                  Alternative 13: 26.9% accurate, 6.4× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 380000:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \end{array} \end{array} \]
                                  (FPCore (kx ky th)
                                   :precision binary64
                                   (if (<= kx 380000.0) (sin th) (* th (/ ky (sin kx)))))
                                  double code(double kx, double ky, double th) {
                                  	double tmp;
                                  	if (kx <= 380000.0) {
                                  		tmp = sin(th);
                                  	} else {
                                  		tmp = th * (ky / sin(kx));
                                  	}
                                  	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 (kx <= 380000.0d0) then
                                          tmp = sin(th)
                                      else
                                          tmp = th * (ky / sin(kx))
                                      end if
                                      code = tmp
                                  end function
                                  
                                  public static double code(double kx, double ky, double th) {
                                  	double tmp;
                                  	if (kx <= 380000.0) {
                                  		tmp = Math.sin(th);
                                  	} else {
                                  		tmp = th * (ky / Math.sin(kx));
                                  	}
                                  	return tmp;
                                  }
                                  
                                  def code(kx, ky, th):
                                  	tmp = 0
                                  	if kx <= 380000.0:
                                  		tmp = math.sin(th)
                                  	else:
                                  		tmp = th * (ky / math.sin(kx))
                                  	return tmp
                                  
                                  function code(kx, ky, th)
                                  	tmp = 0.0
                                  	if (kx <= 380000.0)
                                  		tmp = sin(th);
                                  	else
                                  		tmp = Float64(th * Float64(ky / sin(kx)));
                                  	end
                                  	return tmp
                                  end
                                  
                                  function tmp_2 = code(kx, ky, th)
                                  	tmp = 0.0;
                                  	if (kx <= 380000.0)
                                  		tmp = sin(th);
                                  	else
                                  		tmp = th * (ky / sin(kx));
                                  	end
                                  	tmp_2 = tmp;
                                  end
                                  
                                  code[kx_, ky_, th_] := If[LessEqual[kx, 380000.0], N[Sin[th], $MachinePrecision], N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;kx \leq 380000:\\
                                  \;\;\;\;\sin th\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;th \cdot \frac{ky}{\sin kx}\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if kx < 3.8e5

                                    1. Initial program 90.4%

                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                    2. Step-by-step derivation
                                      1. associate-*l/N/A

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

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

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

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

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                      6. sin-lowering-sin.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                      7. +-commutativeN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                      8. unpow2N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                      9. unpow2N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                      10. hypot-defineN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                      11. hypot-lowering-hypot.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                      12. sin-lowering-sin.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                      13. sin-lowering-sin.f6499.6%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                    3. Simplified99.6%

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

                                      \[\leadsto \color{blue}{\sin th} \]
                                    6. Step-by-step derivation
                                      1. sin-lowering-sin.f6427.6%

                                        \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                    7. Simplified27.6%

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

                                    if 3.8e5 < kx

                                    1. Initial program 99.4%

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

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(kx\right), 2\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), \color{blue}{th}\right) \]
                                    4. Step-by-step derivation
                                      1. Simplified47.8%

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

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

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(ky, \sin kx\right), th\right) \]
                                        2. sin-lowering-sin.f6422.4%

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(ky, \mathsf{sin.f64}\left(kx\right)\right), th\right) \]
                                      4. Simplified22.4%

                                        \[\leadsto \color{blue}{\frac{ky}{\sin kx}} \cdot th \]
                                    5. Recombined 2 regimes into one program.
                                    6. Final simplification26.1%

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 380000:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \end{array} \]
                                    7. Add Preprocessing

                                    Alternative 14: 26.9% accurate, 6.4× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 180000:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;ky \cdot \frac{th}{\sin kx}\\ \end{array} \end{array} \]
                                    (FPCore (kx ky th)
                                     :precision binary64
                                     (if (<= kx 180000.0) (sin th) (* ky (/ th (sin kx)))))
                                    double code(double kx, double ky, double th) {
                                    	double tmp;
                                    	if (kx <= 180000.0) {
                                    		tmp = sin(th);
                                    	} else {
                                    		tmp = ky * (th / sin(kx));
                                    	}
                                    	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 (kx <= 180000.0d0) then
                                            tmp = sin(th)
                                        else
                                            tmp = ky * (th / sin(kx))
                                        end if
                                        code = tmp
                                    end function
                                    
                                    public static double code(double kx, double ky, double th) {
                                    	double tmp;
                                    	if (kx <= 180000.0) {
                                    		tmp = Math.sin(th);
                                    	} else {
                                    		tmp = ky * (th / Math.sin(kx));
                                    	}
                                    	return tmp;
                                    }
                                    
                                    def code(kx, ky, th):
                                    	tmp = 0
                                    	if kx <= 180000.0:
                                    		tmp = math.sin(th)
                                    	else:
                                    		tmp = ky * (th / math.sin(kx))
                                    	return tmp
                                    
                                    function code(kx, ky, th)
                                    	tmp = 0.0
                                    	if (kx <= 180000.0)
                                    		tmp = sin(th);
                                    	else
                                    		tmp = Float64(ky * Float64(th / sin(kx)));
                                    	end
                                    	return tmp
                                    end
                                    
                                    function tmp_2 = code(kx, ky, th)
                                    	tmp = 0.0;
                                    	if (kx <= 180000.0)
                                    		tmp = sin(th);
                                    	else
                                    		tmp = ky * (th / sin(kx));
                                    	end
                                    	tmp_2 = tmp;
                                    end
                                    
                                    code[kx_, ky_, th_] := If[LessEqual[kx, 180000.0], N[Sin[th], $MachinePrecision], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    \mathbf{if}\;kx \leq 180000:\\
                                    \;\;\;\;\sin th\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;ky \cdot \frac{th}{\sin kx}\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if kx < 1.8e5

                                      1. Initial program 90.4%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Step-by-step derivation
                                        1. associate-*l/N/A

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

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

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

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

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                        6. sin-lowering-sin.f64N/A

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                        7. +-commutativeN/A

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                        8. unpow2N/A

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                        9. unpow2N/A

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                        10. hypot-defineN/A

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                        11. hypot-lowering-hypot.f64N/A

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                        12. sin-lowering-sin.f64N/A

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                        13. sin-lowering-sin.f6499.6%

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                      3. Simplified99.6%

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

                                        \[\leadsto \color{blue}{\sin th} \]
                                      6. Step-by-step derivation
                                        1. sin-lowering-sin.f6427.6%

                                          \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                      7. Simplified27.6%

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

                                      if 1.8e5 < kx

                                      1. Initial program 99.4%

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

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(kx\right), 2\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), \color{blue}{th}\right) \]
                                      4. Step-by-step derivation
                                        1. Simplified47.8%

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

                                          \[\leadsto \color{blue}{\frac{ky \cdot th}{\sin kx}} \]
                                        3. Step-by-step derivation
                                          1. associate-/l*N/A

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

                                            \[\leadsto \mathsf{*.f64}\left(ky, \color{blue}{\left(\frac{th}{\sin kx}\right)}\right) \]
                                          3. /-lowering-/.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(ky, \mathsf{/.f64}\left(th, \color{blue}{\sin kx}\right)\right) \]
                                          4. sin-lowering-sin.f6422.4%

                                            \[\leadsto \mathsf{*.f64}\left(ky, \mathsf{/.f64}\left(th, \mathsf{sin.f64}\left(kx\right)\right)\right) \]
                                        4. Simplified22.4%

                                          \[\leadsto \color{blue}{ky \cdot \frac{th}{\sin kx}} \]
                                      5. Recombined 2 regimes into one program.
                                      6. Add Preprocessing

                                      Alternative 15: 25.6% accurate, 6.7× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 3.15 \cdot 10^{+25}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
                                      (FPCore (kx ky th) :precision binary64 (if (<= kx 3.15e+25) (sin th) 0.0))
                                      double code(double kx, double ky, double th) {
                                      	double tmp;
                                      	if (kx <= 3.15e+25) {
                                      		tmp = sin(th);
                                      	} else {
                                      		tmp = 0.0;
                                      	}
                                      	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 (kx <= 3.15d+25) then
                                              tmp = sin(th)
                                          else
                                              tmp = 0.0d0
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double kx, double ky, double th) {
                                      	double tmp;
                                      	if (kx <= 3.15e+25) {
                                      		tmp = Math.sin(th);
                                      	} else {
                                      		tmp = 0.0;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(kx, ky, th):
                                      	tmp = 0
                                      	if kx <= 3.15e+25:
                                      		tmp = math.sin(th)
                                      	else:
                                      		tmp = 0.0
                                      	return tmp
                                      
                                      function code(kx, ky, th)
                                      	tmp = 0.0
                                      	if (kx <= 3.15e+25)
                                      		tmp = sin(th);
                                      	else
                                      		tmp = 0.0;
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(kx, ky, th)
                                      	tmp = 0.0;
                                      	if (kx <= 3.15e+25)
                                      		tmp = sin(th);
                                      	else
                                      		tmp = 0.0;
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[kx_, ky_, th_] := If[LessEqual[kx, 3.15e+25], N[Sin[th], $MachinePrecision], 0.0]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;kx \leq 3.15 \cdot 10^{+25}:\\
                                      \;\;\;\;\sin th\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;0\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if kx < 3.14999999999999987e25

                                        1. Initial program 90.6%

                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                        2. Step-by-step derivation
                                          1. associate-*l/N/A

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

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

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

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

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                          6. sin-lowering-sin.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                          7. +-commutativeN/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                          8. unpow2N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                          9. unpow2N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                          10. hypot-defineN/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                          11. hypot-lowering-hypot.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                          12. sin-lowering-sin.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                          13. sin-lowering-sin.f6499.6%

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                        3. Simplified99.6%

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

                                          \[\leadsto \color{blue}{\sin th} \]
                                        6. Step-by-step derivation
                                          1. sin-lowering-sin.f6427.0%

                                            \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                        7. Simplified27.0%

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

                                        if 3.14999999999999987e25 < kx

                                        1. Initial program 99.4%

                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                        2. Step-by-step derivation
                                          1. associate-*l/N/A

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

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

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

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

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                          6. sin-lowering-sin.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                          7. +-commutativeN/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                          8. unpow2N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                          9. unpow2N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                          10. hypot-defineN/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                          11. hypot-lowering-hypot.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                          12. sin-lowering-sin.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                          13. sin-lowering-sin.f6499.5%

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                        3. Simplified99.5%

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

                                          \[\leadsto \color{blue}{\sin th} \]
                                        6. Step-by-step derivation
                                          1. sin-lowering-sin.f646.8%

                                            \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                        7. Simplified6.8%

                                          \[\leadsto \color{blue}{\sin th} \]
                                        8. Step-by-step derivation
                                          1. *-rgt-identityN/A

                                            \[\leadsto \sin th \cdot \color{blue}{1} \]
                                          2. lft-mult-inverseN/A

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

                                            \[\leadsto \left(\sin th \cdot \frac{1}{\sin ky}\right) \cdot \color{blue}{\sin ky} \]
                                          4. div-invN/A

                                            \[\leadsto \frac{\sin th}{\sin ky} \cdot \sin \color{blue}{ky} \]
                                          5. *-commutativeN/A

                                            \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sin ky}} \]
                                          6. associate-*r/N/A

                                            \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sin ky}} \]
                                          7. div-invN/A

                                            \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sin ky}} \]
                                          8. sin-multN/A

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

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

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

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\cos \left(ky - th\right) - \cos \left(ky + th\right)\right), 1\right), \left(\color{blue}{2} \cdot \sin ky\right)\right) \]
                                          12. --lowering--.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\cos \left(ky - th\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                          13. cos-lowering-cos.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\left(ky - th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                          14. --lowering--.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                          15. cos-lowering-cos.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\left(ky + th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                          16. +-lowering-+.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                          17. *-lowering-*.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \color{blue}{\sin ky}\right)\right) \]
                                          18. sin-lowering-sin.f6421.7%

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \mathsf{sin.f64}\left(ky\right)\right)\right) \]
                                        9. Applied egg-rr21.7%

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

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

                                            \[\leadsto \frac{1}{2} \cdot \frac{\cos \left(\mathsf{neg}\left(th\right)\right) - \cos \left(\mathsf{neg}\left(th\right)\right)}{ky} \]
                                          2. div-subN/A

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

                                            \[\leadsto \frac{1}{2} \cdot 0 \]
                                          4. metadata-eval21.5%

                                            \[\leadsto 0 \]
                                        12. Simplified21.5%

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

                                      Alternative 16: 16.2% accurate, 117.9× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 7 \cdot 10^{-38}:\\ \;\;\;\;th\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
                                      (FPCore (kx ky th) :precision binary64 (if (<= kx 7e-38) th 0.0))
                                      double code(double kx, double ky, double th) {
                                      	double tmp;
                                      	if (kx <= 7e-38) {
                                      		tmp = th;
                                      	} else {
                                      		tmp = 0.0;
                                      	}
                                      	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 (kx <= 7d-38) then
                                              tmp = th
                                          else
                                              tmp = 0.0d0
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double kx, double ky, double th) {
                                      	double tmp;
                                      	if (kx <= 7e-38) {
                                      		tmp = th;
                                      	} else {
                                      		tmp = 0.0;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(kx, ky, th):
                                      	tmp = 0
                                      	if kx <= 7e-38:
                                      		tmp = th
                                      	else:
                                      		tmp = 0.0
                                      	return tmp
                                      
                                      function code(kx, ky, th)
                                      	tmp = 0.0
                                      	if (kx <= 7e-38)
                                      		tmp = th;
                                      	else
                                      		tmp = 0.0;
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(kx, ky, th)
                                      	tmp = 0.0;
                                      	if (kx <= 7e-38)
                                      		tmp = th;
                                      	else
                                      		tmp = 0.0;
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[kx_, ky_, th_] := If[LessEqual[kx, 7e-38], th, 0.0]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;kx \leq 7 \cdot 10^{-38}:\\
                                      \;\;\;\;th\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;0\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if kx < 7.0000000000000003e-38

                                        1. Initial program 89.9%

                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                        2. Step-by-step derivation
                                          1. associate-*l/N/A

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

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

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

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

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                          6. sin-lowering-sin.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                          7. +-commutativeN/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                          8. unpow2N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                          9. unpow2N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                          10. hypot-defineN/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                          11. hypot-lowering-hypot.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                          12. sin-lowering-sin.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                          13. sin-lowering-sin.f6499.6%

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                        3. Simplified99.6%

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

                                          \[\leadsto \color{blue}{\sin th} \]
                                        6. Step-by-step derivation
                                          1. sin-lowering-sin.f6428.3%

                                            \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                        7. Simplified28.3%

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

                                          \[\leadsto \color{blue}{th} \]
                                        9. Step-by-step derivation
                                          1. Simplified19.8%

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

                                          if 7.0000000000000003e-38 < kx

                                          1. Initial program 99.4%

                                            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                          2. Step-by-step derivation
                                            1. associate-*l/N/A

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

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

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

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

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                            6. sin-lowering-sin.f64N/A

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                            7. +-commutativeN/A

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                            8. unpow2N/A

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                            9. unpow2N/A

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                            10. hypot-defineN/A

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                            11. hypot-lowering-hypot.f64N/A

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                            12. sin-lowering-sin.f64N/A

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                            13. sin-lowering-sin.f6499.5%

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                          3. Simplified99.5%

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

                                            \[\leadsto \color{blue}{\sin th} \]
                                          6. Step-by-step derivation
                                            1. sin-lowering-sin.f647.6%

                                              \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                          7. Simplified7.6%

                                            \[\leadsto \color{blue}{\sin th} \]
                                          8. Step-by-step derivation
                                            1. *-rgt-identityN/A

                                              \[\leadsto \sin th \cdot \color{blue}{1} \]
                                            2. lft-mult-inverseN/A

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

                                              \[\leadsto \left(\sin th \cdot \frac{1}{\sin ky}\right) \cdot \color{blue}{\sin ky} \]
                                            4. div-invN/A

                                              \[\leadsto \frac{\sin th}{\sin ky} \cdot \sin \color{blue}{ky} \]
                                            5. *-commutativeN/A

                                              \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sin ky}} \]
                                            6. associate-*r/N/A

                                              \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sin ky}} \]
                                            7. div-invN/A

                                              \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sin ky}} \]
                                            8. sin-multN/A

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

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

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

                                              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\cos \left(ky - th\right) - \cos \left(ky + th\right)\right), 1\right), \left(\color{blue}{2} \cdot \sin ky\right)\right) \]
                                            12. --lowering--.f64N/A

                                              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\cos \left(ky - th\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                            13. cos-lowering-cos.f64N/A

                                              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\left(ky - th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                            14. --lowering--.f64N/A

                                              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                            15. cos-lowering-cos.f64N/A

                                              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\left(ky + th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                            16. +-lowering-+.f64N/A

                                              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                            17. *-lowering-*.f64N/A

                                              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \color{blue}{\sin ky}\right)\right) \]
                                            18. sin-lowering-sin.f6420.0%

                                              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \mathsf{sin.f64}\left(ky\right)\right)\right) \]
                                          9. Applied egg-rr20.0%

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

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

                                              \[\leadsto \frac{1}{2} \cdot \frac{\cos \left(\mathsf{neg}\left(th\right)\right) - \cos \left(\mathsf{neg}\left(th\right)\right)}{ky} \]
                                            2. div-subN/A

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

                                              \[\leadsto \frac{1}{2} \cdot 0 \]
                                            4. metadata-eval19.8%

                                              \[\leadsto 0 \]
                                          12. Simplified19.8%

                                            \[\leadsto \color{blue}{0} \]
                                        10. Recombined 2 regimes into one program.
                                        11. Add Preprocessing

                                        Alternative 17: 12.2% accurate, 709.0× speedup?

                                        \[\begin{array}{l} \\ 0 \end{array} \]
                                        (FPCore (kx ky th) :precision binary64 0.0)
                                        double code(double kx, double ky, double th) {
                                        	return 0.0;
                                        }
                                        
                                        real(8) function code(kx, ky, th)
                                            real(8), intent (in) :: kx
                                            real(8), intent (in) :: ky
                                            real(8), intent (in) :: th
                                            code = 0.0d0
                                        end function
                                        
                                        public static double code(double kx, double ky, double th) {
                                        	return 0.0;
                                        }
                                        
                                        def code(kx, ky, th):
                                        	return 0.0
                                        
                                        function code(kx, ky, th)
                                        	return 0.0
                                        end
                                        
                                        function tmp = code(kx, ky, th)
                                        	tmp = 0.0;
                                        end
                                        
                                        code[kx_, ky_, th_] := 0.0
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        0
                                        \end{array}
                                        
                                        Derivation
                                        1. Initial program 92.9%

                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                        2. Step-by-step derivation
                                          1. associate-*l/N/A

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

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

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

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

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                                          6. sin-lowering-sin.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                                          7. +-commutativeN/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                                          8. unpow2N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                                          9. unpow2N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                          10. hypot-defineN/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                                          11. hypot-lowering-hypot.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                          12. sin-lowering-sin.f64N/A

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                          13. sin-lowering-sin.f6499.6%

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                                        3. Simplified99.6%

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

                                          \[\leadsto \color{blue}{\sin th} \]
                                        6. Step-by-step derivation
                                          1. sin-lowering-sin.f6421.7%

                                            \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                        7. Simplified21.7%

                                          \[\leadsto \color{blue}{\sin th} \]
                                        8. Step-by-step derivation
                                          1. *-rgt-identityN/A

                                            \[\leadsto \sin th \cdot \color{blue}{1} \]
                                          2. lft-mult-inverseN/A

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

                                            \[\leadsto \left(\sin th \cdot \frac{1}{\sin ky}\right) \cdot \color{blue}{\sin ky} \]
                                          4. div-invN/A

                                            \[\leadsto \frac{\sin th}{\sin ky} \cdot \sin \color{blue}{ky} \]
                                          5. *-commutativeN/A

                                            \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sin ky}} \]
                                          6. associate-*r/N/A

                                            \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sin ky}} \]
                                          7. div-invN/A

                                            \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sin ky}} \]
                                          8. sin-multN/A

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

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

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

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\cos \left(ky - th\right) - \cos \left(ky + th\right)\right), 1\right), \left(\color{blue}{2} \cdot \sin ky\right)\right) \]
                                          12. --lowering--.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\cos \left(ky - th\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                          13. cos-lowering-cos.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\left(ky - th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                          14. --lowering--.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \cos \left(ky + th\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                          15. cos-lowering-cos.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\left(ky + th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                          16. +-lowering-+.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \left(2 \cdot \sin ky\right)\right) \]
                                          17. *-lowering-*.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \color{blue}{\sin ky}\right)\right) \]
                                          18. sin-lowering-sin.f6412.6%

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(ky, th\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(ky, th\right)\right)\right), 1\right), \mathsf{*.f64}\left(2, \mathsf{sin.f64}\left(ky\right)\right)\right) \]
                                        9. Applied egg-rr12.6%

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

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

                                            \[\leadsto \frac{1}{2} \cdot \frac{\cos \left(\mathsf{neg}\left(th\right)\right) - \cos \left(\mathsf{neg}\left(th\right)\right)}{ky} \]
                                          2. div-subN/A

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

                                            \[\leadsto \frac{1}{2} \cdot 0 \]
                                          4. metadata-eval12.5%

                                            \[\leadsto 0 \]
                                        12. Simplified12.5%

                                          \[\leadsto \color{blue}{0} \]
                                        13. Add Preprocessing

                                        Reproduce

                                        ?
                                        herbie shell --seed 2024138 
                                        (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)))